opengl32: Check for valid context in wglGetProcAddress.

This commit is contained in:
Roderick Colenbrander 2012-06-24 22:42:11 -07:00 committed by Alexandre Julliard
parent c754f28f17
commit c9962bbb58
2 changed files with 11 additions and 2 deletions

View File

@ -797,7 +797,7 @@ static void test_getprocaddress(HDC hdc)
/* Temporarily disable the context, so we can see that we can't retrieve functions now. */
wglMakeCurrent(hdc, NULL);
func = wglGetProcAddress("glActiveTextureARB");
todo_wine ok(func == NULL, "Function lookup without a context passed, expected a failure; last error %#x\n", GetLastError());
ok(func == NULL, "Function lookup without a context passed, expected a failure; last error %#x\n", GetLastError());
wglMakeCurrent(hdc, ctx);
}

View File

@ -300,9 +300,18 @@ PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) {
TRACE("(%s)\n", lpszProc);
if(lpszProc == NULL)
if (lpszProc == NULL)
return NULL;
/* Without an active context opengl32 doesn't know to what
* driver it has to dispatch wglGetProcAddress.
*/
if (wglGetCurrentContext() == NULL)
{
WARN("No active WGL context found\n");
return NULL;
}
/* First, look if it's not already defined in the 'standard' OpenGL functions */
if ((local_func = GetProcAddress(opengl32_handle, lpszProc)) != NULL) {
TRACE(" found function in 'standard' OpenGL functions (%p)\n", local_func);