Colliding with GL?

I am trying to figure out which #include’s to use when using the COLLADA DOM (I’ve already finished everything else).

I have the following includes at the top of my file:

#include <dae.h>
#include <dom/domMaterial.h>
#include <dom/domP.h>
#include <dom/domGeometry.h>
#include <dom/domTriangles.h>
#include <dom/domCOLLADA.h>
#include <SDL/SDL.h>
#include <GL/glew.h>

There is a problem, however, and I get it in domTypes.h:

/usr/local/include/colladadom/1.5/dom/domTypes.h:268: error: expected identifier before numeric constant
/usr/local/include/colladadom/1.5/dom/domTypes.h:268: error: expected `}' before numeric constant
/usr/local/include/colladadom/1.5/dom/domTypes.h:268: error: expected unqualified-id before numeric constant
/usr/local/include/colladadom/1.5/dom/domTypes.h:278: error: expected declaration before '}' token

This just means there is a name conflict, I think. I looked in the file, and this looks suspicous to me:

enum domGl_blend {
	GL_BLEND_ZERO = 0x0,
	GL_BLEND_ONE = 0x1,
	GL_BLEND_SRC_COLOR = 0x0300,
	GL_BLEND_ONE_MINUS_SRC_COLOR = 0x0301,
	GL_BLEND_DEST_COLOR = 0x0306,
	GL_BLEND_ONE_MINUS_DEST_COLOR = 0x0307,
	GL_BLEND_SRC_ALPHA = 0x0302,
	GL_BLEND_ONE_MINUS_SRC_ALPHA = 0x0303,
	GL_BLEND_DST_ALPHA = 0x0304,
	GL_BLEND_ONE_MINUS_DST_ALPHA = 0x0305,
	GL_BLEND_CONSTANT_COLOR = 0x8001,
	GL_BLEND_ONE_MINUS_CONSTANT_COLOR = 0x8002,
	GL_BLEND_CONSTANT_ALPHA = 0x8003,
	GL_BLEND_ONE_MINUS_CONSTANT_ALPHA = 0x8004,
	GL_BLEND_SRC_ALPHA_SATURATE = 0x0308,
	GL_BLEND_COUNT = 15
};

Am I doing something wrong?

EDIT:

I think I know the problem.

GLEW uses #define’s to create the constants, so the preprocessor is replacing the text with the value:


#define GL_BLEND_SRC_ALPHA 0x80CB

This is a naming conflict. What should I do? The actual values are different, which means that something is wrong.

If it’s a order of declaration problem then you can test it by commenting out #include <GL/glew.h> and the problem changes to something else. Probably you will have to isolate both compilation units that use the same tokens because while the DOM names are properly scoped, the OpeGL header historically uses #defines that stomp on any token matches.

The enum domGl_blend maps to values for OpenGL BlendingFactorDest and BlendingFactorSrc enums, not to literal #defines that have similar names in gl.h etc…

Thanks, I think the solution would be to forward declare any types I really require from domTypes.h, and then make sure it doesn’t get included.

However, for now I am just using the 1.4 spec which doesn’t have these name conflicts ("_TYPE" is included in the names), and I’ve already loaded some models. Thanks!

You’re welcome.

The change in DOM tokens between the 1.4 and 1.5 schema builds appears to be schema driven. The code generator must parse them differently between “gl_blend_type” and “gl_blend_enum” respectively.

I’ve got the same problem. And i could solve it by the use of undefines.

#undef GL_BLEND_SRC_ALPHA

I added these macros to the header file domTypes.h and my code works fine.

Hope i could help.