X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0f9b48d1e1535f8b92a73031be8cceff39123d27..9b66a1d31a32e9235792261db6ff755ce26ab5c1:/src/osx/cocoa/glcanvas.mm diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index b00ff4a235..e088ede061 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -35,7 +35,6 @@ #include "wx/osx/private.h" - WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext ) { WXGLContext context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: shareContext]; @@ -77,6 +76,10 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) const NSOpenGLPixelFormatAttribute defaultAttribs[] = { NSOpenGLPFADoubleBuffer, + NSOpenGLPFAMinimumPolicy, + NSOpenGLPFAColorSize,(NSOpenGLPixelFormatAttribute)8, + NSOpenGLPFAAlphaSize,(NSOpenGLPixelFormatAttribute)0, + NSOpenGLPFADepthSize,(NSOpenGLPixelFormatAttribute)8, (NSOpenGLPixelFormatAttribute)nil }; @@ -118,12 +121,12 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) case WX_GL_AUX_BUFFERS: data[p++] = NSOpenGLPFAAuxBuffers; - data[p++] = attribList[arg++]; + data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]; break; case WX_GL_MIN_RED: data[p++] = NSOpenGLPFAColorSize; - data[p++] = attribList[arg++]; + data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]; break; case WX_GL_MIN_GREEN: @@ -138,22 +141,22 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) case WX_GL_MIN_ALPHA: data[p++] = NSOpenGLPFAAlphaSize; - data[p++] = attribList[arg++]; + data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]; break; case WX_GL_DEPTH_SIZE: data[p++] = NSOpenGLPFADepthSize; - data[p++] = attribList[arg++]; + data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]; break; case WX_GL_STENCIL_SIZE: data[p++] = NSOpenGLPFAStencilSize; - data[p++] = attribList[arg++]; + data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]; break; case WX_GL_MIN_ACCUM_RED: data[p++] = NSOpenGLPFAAccumSize; - data[p++] = attribList[arg++]; + data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]; break; case WX_GL_MIN_ACCUM_GREEN: @@ -181,7 +184,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) } data[p++] = NSOpenGLPFASampleBuffers; - if ( (data[p++] = attribList[arg++]) == true ) + if ( (data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]) == true ) { // don't use software fallback data[p++] = NSOpenGLPFANoRecovery; @@ -198,7 +201,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) } data[p++] = NSOpenGLPFASamples; - data[p++] = attribList[arg++]; + data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]; break; } } @@ -208,7 +211,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList) attribs = data; } - return [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; + return [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*) attribs]; } bool wxGLContext::SetCurrent(const wxGLCanvas& win) const @@ -217,6 +220,7 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const return false; [m_glContext setView: win.GetHandle() ]; + [m_glContext update]; [m_glContext makeCurrentContext]; @@ -225,14 +229,13 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const @interface wxNSCustomOpenGLView : NSView { - wxWidgetImpl* impl; + WXCOCOAIMPL_COMMON_MEMBERS NSOpenGLContext* context; } - (id)initWithFrame:(NSRect)frame; -- (void)setImplementation: (wxWidgetImpl *) theImplementation; -- (wxWidgetImpl*) implementation; -- (BOOL) isFlipped; + +WXCOCOAIMPL_COMMON_INTERFACE @end @@ -245,20 +248,7 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const return self; } -- (void)setImplementation: (wxWidgetImpl *) theImplementation -{ - impl = theImplementation; -} - -- (wxWidgetImpl*) implementation -{ - return impl; -} - -- (BOOL) isFlipped -{ - return YES; -} +WXCOCOAIMPL_COMMON_IMPLEMENTATION - (BOOL)isOpaque { @@ -280,23 +270,27 @@ bool wxGLCanvas::Create(wxWindow *parent, if ( !m_glFormat ) return false; - m_macIsUserPane = false ; + // m_macIsUserPane = false ; if ( !wxWindow::Create(parent, id, pos, size, style, name) ) return false; - - NSView* sv = (parent->GetHandle() ); - +/* NSRect r = wxOSXGetFrameForControl( this, pos , size ) ; wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r]; - [sv addSubview:v]; m_peer = new wxWidgetCocoaImpl( this, v ); [v setImplementation:m_peer]; MacPostControlCreate(pos, size) ; - +*/ return true; } +wxGLCanvas::~wxGLCanvas() +{ + if ( m_glFormat ) + WXGLDestroyPixelFormat(m_glFormat); +} + + #endif // wxUSE_GLCANVAS