1 ! Copyright (C) 2009 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel namespaces combinators.short-circuit vocabs sequences
4 compiler.units tools.annotations tools.annotations.private fry words
5 opengl calendar accessors ascii ;
9 { function word initial: t }
11 { timestamp timestamp } ;
13 gl-error-log [ V{ } clone ] initialize
15 : <gl-error-log> ( function code -- gl-error-log )
16 [ dup ] dip <gl-error> now gl-error-log boa ;
18 : log-gl-error ( function -- )
19 gl-error-code [ <gl-error-log> gl-error-log get push ] [ drop ] if* ;
21 : clear-gl-error-log ( -- )
22 V{ } clone gl-error-log set ;
24 : gl-function? ( word -- ? )
25 name>> { [ "glGetError" = not ] [ "gl" head? ] [ third LETTER? ] } 1&& ;
27 : gl-functions ( -- words )
28 "opengl.gl" lookup-vocab words [ gl-function? ] filter ;
30 : annotate-gl-functions ( quot -- )
32 [ gl-functions ] dip [ [ dup ] dip curry (annotate) ] curry each
33 ] with-compilation-unit ;
35 : reset-gl-functions ( -- )
36 [ gl-functions [ (reset) ] each ] with-compilation-unit ;
38 : throw-gl-errors ( -- )
39 [ '[ @ _ (gl-error) ] ] annotate-gl-functions ;
41 : log-gl-errors ( -- )
42 [ '[ @ _ log-gl-error ] ] annotate-gl-functions ;