win32: Flush message queue between driver changes.

This commit is contained in:
BearOso 2023-02-22 19:14:05 -06:00
parent d8584b9d94
commit 1d0dab45da
2 changed files with 20 additions and 8 deletions

View File

@ -104,7 +104,7 @@ bool COpenGL::Initialize(HWND hWnd)
LoadPBOFunctions();
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress( "wglSwapIntervalEXT" );
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_BLEND);
@ -113,7 +113,7 @@ bool COpenGL::Initialize(HWND hWnd)
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0.0, 1.0, 0.0, 1.0, -1, 1);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
@ -147,7 +147,11 @@ void COpenGL::DeInitialize()
wglDeleteContext(hRC);
hRC = NULL;
}
hDC = NULL;
if (hDC)
{
ReleaseDC(hWnd, hDC);
hDC = NULL;
}
hWnd = NULL;
afterRenderWidth = 0;
afterRenderHeight = 0;
@ -446,7 +450,7 @@ bool COpenGL::SetFullscreen(bool fullscreen)
ChangeDisplaySettings(NULL,0);
}
return true;
}
@ -510,7 +514,7 @@ bool COpenGL::LoadPBOFunctions()
if(glGenBuffers && glBindBuffer && glBufferData && glDeleteBuffers && glMapBuffer) {
pboFunctionsLoaded = true;
}
}
return pboFunctionsLoaded;
}

View File

@ -98,6 +98,15 @@ void WinChangeWindowSize(unsigned int newWidth, unsigned int newHeight)
S9xDisplayOutput->ChangeRenderSize(newWidth,newHeight);
}
static void FlushMessageQueue()
{
for (MSG msg; PeekMessage(&msg, GUI.hWnd, 0, 0, PM_NOREMOVE);)
{
GetMessage(&msg, GUI.hWnd, 0, 0);
DispatchMessage(&msg);
}
}
/* WinDisplayReset
initializes the currently selected display output and
reinitializes the core graphics rendering
@ -107,8 +116,7 @@ returns true if successful, false otherwise
bool WinDisplayReset(void)
{
S9xDisplayOutput->DeInitialize();
if (S9xDisplayOutput == (IS9xDisplayOutput *)&VulkanDriver && GUI.outputMethod == OPENGL)
Sleep(500);
FlushMessageQueue();
switch(GUI.outputMethod) {
default:
@ -238,7 +246,7 @@ bool8 S9xInitUpdate (void)
bool8 S9xContinueUpdate(int Width, int Height)
{
// called every other frame during interlace
Src.Width = Width;
if(Height%SNES_HEIGHT)
Src.Height = Height;