opengl: adding support for a gl-scale-factor.

db4
John Benediktsson 2012-11-01 14:48:12 -07:00
parent f2ce2a0b61
commit 44b7bbc76d
2 changed files with 16 additions and 8 deletions

View 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 ;

View 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