X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e5684ea03b4b9fa41d81968236aa070eefd30374..eea4d01c65f9b29baa1193db762b4c6b8144af24:/src/osx/iphone/glcanvas.mm diff --git a/src/osx/iphone/glcanvas.mm b/src/osx/iphone/glcanvas.mm index 5231dde912..bfe0ce8bc6 100644 --- a/src/osx/iphone/glcanvas.mm +++ b/src/osx/iphone/glcanvas.mm @@ -4,7 +4,7 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id: glcanvas.cpp 54129 2008-06-11 19:30:52Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -46,6 +46,7 @@ @interface wxUICustomOpenGLView : UIView { + CGRect oldRect; EAGLContext* context; /* The pixel dimensions of the backbuffer */ @@ -61,6 +62,7 @@ - (BOOL) createFramebuffer; - (void) destroyFramebuffer; +- (id) initWithFrame:(CGRect) rect; @end @@ -80,6 +82,15 @@ } } +- (id) initWithFrame:(CGRect)rect +{ + if ( !(self=[super initWithFrame:rect]) ) + return nil; + + oldRect = rect; + return self; +} + - (BOOL)isOpaque { return YES; @@ -89,6 +100,7 @@ glGenFramebuffersOES(1, &viewFramebuffer); glGenRenderbuffersOES(1, &viewRenderbuffer); + glEnable(GL_CULL_FACE); glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); @@ -130,8 +142,15 @@ - (void) setContext:(EAGLContext*) ctx { context = ctx; [EAGLContext setCurrentContext:ctx]; - [self destroyFramebuffer]; - [self createFramebuffer]; +#if 0 + CGRect newRect = [self frame]; + if ( /* (CGRectEqualToRect(newRect, oldRect) == NO && ![self isHidden] && newRect.size.width > 0 && newRect.size.height > 0 ) + || */ viewFramebuffer == 0 ) + { + [self destroyFramebuffer]; + [self createFramebuffer]; + } +#endif glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); } @@ -140,6 +159,12 @@ [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } +- (void)layoutSubviews { + [EAGLContext setCurrentContext:context]; + [self destroyFramebuffer]; + [self createFramebuffer]; +} + @end @@ -357,7 +382,7 @@ bool wxGLCanvas::Create(wxWindow *parent, return false; */ #if USE_SEPARATE_VIEW - m_macIsUserPane = false ; + DontCreatePeer(); #endif if ( !wxWindow::Create(parent, id, pos, size, style, name) ) @@ -372,7 +397,7 @@ bool wxGLCanvas::Create(wxWindow *parent, [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; - m_peer = new wxWidgetIPhoneImpl( this, v ); + SetPeer(new wxWidgetIPhoneImpl( this, v )); MacPostControlCreate(pos, size) ; #endif @@ -390,7 +415,7 @@ bool wxGLCanvas::SwapBuffers() WXGLContext context = WXGLGetCurrentContext(); wxCHECK_MSG(context, false, wxT("should have current context")); - wxUICustomOpenGLView* v = (wxUICustomOpenGLView*) m_peer->GetWXWidget(); + wxUICustomOpenGLView* v = (wxUICustomOpenGLView*) GetPeer()->GetWXWidget(); [v swapBuffers]; return true; }