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.

Thanks,
-Ben

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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 =
   osg::isGLExtensionSupported(contextID,
     "GL_EXT_framebuffer_object") &&
   (osg::isGLExtensionSupported(contextID,
     "GL_ARB_fragment_program") ||
    osg::isGLExtensionSupported(contextID,
     "GL_EXT_fragment_program")) &&
   (osg::isGLExtensionSupported(contextID,
     "GL_ARB_fragment_program_shadow") ||
    osg::isGLExtensionSupported(contextID,
     "GL_EXT_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,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [EMAIL PROTECTED]
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to