Preferred method for determining extension support (WIN32)...

All,

What is your opinion on the best practice for determining if an extension is supported on a particular ICD? Currently, I’m using the glGetString(GL_EXTENSIONS) method. But, after using that for a bit, I noticed that it may be easier to just test if the function was returned a null pointer after wglGetProcAddress().

Can anyone speak of the benefit of user either technique? Though the latter appears more straightforward, the former provides more information.

Thoughts?

Glossifah

I always use the extension string which is the official way to do it.

I have read (quite recently) that you may obtain non-null pointers (i.e. the function is present) even though the extension is not specified in the string: it was then said that it could mean that a very beta version of the extension is actually in the driver. Its beta status prevents it from being in the string and it could actually be a bad idea to use it…

I agree with you that trying directly wglGetProcAddress seems simpler but I think we should all stick to the official way…

Regards.

Eric

I personally use this piece of code, first of all coz it’s fully portable, another reason is oz if you are writing a multiapi engine you should play a bit with pinters and using 'em to check extensions availability is not so good (IMHO).

char* extensions;

int cEngine::SomethingHere(bool checkmodes)
{

//controllo le estensioni e i modi video
if (checkmodes)
{
	extensions = (char*)glGetString(GL_EXTENSIONS);
}

}

bool cEngine::IsExtensionAvailable(char *extname)
{
return (strstr((const char *)extensions, (const char *)extname)!= NULL);
}

Using strstr is not the best way of going about testing for a particular extension name in the string. It is conceivable that one extension name could coincide with the substring of another. Then your app might see the substring in the longer string when looking for the shorter one, even if the shorter one is not present. It is best to use strtok and parse the extension string and do multiple compares. You can of course use strstr to reduce the number of compares needed.

I use glutExtensionSupported.

It is a bug if wglGetProcAddress returns anything other than NULL for an unsupported extension, but it is a bug that is (1) quite possible and probably common and (2) difficult for us to check for.

Some extensions also don’t expose new entry points at all.

  • Matt

glutExtensionSupported?
I can’t find it…
What are it’s parameters?

http://reality.sgi.com/mjk/spec3/node74.html#SECTION000105000000000000000

Regards,

Glossifah