]> gitweb.factorcode.org Git - factor.git/blob - extra/gpu/state/state-docs.factor
238451757a666d43032a946f281061b08be53d0b
[factor.git] / extra / gpu / state / state-docs.factor
1 ! (c)2009 Joe Groff bsd license
2 USING: help.markup help.syntax kernel math math.rectangles
3 sequences ;
4 IN: gpu.state
5
6 HELP: <blend-mode>
7 { $values
8     { "equation" blend-equation } { "source-function" blend-function } { "dest-function" blend-function }
9     { "blend-mode" blend-mode }
10 }
11 { $description "Constructs a " { $link blend-mode } " tuple." } ;
12
13 { blend-mode <blend-mode> } related-words
14
15 HELP: <blend-state>
16 { $values
17     { "constant-color" sequence } { "rgb-mode" { $maybe blend-mode } } { "alpha-mode" { $maybe blend-mode } }
18     { "blend-state" blend-state }
19 }
20 { $description "Constructs a " { $link blend-state } " tuple." } ;
21
22 { blend-state <blend-state> get-blend-state } related-words
23
24 HELP: <depth-range-state>
25 { $values
26     { "near" float } { "far" float }
27     { "depth-range-state" depth-range-state }
28 }
29 { $description "Constructs a " { $link depth-range-state } " tuple." } ;
30
31 { depth-range-state <depth-range-state> get-depth-range-state } related-words
32
33 HELP: <depth-state>
34 { $values
35     { "comparison" comparison }
36     { "depth-state" depth-state }
37 }
38 { $description "Constructs a " { $link depth-state } " tuple." } ;
39
40 { depth-state <depth-state> get-depth-state } related-words
41
42 HELP: <line-state>
43 { $values
44     { "width" float } { "antialias?" boolean }
45     { "line-state" line-state }
46 }
47 { $description "Constructs a " { $link line-state } " tuple." } ;
48
49 { line-state <line-state> get-line-state } related-words
50
51 HELP: <mask-state>
52 { $values
53     { "color" sequence } { "depth" boolean } { "stencil-front" boolean } { "stencil-back" boolean }
54     { "mask-state" mask-state }
55 }
56 { $description "Constructs a " { $link mask-state } " tuple." } ;
57
58 { mask-state <mask-state> get-mask-state } related-words
59
60 HELP: <multisample-state>
61 { $values
62     { "multisample?" boolean  } { "sample-alpha-to-coverage?" boolean } { "sample-alpha-to-one?" boolean } { "sample-coverage" { $maybe float } } { "invert-sample-coverage?" boolean }
63     { "multisample-state" multisample-state }
64 }
65 { $description "Constructs a " { $link multisample-state } " tuple." } ;
66
67 { multisample-state <multisample-state> get-multisample-state } related-words
68
69 HELP: <point-state>
70 { $values
71     { "size" { $maybe float } } { "sprite-origin" point-sprite-origin } { "fade-threshold" float }
72     { "point-state" point-state }
73 }
74 { $description "Constructs a " { $link point-state } " tuple." } ;
75
76 { point-state <point-state> get-point-state } related-words
77
78 HELP: <scissor-state>
79 { $values
80     { "rect" { $maybe rect } }
81     { "scissor-state" scissor-state }
82 }
83 { $description "Constructs a " { $link scissor-state } " tuple." } ;
84
85 { scissor-state <scissor-state> get-scissor-state } related-words
86
87 HELP: <stencil-mode>
88 { $values
89     { "value" integer } { "mask" integer } { "comparison" comparison } { "stencil-fail-op" stencil-op } { "depth-fail-op" stencil-op } { "depth-pass-op" stencil-op }
90     { "stencil-mode" stencil-mode }
91 }
92 { $description "Constructs a " { $link stencil-mode } " tuple." } ;
93
94 { stencil-mode <stencil-mode> } related-words
95
96 HELP: <stencil-state>
97 { $values
98     { "front-mode" { $maybe stencil-mode } } { "back-mode" { $maybe stencil-mode } }
99     { "stencil-state" stencil-state }
100 }
101 { $description "Constructs a " { $link stencil-state } " tuple." } ;
102
103 { stencil-state <stencil-state> get-stencil-state } related-words
104
105 HELP: <triangle-cull-state>
106 { $values
107     { "front-face" triangle-face } { "cull" { $maybe triangle-cull } }
108     { "triangle-cull-state" triangle-cull-state }
109 }
110 { $description "Constructs a " { $link triangle-cull-state } " tuple." } ;
111
112 { triangle-cull-state <triangle-cull-state> get-triangle-cull-state } related-words
113
114 HELP: <triangle-state>
115 { $values
116     { "front-mode" triangle-mode } { "back-mode" triangle-mode } { "antialias?" boolean }
117     { "triangle-state" triangle-state }
118 }
119 { $description "Constructs a " { $link triangle-state } " tuple." } ;
120
121 { triangle-state <triangle-state> get-triangle-state } related-words
122
123 HELP: <viewport-state>
124 { $values
125     { "rect" rect }
126     { "viewport-state" viewport-state }
127 }
128 { $description "Constructs a " { $link viewport-state } " tuple." } ;
129
130 { viewport-state <viewport-state> get-viewport-state } related-words
131
132 HELP: blend-equation
133 { $class-description "The " { $snippet "blend-equation" } " of a " { $link blend-mode } " determines how the source and destination color values are combined after they have been multiplied by the result of their respective " { $link blend-function } "s."
134 { $list
135 { { $link eq-add } " indicates that the source and destination results are added." }
136 { { $link eq-subtract } " indicates that the destination result is subtracted from the source." }
137 { { $link eq-reverse-subtract } " indicates that the source result is subtracted from the destination." }
138 { { $link eq-min } " indicates that the componentwise minimum of the source and destination results is taken." }
139 { { $link eq-max } " indicates that the componentwise maximum of the source and destination results is taken." }
140 } } ;
141
142 HELP: blend-function
143 { $class-description "The " { $snippet "blend-function" } "s of a " { $link blend-mode } " multiply the source and destination colors being blended by a function of their values before they are combined by the " { $link blend-equation } "."
144 { $list
145     { { $link func-zero } " returns a constant factor of zero." }
146     { { $link func-one } " returns a constant factor of one." }
147     { { $link func-source } " returns the corresponding source color component for every result component." }
148     { { $link func-one-minus-source } " returns one minus the corresponding source color component for every result component." }
149     { { $link func-dest } " returns the corresponding destination color component for every result component." }
150     { { $link func-one-minus-dest } " returns one minus the corresponding destination color component for every result component." }
151     { { $link func-constant } " returns the corresponding component of the current " { $link blend-state } "'s " { $snippet "constant-color" } " for every result component." }
152     { { $link func-one-minus-constant } " returns one minus the corresponding component of the current " { $link blend-state } "'s " { $snippet "constant-color" } " for every result component." }
153     { { $link func-source-alpha } " returns the source alpha component for every result component." }
154     { { $link func-one-minus-source-alpha } " returns one minus the source alpha component for every result component." }
155     { { $link func-dest-alpha } " returns the destination alpha component for every result component." }
156     { { $link func-one-minus-dest-alpha } " returns one minus the destination alpha component for every result component." }
157     { { $link func-constant-alpha } " returns the alpha component of the current " { $link blend-state } "'s " { $snippet "constant-color" } " for every result component." }
158     { { $link func-one-minus-constant-alpha } " returns one minus the alpha component of the current " { $link blend-state } "'s " { $snippet "constant-color" } " for every result component." }
159 } } ;
160
161 HELP: blend-mode
162 { $class-description "A " { $link blend-mode } " is specified as part of the " { $link blend-state } " to determine the blending equation used between the source (incoming fragment) and destination (existing framebuffer value) colors of blended pixels."
163 { $list
164 { "The " { $snippet "equation" } " slot determines how the source and destination colors are combined after the " { $snippet "source-function" } " and " { $snippet "dest-function" } " have been applied."
165     { $list
166     { { $link eq-add } " indicates that the source and destination results are added." }
167     { { $link eq-subtract } " indicates that the destination result is subtracted from the source." }
168     { { $link eq-reverse-subtract } " indicates that the source result is subtracted from the destination." }
169     { { $link eq-min } " indicates that the componentwise minimum of the source and destination results is taken." }
170     { { $link eq-max } " indicates that the componentwise maximum of the source and destination results is taken." }
171     }
172 }
173 { "The " { $snippet "source-function" } " and " { $snippet "dest-function" } " slots each specify a function to apply to the source, destination, or constant color values to generate a blending factor that is multiplied respectively against the source or destination value before feeding the results to the " { $snippet "equation" } "."
174 }
175     { $list
176     { { $link func-zero } " returns a constant factor of zero." }
177     { { $link func-one } " returns a constant factor of one." }
178     { { $link func-source } " returns the corresponding source color component for every result component." }
179     { { $link func-one-minus-source } " returns one minus the corresponding source color component for every result component." }
180     { { $link func-dest } " returns the corresponding destination color component for every result component." }
181     { { $link func-one-minus-dest } " returns one minus the corresponding destination color component for every result component." }
182     { { $link func-constant } " returns the corresponding component of the current " { $link blend-state } "'s " { $snippet "constant-color" } " for every result component." }
183     { { $link func-one-minus-constant } " returns one minus the corresponding component of the current " { $link blend-state } "'s " { $snippet "constant-color" } " for every result component." }
184     { { $link func-source-alpha } " returns the source alpha component for every result component." }
185     { { $link func-one-minus-source-alpha } " returns one minus the source alpha component for every result component." }
186     { { $link func-dest-alpha } " returns the destination alpha component for every result component." }
187     { { $link func-one-minus-dest-alpha } " returns one minus the destination alpha component for every result component." }
188     { { $link func-constant-alpha } " returns the alpha component of the current " { $link blend-state } "'s " { $snippet "constant-color" } " for every result component." }
189     { { $link func-one-minus-constant-alpha } " returns one minus the alpha component of the current " { $link blend-state } "'s " { $snippet "constant-color" } " for every result component." }
190 }
191 "A typical transparency effect will use the values:"
192 { $code """T{ blend-mode
193     { equation eq-add }
194     { source-function func-source-alpha }
195     { dest-function func-one-minus-source-alpha }
196 }""" }
197 } } ;
198
199 HELP: blend-state
200 { $class-description "The " { $snippet "blend-state" } " controls how alpha blending between the current framebuffer contents and newly drawn pixels."
201 { $list
202 { "The " { $snippet "constant-color" } " slot contains an optional four-" { $link float } " sequence that specifies a constant parameter to the " { $snippet "func-*constant*" } " " { $link blend-function } "s. If constant blend functions are not used, the slot can be " { $link f } "." }
203 { "The " { $snippet "rgb-mode" } " and " { $snippet "alpha-mode" } " slots both contain " { $link blend-mode } " values that determine the blending equation used between RGB and alpha channel values, respectively. If both slots are " { $link f } ", blending is disabled." }
204 } } ;
205
206 HELP: cmp-always
207 { $class-description "This " { $link comparison } " test always succeeds." } ;
208
209 HELP: cmp-equal
210 { $class-description "This " { $link comparison } " test succeeds if the compared values are equal." } ;
211
212 HELP: cmp-greater
213 { $class-description "This " { $link comparison } " test succeeds if the incoming value is greater than the buffer value." } ;
214
215 HELP: cmp-greater-equal
216 { $class-description "This " { $link comparison } " test succeeds if the incoming value is greater than or equal to the buffer value." } ;
217
218 HELP: cmp-less
219 { $class-description "This " { $link comparison } " test succeeds if the incoming value is less than the buffer value." } ;
220
221 HELP: cmp-less-equal
222 { $class-description "This " { $link comparison } " test succeeds if the incoming value is less than or equal to the buffer value." } ;
223
224 HELP: cmp-never
225 { $class-description "This " { $link comparison } " test always fails." } ;
226
227 HELP: cmp-not-equal
228 { $class-description "This " { $link comparison } " test succeeds if the compared values are not equal." } ;
229
230 HELP: comparison
231 { $class-description { $snippet "comparison" } " values are used in the " { $link stencil-state } " and " { $link depth-state } " and control how the fragment stencil and depth tests are performed. For the stencil test, a reference value (the " { $snippet "value" } " slot of the active " { $link stencil-mode } ") is compared to the stencil buffer value using the comparison operator. For the depth test, the incoming fragment depth is compared to the depth buffer value."
232 { $list
233 { { $link cmp-always } " always succeeds." }
234 { { $link cmp-never } " always fails." }
235 { { $link cmp-equal } " succeeds if the compared values are equal." }
236 { { $link cmp-not-equal } " succeeds if the compared values are not equal." }
237 { { $link cmp-less } " succeeds if the incoming value is less than the buffer value." }
238 { { $link cmp-less-equal } " succeeds if the incoming value is less than or equal to the buffer value." }
239 { { $link cmp-greater } " succeeds if the incoming value is greater than the buffer value." }
240 { { $link cmp-greater-equal } " succeeds if the incoming value is greater than or equal to the buffer value." }
241 } } ;
242
243 HELP: cull-all
244 { $class-description "This " { $link triangle-cull } " value culls all triangles." } ;
245
246 HELP: cull-back
247 { $class-description "This " { $link triangle-cull } " value culls back-facing triangles." } ;
248
249 HELP: cull-front
250 { $class-description "This " { $link triangle-cull } " value culls front-facing triangles." } ;
251
252 HELP: depth-range-state
253 { $class-description "The " { $snippet "depth-range-state" } " controls the range of depth values that are generated for fragments and used for depth testing and writing to the depth buffer."
254 { $list
255 { "The " { $snippet "near" } " slot contains a " { $link float } " value that will be assigned to fragments on the near plane. The default value is " { $snippet "0.0" } "." }
256 { "The " { $snippet "far" } " slot contains a " { $link float } " value that will be assigned to fragments on the far plane. The default value is " { $snippet "1.0" } "." }
257 } } ;
258
259 HELP: depth-state
260 { $class-description "The " { $snippet "depth-state" } " controls how incoming fragments' depth values are tested against the depth buffer. The " { $link comparison } " slot, if not " { $link f } ", determines the condition that must be true between the incoming fragment depth and depth buffer depth to pass a fragment. If the " { $snippet "comparison" } " is " { $link f } ", depth testing is disabled and all fragments pass. " { $link cmp-less } " is typically used for depth culling." } ;
261
262 HELP: eq-add
263 { $var-description "This " { $link blend-equation } " adds the source and destination colors together." } ;
264
265 HELP: eq-max
266 { $var-description "This " { $link blend-equation } " takes the componentwise maximum of the source and destination colors." } ;
267
268 HELP: eq-min
269 { $var-description "This " { $link blend-equation } " takes the componentwise minimum of the source and destination colors." } ;
270
271 HELP: eq-reverse-subtract
272 { $var-description "This " { $link blend-equation } " subtracts the source color from the destination color." } ;
273
274 HELP: eq-subtract
275 { $var-description "This " { $link blend-equation } " subtracts the destination color from the source color." } ;
276
277 HELP: face-ccw
278 { $class-description "This " { $link triangle-face } " value refers to the face with counterclockwise-wound vertices." } ;
279
280 HELP: face-cw
281 { $class-description "This " { $link triangle-face } " value refers to the face with clockwise-wound vertices." } ;
282
283 HELP: func-constant
284 { $class-description "This " { $link blend-function } " componentwise multiplies the input color by the current " { $link blend-state } "'s " { "constant-color" } " slot value." } ;
285
286 HELP: func-constant-alpha
287 { $class-description "This " { $link blend-function } " multiplies the input color by the alpha component of the current " { $link blend-state } "'s " { "constant-color" } " slot value." } ;
288
289 HELP: func-dest
290 { $class-description "This " { $link blend-function } " componentwise multiplies the input color by the destination color value." } ;
291
292 HELP: func-dest-alpha
293 { $class-description "This " { $link blend-function } " componentwise multiplies the input color by the alpha component of the destination color value." } ;
294
295 HELP: func-one
296 { $class-description "This " { $link blend-function } " multiplies the input color by one; that is, the input color is unchanged." } ;
297
298 HELP: func-one-minus-constant
299 { $class-description "This " { $link blend-function } " componentwise multiplies the input color by one minus the current " { $link blend-state } "'s " { "constant-color" } " slot value." } ;
300
301 HELP: func-one-minus-constant-alpha
302 { $class-description "This " { $link blend-function } " multiplies the input color by one minus the alpha component of the current " { $link blend-state } "'s " { "constant-color" } " slot value." } ;
303
304 HELP: func-one-minus-dest
305 { $class-description "This " { $link blend-function } " componentwise multiplies the input color by one minus the destination color value." } ;
306
307 HELP: func-one-minus-dest-alpha
308 { $class-description "This " { $link blend-function } " multiplies the input color by one minus the alpha component of the destination color value." } ;
309
310 HELP: func-one-minus-source
311 { $class-description "This " { $link blend-function } " componentwise multiplies the input color by one minus the source color value." } ;
312
313 HELP: func-one-minus-source-alpha
314 { $class-description "This " { $link blend-function } " multiplies the input color by one minus the alpha component source color value." } ;
315
316 HELP: func-source
317 { $class-description "This " { $link blend-function } " componentwise multiplies the input color by the source color value." } ;
318
319 HELP: func-source-alpha
320 { $class-description "This " { $link blend-function } " multiplies the input color by the alpha component of the source color value." } ;
321
322 HELP: func-source-alpha-saturate
323 { $class-description "This " { $link blend-function } " multiplies the input color by the minimum of the alpha component of the source color value and one minus the alpha component of the destination color value. It is only valid as the " { $snippet "source-function" } " of a " { $link blend-mode } "." } ;
324
325 HELP: func-zero
326 { $class-description "This " { $link blend-function } " multiplies the input color by zero." } ;
327
328 HELP: get-blend-state
329 { $values
330     
331     { "blend-state" blend-state }
332 }
333 { $description "Retrieves the current GPU " { $link blend-state } "." } ;
334
335 HELP: get-depth-range-state
336 { $values
337     
338     { "depth-range-state" depth-range-state }
339 }
340 { $description "Retrieves the current GPU " { $link depth-range-state } "." } ;
341
342 HELP: get-depth-state
343 { $values
344     
345     { "depth-state" depth-state }
346 }
347 { $description "Retrieves the current GPU " { $link depth-state } "." } ;
348
349 HELP: get-line-state
350 { $values
351     
352     { "line-state" line-state }
353 }
354 { $description "Retrieves the current GPU " { $link line-state } "." } ;
355
356 HELP: get-mask-state
357 { $values
358     
359     { "mask-state" mask-state }
360 }
361 { $description "Retrieves the current GPU " { $link mask-state } "." } ;
362
363 HELP: get-multisample-state
364 { $values
365     
366     { "multisample-state" multisample-state }
367 }
368 { $description "Retrieves the current GPU " { $link multisample-state } "." } ;
369
370 HELP: get-point-state
371 { $values
372     
373     { "point-state" point-state }
374 }
375 { $description "Retrieves the current GPU " { $link point-state } "." } ;
376
377 HELP: get-scissor-state
378 { $values
379     
380     { "scissor-state" scissor-state }
381 }
382 { $description "Retrieves the current GPU " { $link scissor-state } "." } ;
383
384 HELP: get-stencil-state
385 { $values
386     
387     { "stencil-state" stencil-state }
388 }
389 { $description "Retrieves the current GPU " { $link stencil-state } "." } ;
390
391 HELP: get-triangle-cull-state
392 { $values
393     
394     { "triangle-cull-state" triangle-cull-state }
395 }
396 { $description "Retrieves the current GPU " { $link triangle-cull-state } "." } ;
397
398 HELP: get-triangle-state
399 { $values
400     
401     { "triangle-state" triangle-state }
402 }
403 { $description "Retrieves the current GPU " { $link triangle-state } "." } ;
404
405 HELP: get-viewport-state
406 { $values
407     
408     { "viewport-state" viewport-state }
409 }
410 { $description "Retrieves the current GPU " { $link viewport-state } "." } ;
411
412 HELP: gpu-state
413 { $class-description "This class is a union of all the GPU state tuple classes that can be passed to " { $link set-gpu-state } ":"
414 { $list
415 { { $link viewport-state } }
416 { { $link scissor-state } }
417 { { $link multisample-state } }
418 { { $link stencil-state } }
419 { { $link depth-range-state } }
420 { { $link depth-state } }
421 { { $link blend-state } }
422 { { $link mask-state } }
423 { { $link triangle-cull-state } }
424 { { $link triangle-state } }
425 { { $link point-state } }
426 { { $link line-state } }
427 } } ;
428
429 HELP: line-state
430 { $class-description "The " { $snippet "line-state" } " controls how lines are rendered."
431 { $list
432 { "The " { $snippet "width" } " slot is a " { $link float } " value specifying the line width in pixels." }
433 { "The " { $snippet "antialias?" } " slot is a " { $link boolean } " value specifying whether line edges should be smoothed." }
434 }
435 } ;
436
437 HELP: mask-state
438 { $class-description "The " { $snippet "mask-state" } " controls what parts of the framebuffer are written to."
439 { $list
440 { "The " { $snippet "color" } " slot is a sequence of four " { $link boolean } " values specifying whether the red, green, blue, and alpha channels of the color buffer will be written to." }
441 { "The " { $snippet "depth" } " slot is a " { $link boolean } " value specifying whether the depth buffer will be written to." }
442 { "The " { $snippet "stencil-front" } " and " { $snippet "stencil-back" } " slots are " { $link integer } " values that indicate which bits of the stencil buffer will be written to for front- and back-facing triangles, respectively." }
443 } } ;
444
445 HELP: multisample-state
446 { $class-description "The " { $snippet "multisample-state" } " controls whether and how multisampling occurs."
447 { $list
448 { "The " { $snippet "multisample?" } " slot is a " { $link boolean } " value that determines whether multisampling is enabled." }
449 { "The " { $snippet "sample-alpha-to-coverage?" } " slot is a " { $link boolean } " value that determines whether sample coverage values are determined from their alpha components." }
450 { "The " { $snippet "sample-alpha-to-one?" } " slot is a " { $link boolean } " value that determines whether a sample's alpha value is replaced with one after its alpha-based coverage is calculated." }
451 { "The " { $snippet "sample-coverage" } " slot is an optional " { $link float } " value that is used to calculate another coverage value that is then combined with the alpha-based coverage. If " { $link f } ", the alpha-based coverage is untouched." }
452 { "The " { $snippet "invert-sample-coverage?" } " slot is a " { $link boolean } " value that, if true, indicates that the coverage value derived from " { $snippet "sample-coverage" } " should be inverted before being combined." }
453 } } ;
454
455 HELP: op-dec-sat
456 { $class-description "This " { $link stencil-op } " subtracts one from the stencil buffer value, leaving it unchanged if it is already zero." } ;
457
458 HELP: op-dec-wrap
459 { $class-description "This " { $link stencil-op } " subtracts one from the stencil buffer value, wrapping the value to the maximum storable value if it was zero." } ;
460
461 HELP: op-inc-sat
462 { $class-description "This " { $link stencil-op } " adds one to the stencil buffer value, leaving it unchanged if it is already the maximum storable value." } ;
463
464 HELP: op-inc-wrap
465 { $class-description "This " { $link stencil-op } " adds one to the stencil buffer value, wrapping the value to zero if it was the maximum storable value." } ;
466
467 HELP: op-invert
468 { $class-description "This " { $link stencil-op } " bitwise NOTs the stencil buffer value." } ;
469
470 HELP: op-keep
471 { $class-description "This " { $link stencil-op } " leaves the stencil buffer value unchanged." } ;
472
473 HELP: op-replace
474 { $class-description "This " { $link stencil-op } " sets the stencil buffer value to the reference " { $snippet "value" } "." } ;
475
476 HELP: op-zero
477 { $class-description "This " { $link stencil-op } " sets the stencil buffer value to zero." } ;
478
479 HELP: origin-lower-left
480 { "This " { $link point-sprite-origin } " value sets the point sprite coordinate origin to the lower left corner of the point and increases the Y coordinate upward." } ;
481
482 HELP: origin-upper-left
483 { "This " { $link point-sprite-origin } " value sets the point sprite coordinate origin to the upper left corner of the point and increases the Y coordinate downward." } ;
484
485 HELP: point-sprite-origin
486 { $class-description "The " { $snippet "point-sprite-origin" } " is set as part of the " { $link point-state } " and determines how point sprite coordinates are generated over the rendered area of a point."
487 { $list
488 { { $link origin-lower-left } " sets the coordinate origin to the lower left corner of the point and increases the Y coordinate upward." }
489 { { $link origin-upper-left } " sets the coordinate origin to the upper left corner of the point and increases the Y coordinate downward." }
490 } } ;
491
492 HELP: point-state
493 { $class-description "The " { $snippet "point-state" } " controls how points are drawn."
494 { $list
495 { "The " { $snippet "size" } " slot contains either a " { $link float } " value specifying a constant pixel radius for all points drawn, or " { $link f } ", in which case the vertex shader determines the size of each point independently." }
496 { "The " { $snippet "sprite-origin" } " slot contains either " { $link origin-lower-left } " or " { $link origin-upper-left } ", and determines whether the vertical point sprite coordinates fed to the fragment shader start at zero in the bottom corner and increase upward or start at zero in the upper corner and increase downward." }
497 { "If multisampling is enabled in the " { $link multisample-state } ", the " { $snippet "fade-threshold" } " slot specifies a pixel width at which the multisampling implementation may fade the alpha component of point fragments." }
498 } } ;
499
500 HELP: scissor-state
501 { $class-description "The " { $snippet "scissor-state" } " allows rendering output to be clipped to a rectangular region of the framebuffer. If the " { $snippet "rect" } " slot is set to a " { $link rect } " value, fragments outside that rectangle will be discarded. If it is " { $link f } ", fragments are allowed anywhere on the framebuffer." } ;
502
503 HELP: set-gpu-state
504 { $values
505     { "states" "a " { $link sequence } " or " { $link gpu-state } }
506 }
507 { $description "Changes the GPU state using the values passed in " { $snippet "states" } "." } ;
508
509 HELP: set-gpu-state*
510 { $values
511     { "state" gpu-state }
512 }
513 { $description "Changes the GPU state using a single " { $link gpu-state } " value." } ;
514
515 HELP: stencil-mode
516 { $class-description "A " { $snippet "stencil-mode" } " is specified as part of the " { $link stencil-state } " to define the interaction between an incoming fragment and the stencil buffer."
517 { $list
518 { "The " { $snippet "value" } " slot contains an " { $link integer } " value that is used as the reference value for the " { $snippet "comparison" } " of the stencil test." }
519 { "The " { $snippet "mask" } " slot contains an " { $link integer } " mask value that indicates which bits are relevant to the stencil test." }
520 { "The " { $snippet "comparison" } " slot contains a " { $link comparison } " value that indicates the comparison taken between the masked reference value and stored stencil buffer value to determine whether the fragment is allowed to pass." }
521 { "The " { $snippet "stencil-fail-op" } ", " { $snippet "depth-fail-op" } ", and " { $snippet "depth-pass-op" } " slots all contain " { $link stencil-op } " values that determine how the value in the stencil buffer is affected when the stencil test fails, the stencil test succeeds but depth test fails, and both stencil and depth tests succeed, respectively."
522     { $list
523     { { $link op-keep } " leaves the stencil buffer value unchanged." }
524     { { $link op-zero } " sets the stencil buffer value to zero." }
525     { { $link op-replace } " sets the stencil buffer value to the reference " { $snippet "value" } "." }
526     { { $link op-invert } " bitwise NOTs the stencil buffer value." }
527     { { $link op-inc-sat } " adds one to the stencil buffer value, leaving it unchanged if it is already the maximum storable value." }
528     { { $link op-dec-sat } " subtracts one from the stencil buffer value, leaving it unchanged if it is already zero." }
529     { { $link op-inc-wrap } " adds one to the stencil buffer value, wrapping the value to zero if it was the maximum storable value." }
530     { { $link op-dec-wrap } " subtracts one from the stencil buffer value, wrapping the value to the maximum storable value if it was zero." }
531     }
532 }
533 } } ;
534
535 HELP: stencil-op
536 { $class-description { $snippet "stencil-op" } "s are set as part of a " { $link stencil-mode } " and determine how the stencil buffer is modified by incoming fragments."
537 { $list
538 { { $link op-keep } " leaves the stencil buffer value unchanged." }
539 { { $link op-zero } " sets the stencil buffer value to zero." }
540 { { $link op-replace } " sets the stencil buffer value to the reference " { $snippet "value" } "." }
541 { { $link op-invert } " bitwise NOTs the stencil buffer value." }
542 { { $link op-inc-sat } " adds one to the stencil buffer value, leaving it unchanged if it is already the maximum storable value." }
543 { { $link op-dec-sat } " subtracts one from the stencil buffer value, leaving it unchanged if it is already zero." }
544 { { $link op-inc-wrap } " adds one to the stencil buffer value, wrapping the value to zero if it was the maximum storable value." }
545 { { $link op-dec-wrap } " subtracts one from the stencil buffer value, wrapping the value to the maximum storable value if it was zero." }
546 } } ;
547
548 HELP: stencil-state
549 { $class-description "The " { $snippet "stencil-state" } " controls how incoming fragments interact with the stencil buffer. The " { $snippet "front-mode" } " and " { $snippet "back-mode" } " slots are both " { $link stencil-mode } " tuples that define the stencil buffer interaction for front- and back-facing triangle fragments, respectively. If both slots are " { $link f } ", stencil testing is disabled." } ;
550
551 HELP: triangle-cull
552 { $class-description "The " { $snippet "cull" } " slot of the " { $link triangle-cull-state } " determines which triangle faces are culled, if any."
553 { $list
554 { { $link cull-all } " culls all triangles." }
555 { { $link cull-front } " culls front-facing triangles." } 
556 { { $link cull-back } " culls back-facing triangles." } 
557 } } ;
558
559 HELP: triangle-cull-state
560 { $class-description "The " { $snippet "triangle-cull-state" } " controls what faces of triangles are rasterized."
561 { $list
562 { "The " { $snippet "front-face" } " slot determines which vertex winding order is considered the front face of a triangle: " { $link face-ccw } " or " { $link face-cw } "." }
563 { "The " { $snippet "cull" } " slot determines which triangle faces are discarded: " { $link cull-front } ", " { $link cull-back } ", " { $link cull-all } ", or " { $link f } " to disable triangle culling." }
564 } } ;
565
566 HELP: triangle-face
567 { $class-description "A " { $snippet "triangle-face" } " value names a vertex winding order for triangles."
568 { $list
569 { { $link face-ccw } " indicates counterclockwise winding." }
570 { { $link face-cw } " indicates clockwise winding." }
571 } } ;
572
573 HELP: triangle-fill
574 { $class-description "This " { $link triangle-mode } " fills the entire surface of triangles." } ;
575
576 HELP: triangle-lines
577 { $class-description "This " { $link triangle-mode } " renders lines across the edges of triangles." } ;
578
579 HELP: triangle-mode
580 { $class-description "The " { $snippet "triangle-mode" } " is set as part of the " { $link triangle-state } " to determine how triangles are rendered."
581 { $list
582 { { $link triangle-points } " renders the vertices of triangles as if they were points." }
583 { { $link triangle-lines } " renders lines across the edges of triangles." }
584 { { $link triangle-fill } ", the default, fills the entire surface of triangles." }
585 } } ;
586
587 HELP: triangle-points
588 { $class-description "This " { $link triangle-mode } " renders the vertices of triangles as if they were points." } ;
589
590 HELP: triangle-state
591 { $class-description "The " { $snippet "triangle-state" } " controls how triangles are rasterized."
592 { $list
593 { "The " { $snippet "front-mode" } " and " { $snippet "back-mode" } " slots determine how a front- or back-facing triangle is rendered."
594     { $list
595     { { $link triangle-points } " renders the vertices of triangles as if they were points." }
596     { { $link triangle-lines } " renders lines across the edges of triangles." }
597     { { $link triangle-fill } ", the default, fills the entire surface of triangles." }
598     }
599 }
600 { "The " { $snippet "antialias?" } " slot contains a " { $link boolean } " value that decides whether the edges of triangles should be smoothed." }
601 } } ;
602
603 HELP: viewport-state
604 { $class-description "The " { $snippet "viewport-state" } " controls the rectangular region of the framebuffer to which window-space coordinates are mapped. Window-space vertices are mapped from the rectangle <-1.0, -1.0>­<1.0, 1.0> to the rectangular region specified by the " { $snippet "rect" } " slot." } ;
605
606 ARTICLE: "gpu.state" "GPU state"
607 "The " { $vocab-link "gpu.state" } " vocabulary provides words for querying and setting GPU state."
608 { $subsections set-gpu-state }
609 "The following state tuples are available:"
610 { $subsections
611     viewport-state
612     scissor-state
613     multisample-state
614     stencil-state
615     depth-range-state
616     depth-state
617     blend-state
618     mask-state
619     triangle-cull-state
620     triangle-state
621     point-state
622     line-state
623 } ;
624
625 ABOUT: "gpu.state"