From e65e4f992f3de9533a2155fe0d0ae0abad5b5867 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Fri, 23 Nov 2012 23:03:26 +0100 Subject: [PATCH] Now using DoubleBuffered rendering under OS X for OpenGL. Should hopefully gives some perf gain --- ogl_editor/src/macosx/RocketView.m | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ogl_editor/src/macosx/RocketView.m b/ogl_editor/src/macosx/RocketView.m index 6a56bd6..e2c81a6 100644 --- a/ogl_editor/src/macosx/RocketView.m +++ b/ogl_editor/src/macosx/RocketView.m @@ -4,6 +4,8 @@ #include #include +NSOpenGLContext* g_context = 0; + @implementation RocketView /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -20,10 +22,19 @@ self = [super initWithFrame:frame]; if (self == nil) return nil; - - oglContext = [[NSOpenGLContext alloc] initWithFormat: [NSOpenGLView defaultPixelFormat] shareContext: nil]; + + NSOpenGLPixelFormatAttribute attributes[4]; + + attributes[0] = NSOpenGLPFADoubleBuffer; + attributes[1] = 0; + + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; + oglContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil]; + //oglContext = [[NSOpenGLContext alloc] initWithFormat: [NSOpenGLView defaultPixelFormat] shareContext: nil]; [oglContext makeCurrentContext]; + g_context = oglContext; + EMGFXBackend_create(); Editor_create(); @@ -167,3 +178,9 @@ @end +////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void swapBuffers() +{ + [g_context flushBuffer]; +}