From f323dc464f149ae62bafcd2b73354961c4a64449 Mon Sep 17 00:00:00 2001 From: rogerman Date: Mon, 22 Jul 2024 22:47:29 -0700 Subject: [PATCH] Windows Port: Fix bug where the OpenGL 3D renderer would fail to initialize at program startup. (Regression from commit 76fe5f7. Fixes #815.) --- desmume/src/frontend/windows/main.cpp | 5 +++-- desmume/src/frontend/windows/ogl.cpp | 8 +++----- desmume/src/frontend/windows/ogl.h | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index 796c3349b..659c30ddc 100644 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -1955,8 +1955,9 @@ int _main() // struct configured_features my_config; - oglrender_init = windows_opengl_init; - + oglrender_init = &windows_opengl_init; + oglrender_beginOpenGL = &wgl_beginOpenGL; + oglrender_endOpenGL = &wgl_endOpenGL; //try and detect this for users who don't specify it on the commandline //(can't say I really blame them) diff --git a/desmume/src/frontend/windows/ogl.cpp b/desmume/src/frontend/windows/ogl.cpp index 053ff365d..ddac52958 100644 --- a/desmume/src/frontend/windows/ogl.cpp +++ b/desmume/src/frontend/windows/ogl.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2016 DeSmuME team + Copyright (C) 2006-2024 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -98,7 +98,7 @@ static HGLRC main_hRC; static HDC main_hDC; static HWND main_hWND; -static bool wgl_beginOpenGL() +bool wgl_beginOpenGL() { //wglMakeCurrent is slow in some environments. so, check if the desired context is already current if(wglGetCurrentContext() == main_hRC) @@ -110,7 +110,7 @@ static bool wgl_beginOpenGL() return true; } -static void wgl_endOpenGL() +void wgl_endOpenGL() { // Do nothing. } @@ -232,8 +232,6 @@ bool windows_opengl_init() main_hDC = hdc; main_hRC = hGlRc; oglAlreadyInit = true; - oglrender_beginOpenGL = &wgl_beginOpenGL; - oglrender_endOpenGL = &wgl_endOpenGL; //use the new pbuffer context for further extension interrogation in shared opengl init wgl_beginOpenGL(); diff --git a/desmume/src/frontend/windows/ogl.h b/desmume/src/frontend/windows/ogl.h index 4ed498f83..6241c9dc0 100644 --- a/desmume/src/frontend/windows/ogl.h +++ b/desmume/src/frontend/windows/ogl.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 DeSmuME team + Copyright (C) 2013-2024 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,3 +19,5 @@ bool windows_opengl_init(); bool initContext(HWND hwnd, HGLRC *hRC); +bool wgl_beginOpenGL(); +void wgl_endOpenGL();