[osg-users] osg/GL + glut.h interaction

James Turner zakalawe at mac.com
Wed Jul 23 01:07:08 PDT 2008


Apologies if this is a FAQ or otherwise known, but, the following test  
program fails to compile for me:

=============================


#include <osg/StateSet>

#include <GLUT/glut.h>

#include <osg/Drawable>

int main(int argc, char** argv)
{
   return 0;
}


=============================

I'm on Mac, change <GLUT/glut.h> to <GL/glut.h> or similar if required.

As it turns out, I don't even want GLUT support in the program I was  
trying to build but there's a genuine issue here - glut.h behaves very  
badly: at its end, it #undef-s APIENTRY.

So when <osg/Drawable> is included, <osg/GL> has already been included  
(and guarded against another include, by defining _osg_gl), but  
APIENTRY has been undefined so never gets expanded again - the end  
result is I end up with APIENTRY in the pre-processed source and  
obviously compilation fails.

This took me a while to figure out, so maybe it could be documented?  
But there is an actual (possible) fix - remove the multiple include  
guard  from <osg/GL>. This should be fine because it's a very small  
file that only consists of pre-processor actions. gl.h would still  
only be pulled in once, but APIENTRY would get set regardless.

Regards,
James



More information about the osg-users mailing list