PDA

View Full Version : gl Extensions, again



FurnaceMan
03-06-2003, 12:56 PM
I am still having trouble with installing the glDrawRangeElements function in MS VC++6. So far, I have:

1. ensured that I have gl version 1.2
2. added the glext.h header file to my project
3. put

PFNGLDRAWRANGEELEMENTSEXTPROC glDrawRangeElementsEXT;

in the declaration section of my C file

4. I put

glDrawRangeElementsEXT =
(PFNGLDRAWRANGEELEMENTSEXTPROC) wglGetProcAddress("glDrawRangeElementsEXT");

in my main(). If I put this statement in the declaration section, I get a "intialize not a constant" error. Apparently, VC++6 thinks I'm trying to declare a constant with the assignment statement.

5. With all that above, the program compiles and links but then bombs out at runtime with a NULL pointer error. Apparently, the wglGetProcAddress function did not return the correct function pointer to glDrawRangeElementsEXT.

6. i have also reloaded my opengl32.dll file to make sure its not corrupted.

I am out of ideas. i would like to find someone I could email my code to so they could take alook. Someone experienced would
probably see the error quickly.

shinpaughp
03-06-2003, 01:15 PM
I'll take a look at it. But, have you set up your OpenGL context prior to using wglGetProcAddress?

shinpaughp
03-06-2003, 02:05 PM
Also, the name you declare as the function pointer as glDrawRangeElementsEXT could also be glDrawRangeElements or func1 or anything.

PFNGLDRAWRANGEELEMENTSEXTPROC glDrawRangeElements;

but the string you pass to wglGetProcAddress should be "glDrawRangeElementsEXT" as you have it.

glDrawRangeElements =
(PFNGLDRAWRANGEELEMENTSEXTPROC) wglGetProcAddress("glDrawRangeElementsEXT");

I believe that the string to use for any extension is the substring of the name given to the prototype between PFN and PROC, but spelled as the function except for any addition which should be capitalized such as EXT. I hope that makes sense.

Regardless, call your OpenGL initialization function first (or create it in main), create the context such as
format = ChoosePixelFormat(*hDC, &pfd);
SetPixelFormat(*hDC, format, &pfd);
*hRC = wglCreateContext(*hDC);
wglMakeCurrent(*hDC, *hRC);

and then you can call wglGetProcAddress for any extensions you need within that function or anywhere else in your code after the context is successfully created and the GL context must be current.

[This message has been edited by shinpaughp (edited 03-06-2003).]

FurnaceMan
03-07-2003, 04:47 AM
shinpaughp:

thanks for offering to look at my code. I'm using GLUT and my understanding is that it sets up the rendering context with the
glutCreateWindow function.

I incorporated your suggestions in my code, but i still get the NULL pointer error.

If you could look at it, i appreciate. Code being emailed to you...