Skip to content

Commit

Permalink
Windows Port: Fix bug where the OpenGL 3D renderer would fail to init…
Browse files Browse the repository at this point in the history
…ialize at program startup. (Regression from commit 76fe5f7. Fixes #815.)
  • Loading branch information
rogerman committed Jul 23, 2024
1 parent 8e77a8d commit f323dc4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions desmume/src/frontend/windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions desmume/src/frontend/windows/ogl.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -110,7 +110,7 @@ static bool wgl_beginOpenGL()
return true;
}

static void wgl_endOpenGL()
void wgl_endOpenGL()
{
// Do nothing.
}
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 3 additions & 1 deletion desmume/src/frontend/windows/ogl.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,3 +19,5 @@

bool windows_opengl_init();
bool initContext(HWND hwnd, HGLRC *hRC);
bool wgl_beginOpenGL();
void wgl_endOpenGL();

0 comments on commit f323dc4

Please sign in to comment.