From c1240effe3e4a109dd66cb0fa0c84cbfccfbb45d Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 28 Apr 2022 14:05:38 +0100 Subject: [PATCH] Test alternative functions for binding contexts on GL --- util/test/demos/gl/gl_parameter_zoo.cpp | 3 +++ util/test/demos/gl/gl_test.h | 2 +- util/test/demos/gl/gl_test_linux.cpp | 14 ++++++++++---- util/test/demos/gl/gl_test_win32.cpp | 12 +++++++++--- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/util/test/demos/gl/gl_parameter_zoo.cpp b/util/test/demos/gl/gl_parameter_zoo.cpp index 4ff63460a..24da665d4 100644 --- a/util/test/demos/gl/gl_parameter_zoo.cpp +++ b/util/test/demos/gl/gl_parameter_zoo.cpp @@ -181,6 +181,9 @@ void main() } #endif + ActivateContext(NULL, NULL); + ActivateContext(mainWindow, mainContext, true); + while(Running()) { // trash the texture pack/unpack state diff --git a/util/test/demos/gl/gl_test.h b/util/test/demos/gl/gl_test.h index 476367dfe..d2172e3a0 100644 --- a/util/test/demos/gl/gl_test.h +++ b/util/test/demos/gl/gl_test.h @@ -40,7 +40,7 @@ struct OpenGLGraphicsTest : public GraphicsTest GraphicsWindow *MakeWindow(int width, int height, const char *title); void *MakeContext(GraphicsWindow *win, void *share); void DestroyContext(void *ctx); - void ActivateContext(GraphicsWindow *win, void *ctx); + void ActivateContext(GraphicsWindow *win, void *ctx, bool alt = false); void PostInit(); diff --git a/util/test/demos/gl/gl_test_linux.cpp b/util/test/demos/gl/gl_test_linux.cpp index d55dc78ad..6c2880b63 100644 --- a/util/test/demos/gl/gl_test_linux.cpp +++ b/util/test/demos/gl/gl_test_linux.cpp @@ -224,18 +224,24 @@ void OpenGLGraphicsTest::DestroyContext(void *ctx) glXDestroyContext(x11win->xlib.display, (GLXContext)ctx); } -void OpenGLGraphicsTest::ActivateContext(GraphicsWindow *win, void *ctx) +void OpenGLGraphicsTest::ActivateContext(GraphicsWindow *win, void *ctx, bool alt) { X11Window *x11win = (X11Window *)win; if(ctx == NULL) { - glXMakeContextCurrent(x11win->xlib.display, (GLXDrawable)NULL, (GLXDrawable)NULL, NULL); + if(glXMakeCurrent && alt) + glXMakeCurrent(x11win->xlib.display, (GLXDrawable)NULL, NULL); + else + glXMakeContextCurrent(x11win->xlib.display, (GLXDrawable)NULL, (GLXDrawable)NULL, NULL); return; } - glXMakeContextCurrent(x11win->xlib.display, x11win->xlib.window, x11win->xlib.window, - (GLXContext)ctx); + if(glXMakeCurrent && alt) + glXMakeCurrent(x11win->xlib.display, x11win->xlib.window, (GLXContext)ctx); + else + glXMakeContextCurrent(x11win->xlib.display, x11win->xlib.window, x11win->xlib.window, + (GLXContext)ctx); } void OpenGLGraphicsTest::Present(GraphicsWindow *window) diff --git a/util/test/demos/gl/gl_test_win32.cpp b/util/test/demos/gl/gl_test_win32.cpp index 98ffc46b9..a0a9fb169 100644 --- a/util/test/demos/gl/gl_test_win32.cpp +++ b/util/test/demos/gl/gl_test_win32.cpp @@ -258,11 +258,14 @@ void OpenGLGraphicsTest::DestroyContext(void *ctx) deleteContext((HGLRC)ctx); } -void OpenGLGraphicsTest::ActivateContext(GraphicsWindow *win, void *ctx) +void OpenGLGraphicsTest::ActivateContext(GraphicsWindow *win, void *ctx, bool alt) { if(ctx == NULL) { - makeCurrent(NULL, NULL); + if(alt && wglMakeContextCurrentARB) + wglMakeContextCurrentARB(NULL, NULL, NULL); + else + makeCurrent(NULL, NULL); return; } @@ -270,7 +273,10 @@ void OpenGLGraphicsTest::ActivateContext(GraphicsWindow *win, void *ctx) HDC dc = GetDC(win32win->wnd); - makeCurrent(dc, (HGLRC)ctx); + if(alt && wglMakeContextCurrentARB) + wglMakeContextCurrentARB(dc, dc, (HGLRC)ctx); + else + makeCurrent(dc, (HGLRC)ctx); ReleaseDC(win32win->wnd, dc); }