Skip to content

Commit

Permalink
making HDC static
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanries committed Dec 2, 2022
1 parent 0cddad4 commit 010487a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions WindowsMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,13 @@ void RenderFrameGraphics(void)
DrawDebugInfo();
}

HDC DeviceContext = GetDC(gGameWindow);
// 12/2/2022: realized there is no need to reacquire this HDC each and every frame, we can just create the DC once, make it static, reuse it.
static HDC DeviceContext = NULL;

if (!DeviceContext)
{
DeviceContext = GetDC(gGameWindow);
}

#ifdef OPENGL
glClear(GL_COLOR_BUFFER_BIT);
Expand Down Expand Up @@ -1277,7 +1283,7 @@ void RenderFrameGraphics(void)

#endif

ReleaseDC(gGameWindow, DeviceContext);
//ReleaseDC(gGameWindow, DeviceContext);
}

void FindFirstConnectedGamepad(void)
Expand Down

0 comments on commit 010487a

Please sign in to comment.