bool wxGLContext::SetCurrent(const wxGLCanvas& win) const { if ( !m_glContext ) return false; AGLDrawable drawable = (AGLDrawable)GetWindowPort( MAC_WXHWND(win.MacGetTopLevelWindowRef())); GLint bufnummer = win.GetAglBufferName(); aglSetInteger(m_glContext, AGL_BUFFER_NAME, &bufnummer); //win.SetLastContext(m_glContext); const_cast<wxGLCanvas&>(win).SetViewport(); if ( !aglSetDrawable(m_glContext, drawable) ) { wxLogAGLError("aglSetDrawable"); return false; } if ( !aglSetCurrentContext(m_glContext) ) { wxLogAGLError("aglSetCurrentContext"); return false; } return true; }
WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext ) { WXGLContext context = aglCreateContext(pixelFormat, shareContext); if ( !context ) wxLogAGLError("aglCreateContext"); return context ; }
bool wxGLContext::SetCurrent(const wxGLCanvas& win) const { if ( !m_glContext ) return false; GLint bufnummer = win.GetAglBufferName(); aglSetInteger(m_glContext, AGL_BUFFER_NAME, &bufnummer); //win.SetLastContext(m_glContext); const_cast<wxGLCanvas&>(win).SetViewport(); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if ( UMAGetSystemVersion() >= 0x1050 ) { aglSetWindowRef(m_glContext, win.MacGetTopLevelWindowRef()); } else #endif { AGLDrawable drawable = (AGLDrawable)GetWindowPort( MAC_WXHWND(win.MacGetTopLevelWindowRef())); if ( !aglSetDrawable(m_glContext, drawable) ) { wxLogAGLError("aglSetDrawable"); return false; } } return WXGLSetCurrentContext(m_glContext); }
void WXGLDestroyContext( WXGLContext context ) { if ( context ) { if ( !aglDestroyContext(context) ) { wxLogAGLError("aglDestroyContext"); } } }
bool WXGLSetCurrentContext(WXGLContext context) { if ( !aglSetCurrentContext(context) ) { wxLogAGLError("aglSetCurrentContext"); return false; } return true; }
void wxGLCanvas::SetViewport() { if ( !m_needsUpdate ) return; m_needsUpdate = false; // AGLContext context = aglGetCurrentContext(); // if ( !context ) // return; // viewport is initially set to entire port, adjust it to just this window int x = 0, y = 0; 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; // move the buffer rect out of sight if we're hidden if ( !m_macCanvasIsShown ) parms[0] += 20000; if ( !aglSetInteger(m_dummyContext, AGL_BUFFER_RECT, parms) ) wxLogAGLError("aglSetInteger(AGL_BUFFER_RECT)"); if ( !aglEnable(m_dummyContext, AGL_BUFFER_RECT) ) wxLogAGLError("aglEnable(AGL_BUFFER_RECT)"); if ( !aglUpdateContext(m_dummyContext) ) wxLogAGLError("aglUpdateContext"); }