Index: boot/bootdata/packages/reactos.dff =================================================================== --- boot/bootdata/packages/reactos.dff (révision 46229) +++ boot/bootdata/packages/reactos.dff (copie de travail) @@ -782,6 +782,7 @@ modules\rostests\winetests\odbccp32\odbccp32_winetest.exe 7 optional modules\rostests\winetests\ole32\ole32_winetest.exe 7 optional modules\rostests\winetests\oleaut32\oleaut32_winetest.exe 7 optional +modules\rostests\winetests\opengl32\opengl32_winetest.exe 7 optional modules\rostests\winetests\powrprof\powrprof_winetest.exe 7 optional modules\rostests\winetests\psapi\psapi_winetest.exe 7 optional modules\rostests\winetests\riched20\riched20_winetest.exe 7 optional Index: dll/win32/opengl32/opengl32.h =================================================================== --- dll/win32/opengl32/opengl32.h (révision 46229) +++ dll/win32/opengl32/opengl32.h (copie de travail) @@ -191,6 +191,7 @@ GLDRIVERDATA *OPENGL32_LoadICD( LPCWSTR driver ); BOOL OPENGL32_UnloadICD( GLDRIVERDATA *icd ); BOOL APIENTRY rosglMakeCurrent( HDC hdc, HGLRC hglrc ); +int APIENTRY rosglGetPixelFormat( HDC ); BOOL APIENTRY IntUseFontBitmapsA( HDC hDC, DWORD first, DWORD count, DWORD listBase ); BOOL APIENTRY IntUseFontBitmapsW( HDC hDC, DWORD first, DWORD count, DWORD listBase ); BOOL APIENTRY IntUseFontOutlinesA( HDC hDC, DWORD first, DWORD count, DWORD listBase, Index: dll/win32/opengl32/opengl32.c =================================================================== --- dll/win32/opengl32/opengl32.c (révision 46229) +++ dll/win32/opengl32/opengl32.c (copie de travail) @@ -472,8 +472,6 @@ { if (!_wcsicmp( driver, icd->driver_name )) /* found */ { - icd->refcount++; - /* release mutex */ if (!ReleaseMutex( OPENGL32_processdata.driver_mutex )) DBGPRINT( "Error: ReleaseMutex() failed (%d)", GetLastError() ); @@ -484,8 +482,6 @@ /* not found - try to load */ icd = OPENGL32_LoadDriver( driver ); - if (icd != NULL) - icd->refcount = 1; /* release mutex */ if (!ReleaseMutex( OPENGL32_processdata.driver_mutex )) @@ -513,7 +509,7 @@ return FALSE; /* FIXME: do we have to expect such an error and handle it? */ } - if (--icd->refcount == 0) + if (icd->refcount == 0) ret = OPENGL32_UnloadDriver( icd ); /* release mutex */ Index: dll/win32/opengl32/wgl.c =================================================================== --- dll/win32/opengl32/wgl.c (révision 46229) +++ dll/win32/opengl32/wgl.c (copie de travail) @@ -27,7 +27,6 @@ WCHAR DriverName[256]; /*!< Driver name */ } OPENGL_INFO, *POPENGL_INFO; - /*! \brief Append OpenGL Rendering Context (GLRC) to list * * \param glrc [IN] Pointer to GLRC to append to list @@ -179,8 +178,11 @@ ROSGL_DeleteContext( GLRC *glrc ) { /* unload icd */ - if (glrc->icd != NULL) + if ((glrc->icd != NULL) && (!InterlockedDecrement((LONG*)&glrc->icd->refcount))) + { + /* This is the last context, remove the ICD*/ ROSGL_DeleteDCDataForICD( glrc->icd ); + } /* remove from list */ ROSGL_RemoveContext( glrc ); @@ -269,8 +271,10 @@ data = OPENGL32_processdata.dcdata_list; while (data != NULL) { - if (data->hdc == hdc) /* found */ + if ((data->hdc == hdc) || (WindowFromDC(data->hdc) == WindowFromDC(hdc))) /* found */ + { break; + } data = data->next; } @@ -413,7 +417,7 @@ NULL) != NULL) { /* Too bad, somebody else was faster... */ - OPENGL32_UnloadICD(drvdata); + DBGTRACE("Uh, someone beat you to it!"); } } } @@ -686,6 +690,17 @@ /* FIXME: fallback? */ return NULL; } + /* Don't forget to refcount it, icd will be released when last context is deleted */ + InterlockedIncrement((LONG*)&icd->refcount); + + if(!rosglGetPixelFormat(hdc)) + { + ROSGL_DeleteContext( glrc ); + SetLastError(ERROR_INVALID_PIXEL_FORMAT); + return NULL; + } /* create context */ if (icd->DrvCreateLayerContext != NULL) @@ -989,6 +1004,12 @@ glrc->is_current = FALSE; OPENGL32_threaddata->glrc = NULL; } + else if (GetObjectType( hdc ) != OBJ_DC && GetObjectType( hdc ) != OBJ_MEMDC) + { + DBGPRINT("Current context is NULL, and requested HDC is invalid."); + SetLastError( ERROR_INVALID_HANDLE ); + return FALSE; + } } else { Index: dll/win32/gdi32/misc/wingl.c =================================================================== --- dll/win32/gdi32/misc/wingl.c (révision 46229) +++ dll/win32/gdi32/misc/wingl.c (copie de travail) @@ -166,6 +166,10 @@ INT iPixelFormat, CONST PIXELFORMATDESCRIPTOR * ppfd) { + INT current = GetPixelFormat(hdc); + /*Can only be set once*/ + if(current) return current == iPixelFormat ; + if (glSetPixelFormat == NULL) if (OpenGLEnable() == FALSE) return(0);