Fix opengl C backend crashing

This commit is contained in:
UnknownShadow200 2017-09-29 00:28:04 +10:00
parent e614908177
commit 29b4894c78
2 changed files with 7 additions and 2 deletions

View File

@ -12,9 +12,11 @@ int main(int argc, char* argv[]) {
Window_Create(320, 320, 640, 480, &str, NULL);
Window_SetVisible(true);
Gfx_Init();
Gfx_ClearColour(PackedCol_Red);
UInt8 RGB = 0;
while (true) {
Gfx_ClearColour(PackedCol_Create3(RGB, RGB, RGB));
RGB++;
Window_ProcessEvents();
Platform_ThreadSleep(100);
Gfx_BeginFrame();

View File

@ -440,7 +440,6 @@ void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_TRANSIENT
if (atom == 0) {
ErrorHandler_FailWithCode(GetLastError(), "Failed to register window class");
}
win_Handle = CreateWindowExA(
win_StyleEx, atom, title->buffer, win_Style,
rect.left, rect.top, RECT_WIDTH(rect), RECT_HEIGHT(rect),
@ -449,6 +448,10 @@ void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_TRANSIENT
if (win_Handle == NULL) {
ErrorHandler_FailWithCode(GetLastError(), "Failed to create window");
}
win_DC = GetDC(win_Handle);
if (win_DC == NULL) {
ErrorHandler_FailWithCode(GetLastError(), "Failed to get device context");
}
win_Exists = true;
}