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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to