X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e40298d54ecd5b109222a7c60aa2ef084a304d69..587bc950902c424518fb7a82a5249593b0e42479:/src/mac/carbon/glcanvas.cpp diff --git a/src/mac/carbon/glcanvas.cpp b/src/mac/carbon/glcanvas.cpp index 345fc2aeaf..e6a8b50a69 100644 --- a/src/mac/carbon/glcanvas.cpp +++ b/src/mac/carbon/glcanvas.cpp @@ -33,6 +33,10 @@ #include "wx/glcanvas.h" #include "wx/mac/uma.h" +// DLL options compatibility check: +#include "wx/build.h" +WX_CHECK_BUILD_OPTIONS("wxGL") + /* * GLContext implementation */ @@ -45,7 +49,7 @@ wxGLContext::wxGLContext( { m_window = win; - m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetRootWindow())); + m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetTopLevelWindowRef())); m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL); wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") ); @@ -91,17 +95,14 @@ void wxGLContext::Update() } } -void wxGLContext::SetColour(const char *colour) +void wxGLContext::SetColour(const wxChar *colour) { - float r = 0.0; - float g = 0.0; - float b = 0.0; - wxColour *col = wxTheColourDatabase->FindColour(colour); - if (col) + wxColour col = wxTheColourDatabase->Find(colour); + if (col.Ok()) { - r = (float)(col->Red()/256.0); - g = (float)(col->Green()/256.0); - b = (float)(col->Blue()/256.0); + float r = (float)(col.Red()/256.0); + float g = (float)(col.Green()/256.0); + float b = (float)(col.Blue()/256.0); glColor3f( r, g, b); } } @@ -224,7 +225,7 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); m_glContext = new wxGLContext(fmt, this, palette, shared); - + m_macCanvasIsShown = true ; aglDestroyPixelFormat(fmt); return true; @@ -249,18 +250,29 @@ void wxGLCanvas::SetViewport() int x = 0 ; int y = 0 ; - MacClientToRootWindow( &x , &y ) ; - int width, height; - GetClientSize(& width, & height); - Rect bounds ; - GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ; - GLint parms[4] ; - parms[0] = x ; - parms[1] = bounds.bottom - bounds.top - ( y + height ) ; - parms[2] = width ; - parms[3] = height ; + wxWindow* iter = this ; + while( iter->GetParent() ) + { + iter = iter->GetParent() ; + } - aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; + if ( iter && iter->IsTopLevel() ) + { + MacClientToRootWindow( &x , &y ) ; + int width, height; + GetClientSize(& width, & height); + Rect bounds ; + GetWindowPortBounds( MAC_WXHWND(MacGetTopLevelWindowRef()) , &bounds ) ; + GLint parms[4] ; + parms[0] = x ; + parms[1] = bounds.bottom - bounds.top - ( y + height ) ; + parms[2] = width ; + parms[3] = height ; + + if ( !m_macCanvasIsShown ) + parms[0] += 20000 ; + aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; + } } void wxGLCanvas::OnSize(wxSizeEvent& event) @@ -298,12 +310,57 @@ void wxGLCanvas::SetCurrent() } } -void wxGLCanvas::SetColour(const char *colour) +void wxGLCanvas::SetColour(const wxChar *colour) { if (m_glContext) m_glContext->SetColour(colour); } +bool wxGLCanvas::Show(bool show) +{ + if ( !wxWindow::Show( show ) ) + return FALSE ; +/* + if ( !show ) + { + if ( m_macCanvasIsShown ) + { + m_macCanvasIsShown = false ; + SetViewport() ; + } + } + else + { + if ( IsControlVisible( (ControlRef) m_macControl ) && !m_macCanvasIsShown ) + { + m_macCanvasIsShown = true ; + SetViewport() ; + } + } +*/ + return TRUE ; +} + +void wxGLCanvas::MacVisibilityChanged() +{ + if ( !IsControlVisible( (ControlRef) m_macControl ) ) + { + if ( m_macCanvasIsShown ) + { + m_macCanvasIsShown = false ; + SetViewport() ; + } + } + else + { + if ( !m_macCanvasIsShown ) + { + m_macCanvasIsShown = true ; + SetViewport() ; + } + } + wxWindowMac::MacVisibilityChanged() ; +} //--------------------------------------------------------------------------- // wxGLApp