PDA

View Full Version : How to initialize GL 1.0 pointers with GL3.h



M/\dm/\n
11-26-2009, 05:16 AM
How are you supposed to get opengl 1.1 function pointers if you use gl3.h?

I want to divide all initialization in functions like so:


int InitGL_1_0()
{
if(!(glCullFace = (PFNGLCULLFACEPROC)wglGetProcAddress("glCullFace"))) return 0;
if(!(glFrontFace = (PFNGLFRONTFACEPROC)wglGetProcAddress("glFrontFace"))) return 0;
if(!(glHint = (PFNGLHINTPROC)wglGetProcAddress("glHint"))) return 0;
if(!(glLineWidth = (PFNGLLINEWIDTHPROC)wglGetProcAddress("glLineWidth"))) return 0;
...


But I get an error that function "glCullFace" cannot be found, how do I get it then?

I don't want to include gl.h, only gl3.h for new prototypes.

overlay
11-26-2009, 10:08 AM
By definition, if you use gl3.h it is because you restrain your code to use the core profile and get rid of the compatibility profile. So what you are asking does not make sense.

If you still want to have access to 1.1 function pointers you need the legacy gl.h.

Ref: section E.1 "Core and Compatibility Profiles" and the beginning of section E.2 "Deprecated and Removed Features" page 329 in "OpenGL 3.2 Core Profile Specification (August 3, 2009)"

Ref: section I.2 "Header Files" of Appendix I "Extension Registry, Header Files, and ARB Extensions" page 352 in "OpenGL 3.2 Core Profile Specification (August 3, 2009)"

http://www.opengl.org/registry/doc/glspec32.core.20090803.pdf

M/\dm/\n
11-26-2009, 12:27 PM
Yup, I am using 3.2, core FW compat, but things like glEnable(GL_CULL_FACE/GL_DEPTH_TEST) are still using glEnable and there are glTexImage1D/glTexImage2D/glHint/glViewport which are non-deprecated 1.0-ish calls...

I guess I could resort to "discard" in fragment shaders for things like cull face or depth test, but I don't want to redo textures or viewports.

I ended up copying all 1.0/1.1 calls from gl.h that are used in GL3.x to my headers, there are 64 of them. Still, a nicer way would be cool.