2007-09-20 18:09:08 -04:00
|
|
|
! Copyright (C) 2006, 2007 Slava Pestov
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-09-10 21:07:00 -04:00
|
|
|
USING: alien.c-types arrays kernel math namespaces make cocoa
|
2008-01-30 01:01:06 -05:00
|
|
|
cocoa.messages cocoa.classes cocoa.types sequences
|
|
|
|
continuations ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: cocoa.views
|
|
|
|
|
|
|
|
: NSOpenGLPFAAllRenderers 1 ;
|
|
|
|
: NSOpenGLPFADoubleBuffer 5 ;
|
|
|
|
: NSOpenGLPFAStereo 6 ;
|
|
|
|
: NSOpenGLPFAAuxBuffers 7 ;
|
|
|
|
: NSOpenGLPFAColorSize 8 ;
|
|
|
|
: NSOpenGLPFAAlphaSize 11 ;
|
|
|
|
: NSOpenGLPFADepthSize 12 ;
|
|
|
|
: NSOpenGLPFAStencilSize 13 ;
|
|
|
|
: NSOpenGLPFAAccumSize 14 ;
|
|
|
|
: NSOpenGLPFAMinimumPolicy 51 ;
|
|
|
|
: NSOpenGLPFAMaximumPolicy 52 ;
|
|
|
|
: NSOpenGLPFAOffScreen 53 ;
|
|
|
|
: NSOpenGLPFAFullScreen 54 ;
|
|
|
|
: NSOpenGLPFASampleBuffers 55 ;
|
|
|
|
: NSOpenGLPFASamples 56 ;
|
|
|
|
: NSOpenGLPFAAuxDepthStencil 57 ;
|
2008-08-30 21:54:04 -04:00
|
|
|
: NSOpenGLPFAColorFloat 58 ;
|
|
|
|
: NSOpenGLPFAMultisample 59 ;
|
|
|
|
: NSOpenGLPFASupersample 60 ;
|
|
|
|
: NSOpenGLPFASampleAlpha 61 ;
|
2007-09-20 18:09:08 -04:00
|
|
|
: NSOpenGLPFARendererID 70 ;
|
|
|
|
: NSOpenGLPFASingleRenderer 71 ;
|
|
|
|
: NSOpenGLPFANoRecovery 72 ;
|
|
|
|
: NSOpenGLPFAAccelerated 73 ;
|
|
|
|
: NSOpenGLPFAClosestPolicy 74 ;
|
|
|
|
: NSOpenGLPFARobust 75 ;
|
|
|
|
: NSOpenGLPFABackingStore 76 ;
|
|
|
|
: NSOpenGLPFAMPSafe 78 ;
|
|
|
|
: NSOpenGLPFAWindow 80 ;
|
|
|
|
: NSOpenGLPFAMultiScreen 81 ;
|
|
|
|
: NSOpenGLPFACompliant 83 ;
|
|
|
|
: NSOpenGLPFAScreenMask 84 ;
|
|
|
|
: NSOpenGLPFAPixelBuffer 90 ;
|
2008-08-30 21:54:04 -04:00
|
|
|
: NSOpenGLPFAAllowOfflineRenderers 96 ;
|
2007-09-20 18:09:08 -04:00
|
|
|
: NSOpenGLPFAVirtualScreenCount 128 ;
|
|
|
|
|
2008-08-30 21:54:04 -04:00
|
|
|
: kCGLRendererGenericFloatID HEX: 00020400 ;
|
|
|
|
|
2008-01-30 01:01:06 -05:00
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
SYMBOL: +software-renderer+
|
2008-08-30 21:54:04 -04:00
|
|
|
SYMBOL: +multisample+
|
2008-01-30 01:01:06 -05:00
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
|
|
|
: with-software-renderer ( quot -- )
|
2008-08-30 21:54:04 -04:00
|
|
|
t +software-renderer+ pick with-variable ; inline
|
|
|
|
: with-multisample ( quot -- )
|
|
|
|
t +multisample+ pick with-variable ; inline
|
2008-01-30 01:01:06 -05:00
|
|
|
|
2007-09-20 18:09:08 -04:00
|
|
|
: <PixelFormat> ( -- pixelfmt )
|
|
|
|
NSOpenGLPixelFormat -> alloc [
|
|
|
|
NSOpenGLPFAWindow ,
|
|
|
|
NSOpenGLPFADoubleBuffer ,
|
|
|
|
NSOpenGLPFADepthSize , 16 ,
|
2008-08-30 21:54:04 -04:00
|
|
|
+software-renderer+ get [
|
|
|
|
NSOpenGLPFARendererID , kCGLRendererGenericFloatID ,
|
|
|
|
] when
|
|
|
|
+multisample+ get [
|
|
|
|
NSOpenGLPFASupersample ,
|
|
|
|
NSOpenGLPFASampleBuffers , 1 ,
|
|
|
|
NSOpenGLPFASamples , 8 ,
|
|
|
|
] when
|
2007-09-20 18:09:08 -04:00
|
|
|
0 ,
|
|
|
|
] { } make >c-int-array
|
|
|
|
-> initWithAttributes:
|
|
|
|
-> autorelease ;
|
|
|
|
|
|
|
|
: <GLView> ( class dim -- view )
|
|
|
|
>r -> alloc 0 0 r> first2 <NSRect> <PixelFormat>
|
|
|
|
-> initWithFrame:pixelFormat:
|
|
|
|
dup 1 -> setPostsBoundsChangedNotifications:
|
|
|
|
dup 1 -> setPostsFrameChangedNotifications: ;
|
|
|
|
|
|
|
|
: view-dim ( view -- dim )
|
|
|
|
-> bounds
|
|
|
|
dup NSRect-w >fixnum
|
|
|
|
swap NSRect-h >fixnum 2array ;
|
|
|
|
|
|
|
|
: mouse-location ( view event -- loc )
|
|
|
|
over >r
|
|
|
|
-> locationInWindow f -> convertPoint:fromView:
|
|
|
|
dup NSPoint-x swap NSPoint-y
|
|
|
|
r> -> frame NSRect-h swap - 2array ;
|
2008-05-16 10:57:27 -04:00
|
|
|
|
|
|
|
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 ) ;
|
|
|
|
|