2008-02-08 01:43:05 -05:00
|
|
|
USING: alien alien.syntax combinators kernel parser sequences
|
2008-04-05 08:57:40 -04:00
|
|
|
system words namespaces hashtables init math arrays assocs
|
|
|
|
continuations ;
|
2008-04-06 22:07:21 -04:00
|
|
|
IN: opengl.gl.extensions
|
2008-04-02 19:25:33 -04:00
|
|
|
|
|
|
|
ERROR: unknown-gl-platform ;
|
2008-02-08 01:43:05 -05:00
|
|
|
<< {
|
2008-04-02 19:25:33 -04:00
|
|
|
{ [ os windows? ] [ "opengl.gl.windows" ] }
|
|
|
|
{ [ os macosx? ] [ "opengl.gl.macosx" ] }
|
|
|
|
{ [ os unix? ] [ "opengl.gl.unix" ] }
|
2008-04-11 13:56:48 -04:00
|
|
|
[ unknown-gl-platform ]
|
2008-02-08 01:43:05 -05:00
|
|
|
} cond use+ >>
|
|
|
|
|
|
|
|
SYMBOL: +gl-function-number-counter+
|
|
|
|
SYMBOL: +gl-function-pointers+
|
|
|
|
|
|
|
|
: reset-gl-function-number-counter ( -- )
|
|
|
|
0 +gl-function-number-counter+ set-global ;
|
|
|
|
: reset-gl-function-pointers ( -- )
|
|
|
|
100 <hashtable> +gl-function-pointers+ set-global ;
|
|
|
|
|
2008-02-27 20:24:50 -05:00
|
|
|
[ reset-gl-function-pointers ] "opengl.gl" add-init-hook
|
2008-02-08 01:43:05 -05:00
|
|
|
reset-gl-function-pointers
|
|
|
|
reset-gl-function-number-counter
|
|
|
|
|
|
|
|
: gl-function-number ( -- n )
|
|
|
|
+gl-function-number-counter+ get-global
|
|
|
|
dup 1+ +gl-function-number-counter+ set-global ;
|
|
|
|
|
|
|
|
: gl-function-pointer ( names n -- funptr )
|
|
|
|
gl-function-context 2array dup +gl-function-pointers+ get-global at
|
|
|
|
[ 2nip ] [
|
2008-04-05 08:57:40 -04:00
|
|
|
>r [ gl-function-address ] map [ ] find nip
|
2008-02-08 01:43:05 -05:00
|
|
|
dup [ "OpenGL function not available" throw ] unless
|
|
|
|
dup r>
|
|
|
|
+gl-function-pointers+ get-global set-at
|
|
|
|
] if* ;
|
|
|
|
|
|
|
|
: GL-FUNCTION:
|
|
|
|
gl-function-calling-convention
|
|
|
|
scan
|
|
|
|
scan dup
|
2008-03-31 20:18:05 -04:00
|
|
|
scan drop "}" parse-tokens swap prefix
|
2008-02-08 01:43:05 -05:00
|
|
|
gl-function-number
|
|
|
|
[ gl-function-pointer ] 2curry swap
|
|
|
|
";" parse-tokens [ "()" subseq? not ] subset
|
|
|
|
define-indirect
|
|
|
|
; parsing
|