From f67681c4c40d7cc41a9b36a20e2d7a7ee92477e1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 5 Aug 2015 18:52:17 +0200 Subject: [PATCH] Don't do anything in SwapBuffers if no GL context is active --- renderdoc/driver/gl/gl_common.h | 4 ++++ renderdoc/driver/gl/gl_driver.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index bd66acb77..81c028216 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -38,6 +38,8 @@ struct GLWindowingData { + GLWindowingData() { DC = NULL; ctx = NULL; wnd = NULL; } + void SetCtx(void *c) { ctx = (HGLRC)c; } HDC DC; HGLRC ctx; @@ -54,6 +56,8 @@ struct GLWindowingData struct GLWindowingData { + GLWindowingData() { dpy = NULL; ctx = NULL; wnd = NULL; } + void SetCtx(void *c) { ctx = (GLXContext)c; } Display *dpy; GLXContext ctx; diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index e081aaa83..44a675dd0 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -1967,6 +1967,10 @@ void WrappedOpenGL::SwapBuffers(void *windowHandle) { if(m_State == WRITING_IDLE) RenderDoc::Inst().Tick(); + + // don't do anything if no context is active. + if(GetCtx() == NULL) + return; m_FrameCounter++; // first present becomes frame #1, this function is at the end of the frame