From 1f13d9ce80c0cd5e94ba883ff6bb30c95d48a48a Mon Sep 17 00:00:00 2001 From: Arisotura Date: Mon, 1 Apr 2019 04:50:48 +0200 Subject: * move GL init to main thread * fix potential bug causing the screen bitmap to be created twice --- src/libui_sdl/libui/windows/alloc.cpp | 2 +- src/libui_sdl/libui/windows/gl.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/libui_sdl/libui') diff --git a/src/libui_sdl/libui/windows/alloc.cpp b/src/libui_sdl/libui/windows/alloc.cpp index cf6bd2e..e29d60e 100644 --- a/src/libui_sdl/libui/windows/alloc.cpp +++ b/src/libui_sdl/libui/windows/alloc.cpp @@ -32,7 +32,7 @@ void *uiAlloc(size_t size, const char *type) { byteArray *out; - out = new byteArray(size, 0); + out = new byteArray(size, 0);//printf("alloc %s at %08X\n", type, rawBytes(out)); heap[rawBytes(out)] = out; types[out] = type; return rawBytes(out); diff --git a/src/libui_sdl/libui/windows/gl.cpp b/src/libui_sdl/libui/windows/gl.cpp index eb7d33d..beccb79 100644 --- a/src/libui_sdl/libui/windows/gl.cpp +++ b/src/libui_sdl/libui/windows/gl.cpp @@ -120,7 +120,14 @@ void uiGLFreeContext(uiGLContext* ctx) void uiGLMakeContextCurrent(uiGLContext* ctx) { - wglMakeCurrent(ctx->dc, ctx->rc); + if (ctx == NULL) + { + wglMakeCurrent(NULL, NULL); + return; + } + + if (wglGetCurrentContext() == ctx->rc) return; + int res = wglMakeCurrent(ctx->dc, ctx->rc); } void *uiGLGetProcAddress(const char* proc) -- cgit v1.2.3