Jump to content
  • Advertisement
Sign in to follow this  
Xiachunyi

OpenGL Can not Retrieve Extensions

This topic is 4846 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, I currently have a wierd problem of not being able to retrieve what extensions my current GPU supports. The following shows the extensions checker:
bool WGLisExtensionSupported(const char *extension)
{
	const size_t extlen = strlen(extension);
	const char *supported = NULL;

	// Try To Use wglGetExtensionStringARB On Current DC, If Possible
	PROC wglGetExtString = wglGetProcAddress("wglGetExtensionsStringARB");
char buffer[256];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),buffer,256,0);
MessageBox(NULL,buffer,"Error",MB_OK|MB_ICONERROR);

	if(wglGetExtString)
	{
		supported = ((char*(__stdcall*)(HDC))wglGetExtString)(wglGetCurrentDC());

    }

	// If That Failed, Try Standard Opengl Extensions String
	if(supported == NULL)
	{
		supported = (char*)glGetString(GL_EXTENSIONS);
    }
    if(glGetError() == GL_INVALID_OPERATION)
    {
        MessageBox(NULL, "glGetString", "Error", MB_OK);             
    }
	// If That Failed Too, Must Be No Extensions Supported
	if (supported == NULL)
		return false;

	// Begin Examination At Start Of String, Increment By 1 On False Match
	for (const char* p = supported; ; p++)
	{
		// Advance p Up To The Next Possible Match
		p = strstr(p, extension);

		if (p == NULL)
			return false;															// No Match

		// Make Sure That Match Is At The Start Of The String Or That
		// The Previous Char Is A Space, Or Else We Could Accidentally
		// Match "wglFunkywglExtension" With "wglExtension"

		// Also, Make Sure That The Following Character Is Space Or NULL
		// Or Else "wglExtensionTwo" Might Match "wglExtension"
		if ((p==supported || p[-1]==' ') && (p[extlen]=='\0' || p[extlen]==' '))
			return true;															// Match
	}
}

The function will, for my program, always return false. The first returned false returns also, via GetLastError, that my "handle" is invalid. I do not remember "wglGetProcAddress" requiring a handle in the first place... The second return is also false, this is the "glGetString". The error code, GL_INVALID_OPERATION, registers true even though I checked many times over, there is not a single glBegin(). In fact, there is not even a single opengl call before this. This code works in other projects I have and my GPU is 6600 go. This problem is certainly very odd and has me a little on the high-strung end. Anybody have come across this problem before and managed to remedy a solution? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
That may be it Enigma, I moved it so far in front of my code, for multisampling, that it most likely would have been called before obtaining the rendering context. I will spend later tonight looking at it.

Glee looks to be very promising to offer. I am only utilizing the multisampling extension but I will look more into it.

Thank you.

Share this post


Link to post
Share on other sites
Quote:
Original post by Xiachunyi
That may be it Enigma, I moved it so far in front of my code, for multisampling, that it most likely would have been called before obtaining the rendering context. I will spend later tonight looking at it.

Glee looks to be very promising to offer. I am only utilizing the multisampling extension but I will look more into it.
When using multisampling, you have to first create a window without multisampling, in order to get a valid rendering context, and then destroy the window and create a new one with multisampling.

Share this post


Link to post
Share on other sites
Quote:
Original post by Myopic Rhino
When using multisampling, you have to first create a window without multisampling, in order to get a valid rendering context, and then destroy the window and create a new one with multisampling.


Thank you for the input Myopic Rhino. I was trying to circumvent having to destroy my window and re-starting it in order for Multisampling to take place by moving the extension routine behind what was needed.

I guess I will have to do that.

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!