1 ! Copyright (C) 2006, 2009 Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays kernel math namespaces make
4 cocoa cocoa.messages cocoa.classes core-graphics
5 core-graphics.types sequences continuations accessors ;
8 CONSTANT: NSOpenGLPFAAllRenderers 1
9 CONSTANT: NSOpenGLPFADoubleBuffer 5
10 CONSTANT: NSOpenGLPFAStereo 6
11 CONSTANT: NSOpenGLPFAAuxBuffers 7
12 CONSTANT: NSOpenGLPFAColorSize 8
13 CONSTANT: NSOpenGLPFAAlphaSize 11
14 CONSTANT: NSOpenGLPFADepthSize 12
15 CONSTANT: NSOpenGLPFAStencilSize 13
16 CONSTANT: NSOpenGLPFAAccumSize 14
17 CONSTANT: NSOpenGLPFAMinimumPolicy 51
18 CONSTANT: NSOpenGLPFAMaximumPolicy 52
19 CONSTANT: NSOpenGLPFAOffScreen 53
20 CONSTANT: NSOpenGLPFAFullScreen 54
21 CONSTANT: NSOpenGLPFASampleBuffers 55
22 CONSTANT: NSOpenGLPFASamples 56
23 CONSTANT: NSOpenGLPFAAuxDepthStencil 57
24 CONSTANT: NSOpenGLPFAColorFloat 58
25 CONSTANT: NSOpenGLPFAMultisample 59
26 CONSTANT: NSOpenGLPFASupersample 60
27 CONSTANT: NSOpenGLPFASampleAlpha 61
28 CONSTANT: NSOpenGLPFARendererID 70
29 CONSTANT: NSOpenGLPFASingleRenderer 71
30 CONSTANT: NSOpenGLPFANoRecovery 72
31 CONSTANT: NSOpenGLPFAAccelerated 73
32 CONSTANT: NSOpenGLPFAClosestPolicy 74
33 CONSTANT: NSOpenGLPFARobust 75
34 CONSTANT: NSOpenGLPFABackingStore 76
35 CONSTANT: NSOpenGLPFAMPSafe 78
36 CONSTANT: NSOpenGLPFAWindow 80
37 CONSTANT: NSOpenGLPFAMultiScreen 81
38 CONSTANT: NSOpenGLPFACompliant 83
39 CONSTANT: NSOpenGLPFAScreenMask 84
40 CONSTANT: NSOpenGLPFAPixelBuffer 90
41 CONSTANT: NSOpenGLPFAAllowOfflineRenderers 96
42 CONSTANT: NSOpenGLPFAVirtualScreenCount 128
43 CONSTANT: NSOpenGLCPSwapInterval 222
45 : <GLView> ( class dim pixel-format -- view )
47 [ [ 0 0 ] dip first2 <CGRect> ]
49 -> initWithFrame:pixelFormat:
50 dup 1 -> setPostsBoundsChangedNotifications:
51 dup 1 -> setPostsFrameChangedNotifications: ;
53 : view-dim ( view -- dim )
55 [ CGRect-w >fixnum ] [ CGRect-h >fixnum ] bi
58 : mouse-location ( view event -- loc )
60 -> locationInWindow f -> convertPoint:fromView:
62 ] [ drop -> frame CGRect-h ] 2bi
63 swap - [ >integer ] bi@ 2array ;