X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1be2473f5909d77ec93070d390429d92f3e47298..5c7b506103cfc078a821860766e31c47d595e07f:/src/mac/carbon/glcanvas.cpp diff --git a/src/mac/carbon/glcanvas.cpp b/src/mac/carbon/glcanvas.cpp index a5151fe3d2..5fe1661ddd 100644 --- a/src/mac/carbon/glcanvas.cpp +++ b/src/mac/carbon/glcanvas.cpp @@ -63,10 +63,6 @@ wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other) other ? other->m_aglContext : NULL); if ( !m_aglContext ) wxLogAGLError("aglCreateContext"); - - return; - if ( !aglEnable(m_aglContext, AGL_BUFFER_RECT) ) - wxLogAGLError("aglEnable(AGL_BUFFER_RECT)"); } wxGLContext::~wxGLContext() @@ -79,20 +75,27 @@ wxGLContext::~wxGLContext() } } -void wxGLContext::SetCurrent(const wxGLCanvas& win) const +bool wxGLContext::SetCurrent(const wxGLCanvas& win) const { if ( !m_aglContext ) - return; + return false; - AGLDrawable drawable = (AGLDrawable)UMAGetWindowPort( + AGLDrawable drawable = (AGLDrawable)GetWindowPort( MAC_WXHWND(win.MacGetTopLevelWindowRef())); if ( !aglSetDrawable(m_aglContext, drawable) ) + { wxLogAGLError("aglSetDrawable"); + return false; + } if ( !aglSetCurrentContext(m_aglContext) ) + { wxLogAGLError("aglSetCurrentContext"); + return false; + } wx_const_cast(wxGLCanvas&, win).SetViewport(); + return true; } // ---------------------------------------------------------------------------- @@ -309,12 +312,26 @@ wxGLCanvas::~wxGLCanvas() aglDestroyPixelFormat(m_aglFormat); } -void wxGLCanvas::SwapBuffers() +/* static */ +bool wxGLCanvasBase::IsDisplaySupported(const int *attribList) +{ + AGLPixelFormat aglFormat = ChoosePixelFormat(attribList); + + if ( !aglFormat ) + return false; + + aglDestroyPixelFormat(aglFormat); + + return true; +} + +bool wxGLCanvas::SwapBuffers() { AGLContext context = aglGetCurrentContext(); - wxCHECK_RET( context, _T("should have current context") ); + wxCHECK_MSG(context, false, _T("should have current context")); aglSwapBuffers(context); + return true; } void wxGLCanvas::SetViewport() @@ -365,6 +382,9 @@ void wxGLCanvas::SetViewport() if ( !aglSetInteger(context, AGL_BUFFER_RECT, parms) ) wxLogAGLError("aglSetInteger(AGL_BUFFER_RECT)"); + if ( !aglEnable(context, AGL_BUFFER_RECT) ) + wxLogAGLError("aglEnable(AGL_BUFFER_RECT)"); + if ( !aglUpdateContext(context) ) wxLogAGLError("aglUpdateContext"); } @@ -395,7 +415,7 @@ void wxGLCanvas::MacTopLevelWindowChangedPosition() void wxGLCanvas::MacVisibilityChanged() { - if ( MacIsReallyShown() != m_macCanvasIsShown ) + if ( IsShownOnScreen() != m_macCanvasIsShown ) { m_macCanvasIsShown = !m_macCanvasIsShown; MacUpdateView();