OpenGL 3: How to find deprecated functions ?

Hi,
i have made a program which work using OpenGL 2.x.

Now i have created an OpenGL 3.1 rendering context.
I think i have removed all deprecated functions.
glClear works (my screen is blue) but my mesh is not displayed.
When i comment the OpenGL 3.1 rendering context creation, it works.

How can i find the source of the problem ? Which function is deprecated ? Is there a debug mode like in DirectX to display warning (exampel: “warning: glBegin() deprecated”,…)

Thanks.

I think that if you create a OpenGL 3.1 forward compatible context / core profile, you should get OpenGL errors if you use any function that is deprecated. So make sure you use a forward compatible context and core profile. Thereafter check if any errors occur.

Yes, but it is a tedious business. Doing that way, you should call glGetError() after any suspicious GL command.

The best solution is to use gDEBugger. gDEBugger does the same thing, but without need to change the code. Further more, it would suggest that some functions are deprecated according to its inner database. It is not always true, but in most of the cases works perfectly. The problem can be caused by some new extensions (e.g. Bindless Graphics) that use some “deprecated” functions but with parameters that are essential for the functionality. If gDEBugger does not recognize the parameter, just ignore the warning.

The second solution is to search the spec for the deprecated functions. Or even better, check quick reference pdf. This is the hard stuff, because you have to check both functions and parameters. For example, only few moths ago I have realized that glPolygonMode() considers GL_FRONT and GL_BACK deprecated, but GL_FRONT_AND_BACK not! Checking in the Red book confirmed that.

Oh, yes, the Red book (7th Ed.) is the third source. :slight_smile:

What about just including the gl3.h header, which only contains non-deprecated stuff ?
http://www.opengl.org/registry/api/gl3.h
See also here for details about this gl3.h file :
http://www.opengl.org/registry/

I have already read the OpenGL 3.1 specs. I think i have checked all functions but it’s not easy.

I use GLEW, i will try to use gl3.h instead.
Do you know if there is an option to remove deprecated stuff in GLEW (i haven’t found) ?

Is there something like gDEBugger, but free ?

bugle http://sourceforge.net/projects/bugle/
glIntercept http://glintercept.nutty.org/ (looks like it is not developed any more?)

IIRC they both can check every GL call, so their logs would show you the equivalent of calling glError() after each operation.

But does this debuggers can detect deprecated functions/problems ?

“so their logs would show you the equivalent of calling glError() after each operation”

And simply use gl3.h :slight_smile:

Including just the functions that are valid by using gl3.h (or equivalent) helps a lot, but doesn’t help for functions + constants that are still there, but not usable together in certain combinations or under certain conditions.

If you look at the quick reference guides (eg. http://www.khronos.org/files/opengl4-quick-reference-card.pdf for OpenGL 4), it can also help understand which values are no longer allowed in function calls.

You’ll also need to look at the appendices of OpenGL spec to see the deprecated behaviours, such as calling glVertexAttribPointer with no buffer object or VAO bound is now an error in core profile (although NVidia drivers don’t throw this error when no VAO is bound).

I have tried PerfStudio 2 version 2.2.791 (ATI).
i have this error in the server log:
OGLWrapper: Cannot make context current; it does not exist (we probably missed the createcontext call)
MakeCurrent failed on hGLRC: 0x00010001

Maybe my OpenGL 3.1 context creation is bad ?


// Create a window compatible with OpenGL 1.1
	if(!mainGLWindow.Create("GLAn8Viewer",640,480,32,false,WS_OVERLAPPEDWINDOW,WndProc))
	{
		MessageBox(NULL,"Can't create the window.","ERROR",MB_OK|MB_ICONEXCLAMATION);
		return 0;
	}

	GLenum err = glewInit();
	if (GLEW_OK != err)
	{
		char buffer[2048];
		sprintf(buffer,"%s",glewGetErrorString(err));
		MessageBox(NULL,buffer,"ERROR",MB_OK|MB_ICONEXCLAMATION);
	}

int useGL3 = MessageBox(mainGLWindow.hWnd,"Do you want to use OpenGL 3.1 core ?","Information",MB_YESNO |MB_ICONEXCLAMATION);
	if( WGL_ARB_create_context && useGL3 == 6 )
	{
		HGLRC     hRC;
		int attribList[] =
		{
			WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
			WGL_CONTEXT_MINOR_VERSION_ARB, 1,
			WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
			0, 0
		};

		// Try OpenGL 3.1
		if (!(hRC = wglCreateContextAttribsARB(mainGLWindow.hDC, 0, attribList)))
		{
			MessageBox(NULL,"OpenGL 3.1 context is not supported by your system.
An OpenGL 3.0 context will be tried to be created instead.","Information",MB_OK|MB_ICONEXCLAMATION);

			// Try OpenGL 3.0
			attribList[3] = 0;
			if (!(hRC = wglCreateContextAttribsARB(mainGLWindow.hDC, 0, attribList)))
				MessageBox(NULL,"OpenGL 3.0 context is not supported by your system.
An OpenGL 2.x context will be used instead.","Information",MB_OK|MB_ICONEXCLAMATION);
			else
				SetWindowText(mainGLWindow.hWnd,"GLAn8Viewer - Using OpenGL 3.0");
		}
		else
		{
			SetWindowText(mainGLWindow.hWnd,"GLAn8Viewer - Using OpenGL 3.1");
		}

		if (!wglMakeCurrent(mainGLWindow.hDC, hRC))
			MessageBox(NULL,"wglMakeCurrent() failed for OpenGL 3.x context.","Information",MB_OK|MB_ICONEXCLAMATION);
	
		wglDeleteContext(mainGLWindow.hRC);
		mainGLWindow.hRC = hRC;
	}
	else
	{
		SetWindowText(mainGLWindow.hWnd,"GLAn8Viewer - Using OpenGL 2");
	}