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

Robert Osfield robert.osfield at gmail.com
Wed Jul 23 01:56:05 PDT 2008

Hi James,

Can you not just avoid GLUT because it's crap for an proper
application development.  Or just put the GLUT include last.  I'm not
going to mess around with the core OSG to make up for deficiencies in
an API that is well passed it's sell by date.


On Wed, Jul 23, 2008 at 9:07 AM, James Turner <zakalawe at mac.com> wrote:
> 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
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list