From b90817de2b4543762b308f15f7010a19e941991e Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sun, 13 Sep 2009 17:19:01 +0000 Subject: [PATCH] OpenGL changes for carbon and cocoa git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/glcanvas.h | 5 ++++- src/osx/carbon/glcanvas.cpp | 14 +++++++++----- src/osx/cocoa/glcanvas.mm | 35 ++++++++++++++++++++++------------- src/osx/glcanvas_osx.cpp | 11 ----------- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/include/wx/osx/glcanvas.h b/include/wx/osx/glcanvas.h index 62b5c001be..ff97bdf0ef 100644 --- a/include/wx/osx/glcanvas.h +++ b/include/wx/osx/glcanvas.h @@ -15,17 +15,20 @@ #ifdef __WXOSX_IPHONE__ #import #import +#define wxUSE_OPENGL_EMULATION 1 #else #include #endif +#include "wx/vector.h" + // low level calls WXDLLIMPEXP_GL WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext ); WXDLLIMPEXP_GL void WXGLDestroyContext( WXGLContext context ); + WXDLLIMPEXP_GL WXGLContext WXGLGetCurrentContext(); WXDLLIMPEXP_GL bool WXGLSetCurrentContext(WXGLContext context); -WXDLLIMPEXP_GL void WXGLSwapBuffers( WXGLContext context ); WXDLLIMPEXP_GL WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList); WXDLLIMPEXP_GL void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat ); diff --git a/src/osx/carbon/glcanvas.cpp b/src/osx/carbon/glcanvas.cpp index 4029acc11c..9a6226dd9a 100644 --- a/src/osx/carbon/glcanvas.cpp +++ b/src/osx/carbon/glcanvas.cpp @@ -77,11 +77,6 @@ void WXGLDestroyContext( WXGLContext context ) } } -void WXGLSwapBuffers( WXGLContext context ) -{ - aglSwapBuffers(context); -} - WXGLContext WXGLGetCurrentContext() { return aglGetCurrentContext(); @@ -367,6 +362,15 @@ wxGLCanvas::~wxGLCanvas() WXGLDestroyContext(m_dummyContext); } +bool wxGLCanvas::SwapBuffers() +{ + WXGLContext context = WXGLGetCurrentContext(); + wxCHECK_MSG(context, false, wxT("should have current context")); + + aglSwapBuffers(context); + return true; +} + void wxGLCanvas::SetViewport() { if ( !m_needsUpdate ) diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 4c5f6ec1e5..bebcdcefdb 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -221,19 +221,6 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) return [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*) attribs]; } -bool wxGLContext::SetCurrent(const wxGLCanvas& win) const -{ - if ( !m_glContext ) - return false; - - [m_glContext setView: win.GetHandle() ]; - [m_glContext update]; - - [m_glContext makeCurrentContext]; - - return true; -} - @interface wxNSCustomOpenGLView : NSView { NSOpenGLContext* context; @@ -294,5 +281,27 @@ wxGLCanvas::~wxGLCanvas() WXGLDestroyPixelFormat(m_glFormat); } +bool wxGLCanvas::SwapBuffers() +{ + WXGLContext context = WXGLGetCurrentContext(); + wxCHECK_MSG(context, false, wxT("should have current context")); + + [context flushBuffer]; + + return true; +} + +bool wxGLContext::SetCurrent(const wxGLCanvas& win) const +{ + if ( !m_glContext ) + return false; + + [m_glContext setView: win.GetHandle() ]; + [m_glContext update]; + + [m_glContext makeCurrentContext]; + + return true; +} #endif // wxUSE_GLCANVAS diff --git a/src/osx/glcanvas_osx.cpp b/src/osx/glcanvas_osx.cpp index d571089709..56f74a7f41 100644 --- a/src/osx/glcanvas_osx.cpp +++ b/src/osx/glcanvas_osx.cpp @@ -35,8 +35,6 @@ #include "wx/osx/private.h" -#include - // ---------------------------------------------------------------------------- // wxGLCanvas // ---------------------------------------------------------------------------- @@ -147,15 +145,6 @@ bool wxGLCanvasBase::IsDisplaySupported(const int *attribList) return true; } -bool wxGLCanvas::SwapBuffers() -{ - WXGLContext context = WXGLGetCurrentContext(); - wxCHECK_MSG(context, false, wxT("should have current context")); - - WXGLSwapBuffers(context); - return true; -} - bool wxGLCanvasBase::IsExtensionSupported(const char *extension) { // we need a valid context to query for extensions. -- 2.45.2