Next: , Previous: , Up: Graphics   [Contents][Index]


2.3.10 Rendering Engine

Chickadee defines rendering using a metaphor familiar to Scheme programmers: procedure application. A shader (see Shaders) is like a procedure for the GPU to apply. Shaders are passed arguments: A vertex array containing the geometry to render (see Buffers) and zero or more keyword arguments that the shader understands. Similar to how Scheme has apply for calling procedures, Chickadee provides gpu-apply for calling shaders.

Additionally, there is some dynamic state that effects how gpu-apply will behave. Things like the current viewport, framebuffer, and blend mode are stored as dynamic state because it would be tedious to have to have to specify them each time gpu-apply is called.

The following procedures and syntax can be found in the (chickadee render) module.

Syntax: gpu-apply shader vertex-array [#:uniform-key uniform-value …]
Syntax: gpu-apply* shader vertex-array count [#:uniform-key uniform-value …]

Render vertex-array using shader with the uniform values specified in the following keyword arguments.

While gpu-apply will draw every vertex in vertex-array, gpu-apply* will only draw count vertices.

Syntax: gpu-apply/instanced shader vertex-array n [#:uniform-key uniform-value …]
Syntax: gpu-apply/instanced shader vertex-array count n [#:uniform-key uniform-value …]

Render vertex-array n times using shader with the uniform values specified in the following keyword arguments.

Instanced rendering is very beneficial for rendering the same object many times with only small differences for each one. For example, the particle effects described in Particles use instanced rendering.

While gpu-apply/instanced will draw every vertex in vertex-array, gpu-apply* will only draw count vertices.

Procedure: current-viewport

Return the currently bound viewport (see Viewports).

Procedure: current-framebuffer

Return the currently bound framebuffer (see Framebuffers).

Procedure: current-blend-mode

Return the currently bound blend mode (see Blending).

Procedure: current-depth-test

Return #t if depth testing is currently enabled (see Blending).

Procedure: current-texture

Return the currently bound texture (see Textures).

Procedure: current-projection

Return the currently bound projection matrix (see Matrices).

Syntax: with-viewport viewport body …

Evaluate body with the current viewport bound to viewport (see Viewports).

Syntax: with-framebuffer framebuffer body …

Evaluate body with the current framebuffer bound to framebuffer (see Framebuffers).

Syntax: with-blend-mode blend-mode body …

Evaluate body with the current blend mode bound to blend-mode (see Blending).

Syntax: with-depth-test depth-test? body …

Evaluate body with the depth-test disabled if depth-test? is #f, or enabled otherwise (see Blending).

Syntax: with-texture texture body …

Evaluate body with the current texture bound to texture (see Textures).

Syntax: with-projection projection body …

Evaluate body with the current projection matrix bound to projection (see Matrices).


Next: , Previous: , Up: Graphics   [Contents][Index]