Another shot at fixing wxGLCanvas woes on Mac, updates #850. This time the code is also considerably simpler!

Originally committed to SVN as r3014.
This commit is contained in:
Niels Martin Hansen 2009-06-04 02:05:11 +00:00
parent d6a8a07845
commit 26ac4e65f8

View file

@ -467,26 +467,22 @@ void VideoContext::JumpToTime(int ms,bool exact) {
////////////////// //////////////////
// Get GL context // Get GL context
wxGLContext *VideoContext::GetGLContext(wxGLCanvas *canvas) { wxGLContext *VideoContext::GetGLContext(wxGLCanvas *canvas) {
#ifdef __WXMAC__ // wxGLCanvas and wxGLContext is a funky couple.
// This code is written blindly, might be very broken // On wxMac wxGLContext has a different constructor than everywhere else...
// What are the wxMac developers thinking? This is impossible to work with, // But wxMac is also the only implementation that creates and initialises a context
// having a different API on different platforms... // in the canvas constructor, meaning a wxGLCanvas on wxMac comes with a context
if (!glContext) { // for free, while we have to create our own everywhere else.
GLint pfmtattribs[] = {AGL_WINDOW, AGL_BACKING_STORE, AGL_STENCIL_SIZE, 1, 0}; // So let's first see if the canvas might already have a context of its own and
AGLPixelFormat pfmt = aglChoosePixelFormat(0, 0, pfmtattribs); // get that if we lack one.
glContext = new wxGLContext(pfmt, canvas, wxPalette(), 0); // That should always succeed on wxMac...
} // Everywhere else, we can just create a wxGLContext using the documented interface
#else // and be over with it after that.
// Also see bug #850.
if (!glContext) glContext = canvas->GetContext();
#ifndef __WXMAC__
if (!glContext) glContext = new wxGLContext(canvas); if (!glContext) glContext = new wxGLContext(canvas);
#endif #endif
return glContext; return glContext;
/*
if (!((VideoDisplay*)canvas)->freeSize) return glContext;
else {
static wxGLContext *test = NULL;
if (test = NULL) test = new wxGLContext(canvas,glContext);
return test;
}*/
} }