]> gitweb.factorcode.org Git - factor.git/commitdiff
sync gl refresh with monitor refresh in macosx
authorAlex Chapman <chapman.alex@gmail.com>
Fri, 16 May 2008 14:57:27 +0000 (00:57 +1000)
committerAlex Chapman <chapman.alex@gmail.com>
Fri, 16 May 2008 14:57:27 +0000 (00:57 +1000)
extra/cocoa/views/views.factor
extra/ui/cocoa/views/views.factor

index 7b8de9067c6685d774e813693feb0d12dbe7ca6f..ca631d5deab2bb1c88edb5d04e595eb8b250a0d7 100644 (file)
@@ -74,3 +74,17 @@ PRIVATE>
     -> locationInWindow f -> convertPoint:fromView:
     dup NSPoint-x swap NSPoint-y
     r> -> frame NSRect-h swap - 2array ;
+
+USE: opengl.gl
+USE: alien.syntax
+
+: NSOpenGLCPSwapInterval 222 ;
+
+LIBRARY: OpenGL
+
+TYPEDEF: int CGLError
+TYPEDEF: void* CGLContextObj
+TYPEDEF: int CGLContextParameter
+
+FUNCTION: CGLError CGLSetParameter ( CGLContextObj ctx, CGLContextParameter pname, GLint* params ) ;
+
index 83890788e3675b4dfea8a6a3636252debf799640..20e6e19de5230f970b2ab3777dd913bff472a400 100755 (executable)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2006, 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays assocs cocoa kernel math cocoa.messages
+USING: alien alien.c-types arrays assocs cocoa kernel math cocoa.messages
 cocoa.subclassing cocoa.classes cocoa.views cocoa.application
-cocoa.pasteboard cocoa.types cocoa.windows sequences ui
-ui.gadgets ui.gadgets.worlds ui.gestures core-foundation
-threads combinators ;
+cocoa.pasteboard cocoa.types cocoa.windows sequences ui ui.gadgets
+ui.gadgets.worlds ui.gestures core-foundation threads combinators ;
 IN: ui.cocoa.views
 
 : send-mouse-moved ( view event -- )
@@ -360,8 +359,14 @@ CLASS: {
     ]
 } ;
 
+: sync-refresh-to-screen ( GLView -- )
+    -> openGLContext -> CGLContextObj NSOpenGLCPSwapInterval 1 <int>
+    CGLSetParameter drop ;
+
 : <FactorView> ( world -- view )
-    FactorView over rect-dim <GLView> [ register-window ] keep ;
+    FactorView over rect-dim <GLView>
+    [ sync-refresh-to-screen ] keep
+    [ register-window ] keep ;
 
 CLASS: {
     { +superclass+ "NSObject" }