From 976420b9d5ac8fce3b3f46678d72df321eba1975 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Fri, 28 Jan 2011 09:39:28 +0000 Subject: [PATCH] Vertical sync on OS X. Fixes issue 3996. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6946 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 6 ++++-- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 8 +++++++- Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 789698ac39..28a0453ea3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -324,8 +324,9 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight GLWin.panel = (wxPanel *)g_VideoInitialize.pWindowHandle; GLWin.glCanvas = new wxGLCanvas(GLWin.panel, wxID_ANY, NULL, wxPoint(0, 0), wxSize(_twidth, _theight)); - GLWin.glCtxt = new wxGLContext(GLWin.glCanvas); GLWin.glCanvas->Show(true); + if (GLWin.glCtxt == NULL) // XXX dirty hack + GLWin.glCtxt = new wxGLContext(GLWin.glCanvas); #elif defined(__APPLE__) NSOpenGLPixelFormatAttribute attr[2] = { NSOpenGLPFADoubleBuffer, 0 }; @@ -570,7 +571,8 @@ void OpenGL_Shutdown() { #if defined(USE_WX) && USE_WX GLWin.glCanvas->Hide(); - delete GLWin.glCtxt; + // XXX GLWin.glCanvas->Destroy(); + // XXX delete GLWin.glCtxt; #elif defined(__APPLE__) [GLWin.cocoaWin close]; [GLWin.cocoaCtx clearDrawable]; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index f422d5c6de..d293097baf 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -310,8 +310,14 @@ Renderer::Renderer() s_backbuffer_height = (int)OpenGL_GetBackbufferHeight(); // Handle VSync on/off +#ifdef __APPLE__ + int swapInterval = g_ActiveConfig.bVSync ? 1 : 0; #if defined USE_WX && USE_WX - // TODO: FILL IN + NSOpenGLContext *ctx = GLWin.glCtxt->GetWXGLContext(); +#else + NSOpenGLContext *ctx = GLWin.cocoaCtx; +#endif + [ctx setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval]; #elif defined _WIN32 if (WGLEW_EXT_swap_control) wglSwapIntervalEXT(g_ActiveConfig.bVSync ? 1 : 0); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp index d34ac78c16..4a910e92fb 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp @@ -121,8 +121,9 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight GLWin.panel = (wxPanel *)g_VideoInitialize.pWindowHandle; GLWin.glCanvas = new wxGLCanvas(GLWin.panel, wxID_ANY, NULL, wxPoint(0, 0), wxSize(_twidth, _theight)); - GLWin.glCtxt = new wxGLContext(GLWin.glCanvas); GLWin.glCanvas->Show(true); + if (GLWin.glCtxt == NULL) // XXX dirty hack + GLWin.glCtxt = new wxGLContext(GLWin.glCanvas); #elif defined(_WIN32) // Create rendering window in Windows @@ -384,7 +385,8 @@ void OpenGL_Shutdown() { #if defined(USE_WX) && USE_WX GLWin.glCanvas->Hide(); - delete GLWin.glCtxt; + // XXX GLWin.glCanvas->Destroy(); + // XXX delete GLWin.glCtxt; #elif defined(_WIN32) if (hRC) // Do We Have A Rendering Context? {