But whenever I try to do this the compiler returns to me saying that there are too many actual parameters to the function, and that the function is prototyped as SomeFunction(void).
Why is this, and how do I go about doing this the right way?
But whenever I look at MSDN documentation about various API extensions (not OpenGL - Win32 API), they simply declare a pointer of type FARPROC and then get the address and assign it to that variable. Then, every subsequent call they make includes parameters and there is no prototype for the function.
You’ve not seen that at all, liar!
You can only call a function with the parameters declared in it’s prototype.
A function pointer should be of a certain type - that type is one that you create (or include from a header file).
I thought this would be a good post to jump in on. I’m using wglGetProcAddress for the first time in order to use glTexImage3D. I can get the address fine, but then I have another problem. Compiling in VC++6 gives me the error GL_TEXTURE_3D undeclared identifier, and the same for GL_TEXTURE_WRAP_R.
Where can I find these enums? Or do I have to define them myself from the OpenGL 1.2 specs values?
DFrey: AFAIK my code is alright. Here’s a snippet:
code: #ifdef _WIN32
// Prepare a function pointer to hold the glTexImage3D pointer.
typedef void (*PFNglTexImage3D) (GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type,
const GLvoid *texels);
// Call wglGetProcAddress to get a pointer to the function.
PFNglTexImage3D glTexImage3D = (PFNglTexImage3D) wglGetProcAddress("glTexImage3D");
assert(glTexImage3D != 0);
But with regard to your problem, yes, you need to define those enumerants. You can get the latest gl header from SGI that includes those definitions. I can’t remember the url to the relevant link, but I know NVIDIA has it posted on the dev site.
Secondly, as for the reson why it doesn’t compile is because it isn’t legal C++ syntax. If it were a simple C application, using the aforementioned method would work just fine. In case you’re wondering, the answer as to why (which I was looking for) this wasn’t working is here: http://support.microsoft.com/support/kb/articles/Q117/4/28.asp
The above link states the typing conventions for GetProcAddress and FARPROC, and why that code works in C and not in C++.
Interesting. Learn something new all the time. It has been a long time since I’ve worked with pure C, but I never knew that about the empty parenthesis before.