OpenGL changes for carbon and cocoa

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2009-09-13 17:19:01 +00:00
parent e7ee4873d5
commit b90817de2b
4 changed files with 35 additions and 30 deletions

View File

@@ -15,17 +15,20 @@
#ifdef __WXOSX_IPHONE__
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#define wxUSE_OPENGL_EMULATION 1
#else
#include <OpenGL/gl.h>
#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 );

View File

@@ -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 )

View File

@@ -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

View File

@@ -35,8 +35,6 @@
#include "wx/osx/private.h"
#include <AGL/agl.h>
// ----------------------------------------------------------------------------
// 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.