wglGetProcAddress

#1

Hi

I am trying to use:
wglGetProcAddress

in Windows 8.1

The errors I am getting are:
error C2100: illegal indirection
error C2064: term does not evaluate to a function taking 339 arguments

I have no idea how to use this windows function



GLuint triangleVBO;

	void *vPointer;
	
	vPointer = GetAnyGLFuncAddress("glGenBuffers");
	(*vPointer)(1, &triangleVBO);

where


void *GetAnyGLFuncAddress(const char *name)
{
	void *p = (void *)wglGetProcAddress(name);
	if (p == 0 ||
		(p == (void*)0x1) || (p == (void*)0x2) || (p == (void*)0x3) ||
		(p == (void*)-1))
	{
		HMODULE module = LoadLibraryA("opengl32.dll");
		p = (void *)GetProcAddress(module, name);
	}

	return p;
}

Any help gratefully appreciated.

MacSam

#2

This never threw up any errors


GLuint triangleVBO;
    
PFNGLGENBUFFERSPROC vPointer = GetAnyGLFuncAddress("glGenBuffers");
    
(vPointer)( 1, &triangleVBO);

Am I on the right road?

#3

Looks like it, yes.

You should need a (PFNGLGENBUFFERSPROC) cast to convert the void * returned from GetAnyGLFuncAddress() though. See the example here for instance:

Load OpenGL Functions#Function Retrieval