mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-13 09:15:36 +00:00
Add support for wglMakeContextCurrentARB. Closes #2498
This commit is contained in:
@@ -41,6 +41,7 @@ typedef HDC(WINAPI *PFN_wglGetCurrentDC)();
|
||||
|
||||
// wgl extensions
|
||||
typedef PFNWGLCREATECONTEXTATTRIBSARBPROC PFN_wglCreateContextAttribsARB;
|
||||
typedef PFNWGLMAKECONTEXTCURRENTARBPROC PFN_wglMakeContextCurrentARB;
|
||||
typedef PFNWGLGETPIXELFORMATATTRIBIVARBPROC PFN_wglGetPixelFormatAttribivARB;
|
||||
typedef PFNWGLGETEXTENSIONSSTRINGEXTPROC PFN_wglGetExtensionsStringEXT;
|
||||
typedef PFNWGLGETEXTENSIONSSTRINGARBPROC PFN_wglGetExtensionsStringARB;
|
||||
@@ -75,6 +76,7 @@ typedef LONG(WINAPI *PFN_ChangeDisplaySettingsExW)(LPCWSTR, DEVMODEW *, HWND, DW
|
||||
FUNC("opengl32.dll", wglSwapLayerBuffers); \
|
||||
FUNC("opengl32.dll", wglSwapMultipleBuffers); \
|
||||
FUNC("", wglCreateContextAttribsARB); \
|
||||
FUNC("", wglMakeContextCurrentARB); \
|
||||
FUNC("gdi32.dll", SwapBuffers); \
|
||||
FUNC("user32.dll", ChangeDisplaySettingsA); \
|
||||
FUNC("user32.dll", ChangeDisplaySettingsW); \
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
|
||||
void RefreshWindowParameters(const GLWindowingData &data);
|
||||
void ProcessSwapBuffers(GLChunk src, HDC dc);
|
||||
void ProcessContextActivate(HGLRC rc, HDC dc);
|
||||
void PopulateFromContext(HDC dc, HGLRC rc);
|
||||
GLInitParams GetInitParamsForDC(HDC dc);
|
||||
} wglhook;
|
||||
@@ -83,6 +84,10 @@ void WGLHook::PopulateFromContext(HDC dc, HGLRC rc)
|
||||
WGL.wglCreateContextAttribsARB =
|
||||
(PFN_wglCreateContextAttribsARB)WGL.wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
|
||||
if(!WGL.wglMakeContextCurrentARB)
|
||||
WGL.wglMakeContextCurrentARB =
|
||||
(PFN_wglMakeContextCurrentARB)WGL.wglGetProcAddress("wglMakeContextCurrentARB");
|
||||
|
||||
if(!WGL.wglGetPixelFormatAttribivARB)
|
||||
WGL.wglGetPixelFormatAttribivARB =
|
||||
(PFN_wglGetPixelFormatAttribivARB)WGL.wglGetProcAddress("wglGetPixelFormatAttribivARB");
|
||||
@@ -198,6 +203,35 @@ void WGLHook::ProcessSwapBuffers(GLChunk src, HDC dc)
|
||||
}
|
||||
}
|
||||
|
||||
void WGLHook::ProcessContextActivate(HGLRC rc, HDC dc)
|
||||
{
|
||||
SCOPED_LOCK(glLock);
|
||||
|
||||
SetDriverForHooks(&driver);
|
||||
|
||||
if(rc && contexts.find(rc) == contexts.end())
|
||||
{
|
||||
contexts.insert(rc);
|
||||
|
||||
FetchEnabledExtensions();
|
||||
|
||||
// see gl_emulated.cpp
|
||||
GL.EmulateUnsupportedFunctions();
|
||||
GL.EmulateRequiredExtensions();
|
||||
GL.DriverForEmulation(&driver);
|
||||
}
|
||||
|
||||
GLWindowingData data;
|
||||
data.DC = dc;
|
||||
data.wnd = WindowFromDC(dc);
|
||||
data.ctx = rc;
|
||||
|
||||
RefreshWindowParameters(data);
|
||||
|
||||
if(haveContextCreation)
|
||||
driver.ActivateContext(data);
|
||||
}
|
||||
|
||||
static HGLRC WINAPI wglCreateContext_hooked(HDC dc)
|
||||
{
|
||||
SCOPED_LOCK(glLock);
|
||||
@@ -422,31 +456,25 @@ static BOOL WINAPI wglMakeCurrent_hooked(HDC dc, HGLRC rc)
|
||||
|
||||
if(ret && !wglhook.eglDisabled)
|
||||
{
|
||||
SCOPED_LOCK(glLock);
|
||||
wglhook.ProcessContextActivate(rc, dc);
|
||||
}
|
||||
|
||||
SetDriverForHooks(&wglhook.driver);
|
||||
SetLastError(err);
|
||||
|
||||
if(rc && wglhook.contexts.find(rc) == wglhook.contexts.end())
|
||||
{
|
||||
wglhook.contexts.insert(rc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
FetchEnabledExtensions();
|
||||
static BOOL WINAPI wglMakeContextCurrentARB_hooked(HDC drawDC, HDC readDC, HGLRC rc)
|
||||
{
|
||||
SCOPED_LOCK(glLock);
|
||||
|
||||
// see gl_emulated.cpp
|
||||
GL.EmulateUnsupportedFunctions();
|
||||
GL.EmulateRequiredExtensions();
|
||||
GL.DriverForEmulation(&wglhook.driver);
|
||||
}
|
||||
BOOL ret = WGL.wglMakeContextCurrentARB(drawDC, readDC, rc);
|
||||
|
||||
GLWindowingData data;
|
||||
data.DC = dc;
|
||||
data.wnd = WindowFromDC(dc);
|
||||
data.ctx = rc;
|
||||
DWORD err = GetLastError();
|
||||
|
||||
wglhook.RefreshWindowParameters(data);
|
||||
|
||||
if(wglhook.haveContextCreation)
|
||||
wglhook.driver.ActivateContext(data);
|
||||
if(ret && !wglhook.eglDisabled)
|
||||
{
|
||||
wglhook.ProcessContextActivate(rc, drawDC);
|
||||
}
|
||||
|
||||
SetLastError(err);
|
||||
@@ -583,6 +611,8 @@ static PROC WINAPI wglGetProcAddress_hooked(const char *func)
|
||||
return (PROC)&wglCreateLayerContext_hooked;
|
||||
if(!strcmp(func, "wglCreateContextAttribsARB"))
|
||||
return (PROC)&wglCreateContextAttribsARB_hooked;
|
||||
if(!strcmp(func, "wglMakeContextCurrentARB"))
|
||||
return (PROC)&wglMakeContextCurrentARB_hooked;
|
||||
if(!strcmp(func, "wglMakeCurrent"))
|
||||
return (PROC)&wglMakeCurrent_hooked;
|
||||
if(!strcmp(func, "wglSwapBuffers"))
|
||||
|
||||
Reference in New Issue
Block a user