Call ogl ext functions but return null?

I called an ogl ext function(that func can be supported in opengl1.2) in a win32 console application program(vc2003.net),but I was notified that pointer(glTexImage3D) to the function returns null, why?
I call the funcproc in this way…
#include “windows.h”
#include “gl.h”
#include “glu.h”


#ifdef _WIN32
typedef void(APIENTRY* PFNGLTEXIMAGE3DEXTPROC)(GLenum target, Glint level,…);
#endif

#ifdef _WIN32
PFNGLTEXIMAGE3DEXTPROC glTexImage3D=(PFNGLTEXIMAGE3DEXTPROC) wglGetProcAddress(glTexImage3D);
#endif

can someone help me? thanks…

wglGetProcAddress wants a string as argument.
You are passing the pointer you want to get filled, which initially, at best, is NULL.
So this should do it:

PFNGLTEXIMAGE3DEXTPROC glTexImage3D=(PFNGLTEXIMAGE3DEXTPROC) wglGetProcAddress(“glTexImage3D”);

sorry, i made a mistake…
I do have used wglGetProcAddress(“glTexImage3D”);
but…
I am puzzled…

Did you set up your OpenGL context before trying to get the extension function pointer?
There must be a valid active OpenGL context. Otherwise wglGetProcAddress fails.
A very common mistake…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.