X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1650623133123f4f708c61af6446aaaff9ef11e8..74698d3a22d5e611bbcd731a3ade616c66cfaca6:/src/mac/glcanvas.cpp diff --git a/src/mac/glcanvas.cpp b/src/mac/glcanvas.cpp index 6c1459db38..16e47d4c79 100644 --- a/src/mac/glcanvas.cpp +++ b/src/mac/glcanvas.cpp @@ -45,7 +45,7 @@ wxGLContext::wxGLContext( { m_window = win; - m_drawable = (AGLDrawable) UMAGetWindowPort(win->GetMacRootWindow()); + m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetRootWindow())); m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL); wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") ); @@ -111,9 +111,9 @@ void wxGLContext::SetColour(const char *colour) * wxGLCanvas implementation */ -IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow) +IMPLEMENT_CLASS(wxGLCanvas, wxWindow) -BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow) +BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow) EVT_SIZE(wxGLCanvas::OnSize) END_EVENT_TABLE() @@ -141,8 +141,10 @@ wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID i wxGLCanvas::~wxGLCanvas() { - if (m_glContext) - delete m_glContext; + if (m_glContext != NULL) { + delete m_glContext; + m_glContext = NULL; + } } static AGLPixelFormat ChoosePixelFormat(const int *attribList) @@ -216,8 +218,7 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID const wxPoint& pos, const wxSize& size, long style, const wxString& name, int *attribList, const wxPalette& palette) { - m_macEraseOnRedraw = false ; - wxScrolledWindow::Create( parent, id, pos, size, style, name ); + wxWindow::Create( parent, id, pos, size, style, name ); AGLPixelFormat fmt = ChoosePixelFormat(attribList); wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); @@ -252,7 +253,7 @@ void wxGLCanvas::SetViewport() int width, height; GetClientSize(& width, & height); Rect bounds ; - GetWindowPortBounds( GetMacRootWindow() , &bounds ) ; + GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ; GLint parms[4] ; parms[0] = x ; parms[1] = bounds.bottom - bounds.top - ( y + height ) ; @@ -263,20 +264,32 @@ void wxGLCanvas::SetViewport() } void wxGLCanvas::OnSize(wxSizeEvent& event) +{ + MacUpdateView() ; +} + +void wxGLCanvas::MacUpdateView() { if (m_glContext) { UpdateContext(); m_glContext->SetCurrent(); - SetViewport(); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 ); - glMatrixMode(GL_MODELVIEW); } } +void wxGLCanvas::MacSuperChangedPosition() +{ + MacUpdateView() ; + wxWindow::MacSuperChangedPosition() ; +} + +void wxGLCanvas::MacTopLevelWindowChangedPosition() +{ + MacUpdateView() ; + wxWindow::MacTopLevelWindowChangedPosition() ; +} + void wxGLCanvas::SetCurrent() { if (m_glContext) @@ -301,7 +314,11 @@ IMPLEMENT_CLASS(wxGLApp, wxApp) bool wxGLApp::InitGLVisual(int *attribList) { AGLPixelFormat fmt = ChoosePixelFormat(attribList); - return (fmt != NULL); + if (fmt != NULL) { + aglDestroyPixelFormat(fmt); + return true; + } else + return false; } wxGLApp::~wxGLApp(void)