From 0973e810eb59f50c19a228df72a4e652c2a819f0 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Tue, 19 Dec 2023 21:37:47 +0300 Subject: [PATCH] Changed GL context creation a bit --- src/DivaGL/inject.cpp | 22 +++++++++++++--------- src/DivaGL/wrap.cpp | 8 -------- src/DivaGL/wrap.hpp | 4 ---- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/DivaGL/inject.cpp b/src/DivaGL/inject.cpp index d957cc1..c44ea63 100644 --- a/src/DivaGL/inject.cpp +++ b/src/DivaGL/inject.cpp @@ -92,21 +92,25 @@ static HGLRC FASTCALL glut_create_context(int64_t a1, int64_t a2, int64_t a3, in wrap_addresses(); if (true/*a5*/) { - const int32_t attrib_list[] = { - WGL_CONTEXT_MAJOR_VERSION_ARB, 4, - WGL_CONTEXT_MINOR_VERSION_ARB, 3, - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, - 0, - }; - typedef HGLRC(GLAPIENTRY* PFNWGLCREATECONTEXTGLUTPROC)(HDC hDc); HGLRC tmp_ctx = wglCreateContextGLUT(hDc);; wglMakeCurrentGLUT(hDc, tmp_ctx); PFNWGLCREATECONTEXTATTRIBSARBPROC _wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddressGLUT("wglCreateContextAttribsARB"); - HGLRC ctx = _wglCreateContextAttribsARB(hDc, 0, attrib_list); + + int32_t minor = 6; + HGLRC ctx = 0; + while (!ctx || minor < 3) { + const int32_t attrib_list[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, 4, + WGL_CONTEXT_MINOR_VERSION_ARB, minor, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, + 0, + }; + ctx = _wglCreateContextAttribsARB(hDc, 0, attrib_list);; + } wglMakeCurrentGLUT(hDc, ctx); wglDeleteContextGLUT(tmp_ctx); return ctx; diff --git a/src/DivaGL/wrap.cpp b/src/DivaGL/wrap.cpp index f9ab7ef..ccfcd8e 100644 --- a/src/DivaGL/wrap.cpp +++ b/src/DivaGL/wrap.cpp @@ -1583,10 +1583,6 @@ gl_func_struct gl_addr_glut[7] = { { 0x000000000002A430, 0, }, // wglMakeCurrent }; -bool GL_VERSION_3_3 = false; -bool GL_VERSION_4_0 = false; -bool GL_VERSION_4_1 = false; -bool GL_VERSION_4_2 = false; bool GL_VERSION_4_3 = false; bool GL_VERSION_4_4 = false; bool GL_VERSION_4_5 = false; @@ -1666,10 +1662,6 @@ void wrap_addresses() { int32_t minor; sscanf_s(version, "%d.%d", &major, &minor); - GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3; - GL_VERSION_4_0 = (major == 4 && minor >= 0) || major > 4; - GL_VERSION_4_1 = (major == 4 && minor >= 1) || major > 4; - GL_VERSION_4_2 = (major == 4 && minor >= 2) || major > 4; GL_VERSION_4_3 = (major == 4 && minor >= 3) || major > 4; GL_VERSION_4_4 = (major == 4 && minor >= 4) || major > 4; GL_VERSION_4_5 = (major == 4 && minor >= 5) || major > 4; diff --git a/src/DivaGL/wrap.hpp b/src/DivaGL/wrap.hpp index e192b2f..5990440 100644 --- a/src/DivaGL/wrap.hpp +++ b/src/DivaGL/wrap.hpp @@ -3245,10 +3245,6 @@ extern gl_func_struct gl_addr_glut[7]; #define wglGetProcAddressGLUT ((PFNWGLGETPROCADDRESSGLUTPROC)gl_addr_glut[WGLGETPROCADDRESSGLUT].func) #define wglMakeCurrentGLUT ((PFNWGLMAKECURRENTGLUTPROC)gl_addr_glut[WGLMAKECURRENTGLUT].func) -extern bool GL_VERSION_3_3; -extern bool GL_VERSION_4_0; -extern bool GL_VERSION_4_1; -extern bool GL_VERSION_4_2; extern bool GL_VERSION_4_3; extern bool GL_VERSION_4_4; extern bool GL_VERSION_4_5;