diff --git a/extra/cocoa/views/views.factor b/extra/cocoa/views/views.factor index 7b8de9067c..ca631d5dea 100644 --- a/extra/cocoa/views/views.factor +++ b/extra/cocoa/views/views.factor @@ -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 ) ; + diff --git a/extra/ui/cocoa/views/views.factor b/extra/ui/cocoa/views/views.factor index 83890788e3..20e6e19de5 100755 --- a/extra/ui/cocoa/views/views.factor +++ b/extra/ui/cocoa/views/views.factor @@ -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 + CGLSetParameter drop ; + : ( world -- view ) - FactorView over rect-dim [ register-window ] keep ; + FactorView over rect-dim + [ sync-refresh-to-screen ] keep + [ register-window ] keep ; CLASS: { { +superclass+ "NSObject" }