[osg-users] openGL extensions

Ben Axelrod baxelrod at coroware.com
Thu Sep 25 10:15:51 PDT 2008

Thank you Jean and Gordon.  I put those functions in my draw callback and now I get some information.  However, the behavior is very strange.  It only works the first time through.  The rest of the time, they return null.  Even weirder is that if I click on another window, they work again for one iteration, then go back to being null.  Every time I click off and on again of my OSG application, the info appears.  Why is this?

FYI: OSG 2.6.0 on Debian Etch with an NVidia 7300 card.


-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org [mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay
Sent: Monday, September 22, 2008 8:12 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] openGL extensions

Hi Ben,

> I would like to detect if the user has the appropriate openGL extensions
> in order to do shadowing.  However, when I do:
> glGetString(GL_VERSION)
> glGetString(GL_EXTENSIONS)
> They return null.  How can I get a list of the available extensions?  Is
> there an easy way to get this info from OSG?

For the first part of your question, they return NULL if they were
called from a thread that does not have a graphics context. The safest
way to do this is to create a camera predraw/postdraw/finaldraw callback
or a node cull callback or a drawable draw callback. In each of these
points you will have a graphics context.

What I generally do is assume support is present and start the viewer
with a detection callback attached (camera predraw callback on the main
camera) which will check extensions and then remove itself from the
camera. Then after the first frame, if I see that some feature is not
supported, I disable the relevant options.

There are other valid strategies of course.

As for detecting actual extensions, instead of calling
glGetString(GL_EXTENSIONS) and parsing it yourself, you can use

#include <osg/GLExtensions>
#include <osg/GL2Extensions>

osg::isGLExtensionSupported(contextID, extensionName)

> Also, how do I know which extensions I need for the different shadow
> techniques?

I'm personally not sure which extensions are required for all of them,
perhaps someone else will know (it might be good to add that info to the
osgShadow page on the wiki). I can tell you what I test for in the case
of osgShadow::ShadowMap:

_shadowsSupported =
     "GL_EXT_framebuffer_object") &&
     "GL_ARB_fragment_program") ||
     "GL_EXT_fragment_program")) &&
     "GL_ARB_fragment_program_shadow") ||

Not sure if that's totally correct, but in most cases where shadow maps
were not supported (they fell back to software and so were extremely
slow) it was the first (GL_EXT_framebuffer_object) which was not supported.

Hope this helps,

Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
osg-users mailing list
osg-users at lists.openscenegraph.org

More information about the osg-users mailing list