Jump to content
  • Advertisement
Sign in to follow this  
helpmenow

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.



if(glXGetProcAddress((GLubyte*)"SomeFunctionName") == NULL)
{
std:cout << "SomeFunctionName" << " Is Not Supported!\n";
}


or


PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC) glXGetProcAddress((GLubyte*)"glGetStringi");
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 this post


Link to post
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 this post


Link to post
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, renderer
string 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 extensions
int[] 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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!