diff --git a/basis/opengl/opengl.factor b/basis/opengl/opengl.factor index a8b04eafbc..f3ee56587d 100644 --- a/basis/opengl/opengl.factor +++ b/basis/opengl/opengl.factor @@ -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 ; diff --git a/basis/ui/backend/cocoa/views/views.factor b/basis/ui/backend/cocoa/views/views.factor index 7ea60f1379..29ff18c786 100644 --- a/basis/ui/backend/cocoa/views/views.factor +++ b/basis/ui/backend/cocoa/views/views.factor @@ -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