From d1251757ef9cba22d9aaabc1816e5784e157e2b8 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Thu, 4 Jun 2009 02:05:11 +0000 Subject: [PATCH] Another shot at fixing wxGLCanvas woes on Mac, updates #850. This time the code is also considerably simpler! Originally committed to SVN as r3014. --- aegisub/src/video_context.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 95d90ae74..85de103b8 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -467,26 +467,22 @@ void VideoContext::JumpToTime(int ms,bool exact) { ////////////////// // Get GL context wxGLContext *VideoContext::GetGLContext(wxGLCanvas *canvas) { -#ifdef __WXMAC__ - // This code is written blindly, might be very broken - // What are the wxMac developers thinking? This is impossible to work with, - // having a different API on different platforms... - if (!glContext) { - GLint pfmtattribs[] = {AGL_WINDOW, AGL_BACKING_STORE, AGL_STENCIL_SIZE, 1, 0}; - AGLPixelFormat pfmt = aglChoosePixelFormat(0, 0, pfmtattribs); - glContext = new wxGLContext(pfmt, canvas, wxPalette(), 0); - } -#else + // wxGLCanvas and wxGLContext is a funky couple. + // On wxMac wxGLContext has a different constructor than everywhere else... + // But wxMac is also the only implementation that creates and initialises a context + // in the canvas constructor, meaning a wxGLCanvas on wxMac comes with a context + // for free, while we have to create our own everywhere else. + // So let's first see if the canvas might already have a context of its own and + // get that if we lack one. + // That should always succeed on wxMac... + // Everywhere else, we can just create a wxGLContext using the documented interface + // and be over with it after that. + // Also see bug #850. + if (!glContext) glContext = canvas->GetContext(); +#ifndef __WXMAC__ if (!glContext) glContext = new wxGLContext(canvas); #endif return glContext; - /* - if (!((VideoDisplay*)canvas)->freeSize) return glContext; - else { - static wxGLContext *test = NULL; - if (test = NULL) test = new wxGLContext(canvas,glContext); - return test; - }*/ }