OpenGL glGetIntegerv(GL_NUM_EXTENSIONS, &NumExtension) doesnt work

This topic is 2829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

hello Ive been using Ubuntu Linux for a year now and Ive recently been working on an opengl app. anyways im making an opengl extensions wrapper but glGetIntegerv doesn't seem to be working.

GLint NumExtension = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &NumExtension);
std::cout << "NUM_EXTENSIONS = " << NumExtension << "\n"; // this line prints out "0"

basically im trying to get a list of supported extensions but this function doesn't seem to be doing anything. i cant use glGetStringi(GL_EXTENSIONS, i) if i don't know how Manny there is. which by the way glGetStringi(GL_EXTENSIONS, i) actually works fine. i through an arbitrary number in there and it gave me some function name.

Share on other sites
Are you sure you have an OpenGL 3.0 or later rendering context active? Are you sure there are no errors, implying that you really have zero extensions available?

edit: Err, well, I think I misunderstood your last paragraph for some reason. Apparently everything but querying the number works, so never mind the above. Still, check for errors after each and every function to see if you can narrow it down.

Share on other sites
thanks for the reply. my gpu is a "GeForce 6150SE nForce 430" i don't think it can support openGL3.0 i hope thats not a requirement for this function. as far as which functions causing the problem. those three lines of code have been copied and pasted line for line from my source. i changed the first parameter to some other supported macro and it sent back some value. moreover if i initialize NumExtensions with a number other than 0 and call glGetIntegerv. it wont change the value of NumExtensions. so the function doesn't seem to be doing any thing with my integer.

Share on other sites
Well, the GL_NUM_EXTENSIONS query was added in OpenGL 3.0. If you haven't created a 3.0 compatible rendring context you won't have access to it.

Share on other sites
crap is there any other way of getting that value from OpenGL? if not would it be safe to test if an extension exists by calling glXGetProcAddress and checking if it returns NULL like so.

{
std:cout << "SomeFunctionName" << " Is Not Supported!\n";
}

or

if(glGetStringi == NULL)
{
std:cout << "glGetStringi" << " Is Not Supported!\n";
}

so far the second has worked fine. i just want to know if this is a safe way of checking for Extensions.

Share on other sites
No, it is not safe. The function is only valid if the corresponding extension is reported as being supported, or if you have a sufficiently recent rendering context. Otherwise, the return value is not guaranteed to point to a properly implemented function. It may, for example, return some experimental function.

Share on other sites
so how can i test if an extension is supported?

Share on other sites
Can you check the version using glGetString with GL_VERSION, I use this code below and I get version of 3.3, and the GL_NUM_EXTENSIONS returns a number for me and then I loop through all the extensions. This is C# but the calls to open gl functions are the same.

Also I noticed I use an int[] in my code and you use a pointer to an int, I dunno if that wouild make a difference.

// get version, vendor, rendererstring sVersion = StringUtility.GetStringFromIntPtr(RC.glGetString(GLEnum.GL_VERSION), 1024);string sVendor = StringUtility.GetStringFromIntPtr(RC.glGetString(GLEnum.GL_VENDOR), 1024);string sRenderer = StringUtility.GetStringFromIntPtr(RC.glGetString(GLEnum.GL_RENDERER), 1024);// get supported extensionsint[] ext = new int[1];RC.glGetIntegerv(GLEnum.GL_NUM_EXTENSIONS, ext);for (int i = 0; i < ext[0]; i++)  {    IntPtr cstring = RC.glGetStringi(GLEnum.GL_EXTENSIONS, (uint)i);    string sExtension = StringUtility.GetStringFromIntPtr(cstring, 1024);  }

Share on other sites
Thanks for the reply zmg2b6. but brother bob said i cant get the number of extensions with OpenGL2.0 so i cant use the glGetStringi function because i don't know how Manny times to loop it.

Share on other sites
You can get the extension string with glGetString and GL_EXTENSIONS to get a list of extensions currently supported if you're having a 2.0 rendering context. It will return a space-separated list of all extensions, so search that string.

1. 1
2. 2
Rutin
26
3. 3
4. 4
JoeJ
18
5. 5
gaxio
11

• 14
• 22
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631763
• Total Posts
3002196
×