]> gitweb.factorcode.org Git - factor.git/commitdiff
opengl: adding support for a gl-scale-factor.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 1 Nov 2012 21:48:12 +0000 (14:48 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 1 Nov 2012 21:48:12 +0000 (14:48 -0700)
basis/opengl/opengl.factor
basis/ui/backend/cocoa/views/views.factor

index a8b04eafbc6b03aa5cd18ee1e218bb2a8b82c047..f3ee56587df3132aadaf54e5f1dacafbeb62045c 100644 (file)
@@ -13,6 +13,8 @@ SPECIALIZED-ARRAY: float
 SPECIALIZED-ARRAY: uint
 IN: opengl
 
+SYMBOL: gl-scale-factor
+
 : gl-color ( color -- ) >rgba-components glColor4d ; inline
 
 : gl-clear-color ( color -- ) >rgba-components glClearColor ;
@@ -200,8 +202,14 @@ MACRO: set-draw-buffers ( buffers -- )
 : with-translation ( loc quot -- )
     [ [ gl-translate ] dip call ] do-matrix ; inline
 
+: gl-scale ( m -- n )
+    gl-scale-factor get-global [ * ] when* ; inline
+
+: gl-unscale ( m -- n )
+    gl-scale-factor get-global [ / ] when* ; inline
+
 : fix-coordinates ( point1 point2 -- x1 y1 x2 y2 )
-    [ first2 [ >fixnum ] bi@ ] bi@ ;
+    [ first2 [ gl-scale >fixnum ] bi@ ] bi@ ;
 
 : gl-set-clip ( loc dim -- )
     fix-coordinates glScissor ;
index 7ea60f13793606c40b4ddbeee92c9cee208e11d0..29ff18c786a9afe6fd4c03b753cb9acb8bdde18a 100644 (file)
@@ -1,13 +1,12 @@
 ! Copyright (C) 2006, 2010 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types alien.data alien.strings
-arrays assocs cocoa kernel math cocoa.messages cocoa.subclassing
-cocoa.classes cocoa.views cocoa.application cocoa.pasteboard
-cocoa.runtime cocoa.types cocoa.windows sequences
-io.encodings.utf8 locals ui ui.private ui.gadgets
-ui.gadgets.private ui.gadgets.worlds ui.gestures
-core-foundation.strings core-graphics core-graphics.types
-threads combinators math.rectangles ;
+arrays assocs cocoa cocoa.application cocoa.classes
+cocoa.pasteboard cocoa.runtime cocoa.subclassing cocoa.types
+cocoa.views combinators core-foundation.strings core-graphics
+core-graphics.types io.encodings.utf8 kernel locals math
+math.rectangles namespaces opengl sequences threads ui.gadgets
+ui.gadgets.private ui.gadgets.worlds ui.gestures ui.private ;
 IN: ui.backend.cocoa.views
 
 : send-mouse-moved ( view event -- )
@@ -307,6 +306,7 @@ CLASS: FactorView < NSOpenGLView NSTextInput
 
     METHOD: void prepareOpenGL [
         self 1 -> setWantsBestResolutionOpenGLSurface:
+        self -> backingScaleFactor gl-scale-factor set-global
     ]
 
     ! Initialization