]> gitweb.factorcode.org Git - factor.git/blob - basis/opengl/annotations/annotations.factor
Missed yet more renames
[factor.git] / basis / opengl / annotations / annotations.factor
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 ;
6 IN: opengl.annotations
7
8 TUPLE: gl-error-log
9     { function word initial: t }
10     { error gl-error }
11     { timestamp timestamp } ;
12
13 gl-error-log [ V{ } clone ] initialize
14
15 : <gl-error-log> ( function code -- gl-error-log )
16     [ dup ] dip <gl-error> now gl-error-log boa ;
17
18 : log-gl-error ( function -- )
19     gl-error-code [ <gl-error-log> gl-error-log get push ] [ drop ] if* ;
20
21 : clear-gl-error-log ( -- )
22     V{ } clone gl-error-log set ;
23
24 : gl-function? ( word -- ? )
25     name>> { [ "glGetError" = not ] [ "gl" head? ] [ third LETTER? ] } 1&& ;
26
27 : gl-functions ( -- words )
28     "opengl.gl" lookup-vocab words [ gl-function? ] filter ;
29
30 : annotate-gl-functions ( quot -- )
31     [
32         [ gl-functions ] dip [ [ dup ] dip curry (annotate) ] curry each
33     ] with-compilation-unit ;
34
35 : reset-gl-functions ( -- )
36     [ gl-functions [ (reset) ] each ] with-compilation-unit ;
37
38 : throw-gl-errors ( -- )
39     [ '[ @ _ (gl-error) ] ] annotate-gl-functions ;
40
41 : log-gl-errors ( -- )
42     [ '[ @ _ log-gl-error ] ] annotate-gl-functions ;