]> gitweb.factorcode.org Git - factor.git/blob - core/ui/opengl/utilities.facts
5c7723c9371b7df3d69c62852ab932b16f3f493c
[factor.git] / core / ui / opengl / utilities.facts
1 IN: opengl
2 USING: help io kernel math ;
3
4 HELP: gl-color
5 { $values { "color" "a color specifier" } }
6 { $description "Wrapper for " { $link glColor4d } " taking a color specifier." } ;
7
8 HELP: gl-error
9 { $description "If the most recent OpenGL call resulted in an error, print the error to the " { $link stdio } " stream." } ;
10
11 HELP: do-state
12 { $values { "what" integer } { "quot" quotation } }
13 { $description "Wraps a quotation in " { $link glBegin } "/" { $link glEnd } " calls." } ;
14
15 HELP: do-enabled
16 { $values { "what" integer } { "quot" quotation } }
17 { $description "Wraps a quotation in " { $link glEnable } "/" { $link glDisable } " calls." } ;
18
19 HELP: do-matrix
20 { $values { "mode" { $link GL_MODELVIEW } " or " { $link GL_PROJECTION } } { "quot" quotation } }
21 { $description "Saves and restores the matrix specified by " { $snippet "mode" } " before and after calling the quotation." } ;
22
23 HELP: gl-vertex
24 { $values { "point" "a pair of integers" } }
25 { $description "Wrapper for " { $link glVertex2d } " taking a point object." } ;
26
27 HELP: gl-vertex
28 { $values { "point" "a pair of integers" } }
29 { $description "Wrapper for " { $link glVertex2d } " taking a point object." } ;
30
31 HELP: gl-line
32 { $values { "a" "a pair of integers" } { "b" "a pair of integers" } }
33 { $description "Draws a line between two points." } ;
34
35 HELP: gl-fill-rect
36 { $values { "loc" "a pair of integers" } { "dim" "a pair of integers" } }
37 { $description "Draws a filled rectangle with top-left corner " { $snippet "loc" } " and dimensions " { $snippet "dim" } "." } ;
38
39 HELP: gl-rect
40 { $values { "loc" "a pair of integers" } { "dim" "a pair of integers" } }
41 { $description "Draws the outline of a rectangle with top-left corner " { $snippet "loc" } " and dimensions " { $snippet "dim" } "." } ;
42
43 HELP: gl-fill-poly
44 { $values { "points" "a sequence of pairs of integers" } }
45 { $description "Draws a filled polygon." } ;
46
47 HELP: gl-poly
48 { $values { "points" "a sequence of pairs of integers" } }
49 { $description "Draws the outline of a polygon." } ;
50
51 HELP: gl-gradient
52 { $values { "direction" "one of " { $snippet "{ 0 1 }" } " or " { $snippet "{ 1 0 }" } } { "colors" "a sequence of color specifiers" } { "dim" "a pair of integers" } }
53 { $description "Draws a rectangle with top-left corner " { $snippet "{ 0 0 }" } " and dimensions " { $snippet "dim" } ", filled wit ha smoothly shaded transition between the colors in " { $snippet "colors" } "." } ;
54
55 HELP: gen-texture
56 { $values { "id" integer } }
57 { $description "Wrapper for " { $link glGenTextures } " to handle the common case of generating a single texture ID." } ;
58
59 HELP: save-attribs
60 { $values { "bits" integer } { "quot" quotation } }
61 { $description "Wraps a quotation in " { $link glPushAttrib } "/" { $link glPopAttrib } " calls." } ;
62
63 HELP: sprite
64 { $class-description "A sprite is an OpenGL texture together with a display list which renders a textured quad. Sprites are used to draw text in the UI. Sprites have the following slots:"
65     { $list
66         { { $link sprite-dlist } " - an OpenGL display list ID" }
67         { { $link sprite-texture } " - an OpenGL texture ID" }
68         { { $link sprite-loc } " - top-left corner of the sprite" }
69         { { $link sprite-dim } " - dimensions of the sprite" }
70         { { $link sprite-dim2 } " - dimensions of the sprite, rounded up to the nearest powers of two" }
71     }
72 } ;
73
74 HELP: gray-texture
75 { $values { "sprite" sprite } { "pixmap" "an alien or byte array" } { "id" "an OpenGL texture ID" } }
76 { $description "Creates a new OpenGL texture from a 1 byte per pixel image whose dimensions are equal to " { $link sprite-dim2 } "." } ;
77
78 HELP: gen-dlist
79 { $values { "id" integer } }
80 { $description "Wrapper for " { $link glGenLists } " to handle the common case of generating a single display list ID." } ;
81
82 HELP: make-dlist
83 { $values { "type" "one of " { $link GL_COMPILE } " or " { $link GL_COMPILE_AND_EXECUTE } } { "quot" quotation } { "id" "an OpenGL texture ID" } }
84 { $description "Compiles the results of calling the quotation into a new OpenGL display list." } ;
85
86 HELP: gl-translate
87 { $values { "loc" "a pair of integers" } }
88 { $description "Wrapper for " { $link glTranslated } " taking a point object." } ;
89
90 HELP: free-sprites
91 { $values { "sprites" "a sequence of " { $link sprite } " instances" } }
92 { $description "Deallocates native resources associated toa  sequence of sprites." } ;
93
94 HELP: with-translation
95 { $values { "loc" "a pair of integers" } { "quot" quotation } }
96 { $description "Calls the quotation with a translation by " { $snippet "loc" } " pixels applied to the current " { $link GL_MODELVIEW } " matrix, restoring the matrix when the quotation is done." } ;