summaryrefslogtreecommitdiff
path: root/manuals/chickadee/Rendering-Engine.html
diff options
context:
space:
mode:
Diffstat (limited to 'manuals/chickadee/Rendering-Engine.html')
-rw-r--r--manuals/chickadee/Rendering-Engine.html140
1 files changed, 54 insertions, 86 deletions
diff --git a/manuals/chickadee/Rendering-Engine.html b/manuals/chickadee/Rendering-Engine.html
index bdc2444..1c90022 100644
--- a/manuals/chickadee/Rendering-Engine.html
+++ b/manuals/chickadee/Rendering-Engine.html
@@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
-<!-- Copyright (C) 2017-2020 David Thompson davet@gnu.org
+<!-- Copyright (C) 2017-2021 David Thompson davet@gnu.org
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
@@ -32,8 +32,8 @@ http://www.texinfo.org/ (GNU Texinfo).
<link href="Index.html" rel="index" title="Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Graphics.html" rel="up" title="Graphics">
-<link href="Buffers.html" rel="next" title="Buffers">
-<link href="Viewports.html" rel="prev" title="Viewports">
+<link href="Audio.html" rel="next" title="Audio">
+<link href="Render-Settings.html" rel="prev" title="Render Settings">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
@@ -82,27 +82,60 @@ ul.no-bullet {list-style: none}
<body lang="en">
<span id="Rendering-Engine"></span><div class="header">
<p>
-Next: <a href="Buffers.html" accesskey="n" rel="next">Buffers</a>, Previous: <a href="Viewports.html" accesskey="p" rel="prev">Viewports</a>, Up: <a href="Graphics.html" accesskey="u" rel="up">Graphics</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
+Previous: <a href="Render-Settings.html" accesskey="p" rel="prev">Render Settings</a>, Up: <a href="Graphics.html" accesskey="u" rel="up">Graphics</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
-<span id="Rendering-Engine-1"></span><h4 class="subsection">2.3.13 Rendering Engine</h4>
-
-<p>Chickadee defines rendering using a metaphor familiar to Scheme
-programmers: procedure application. A shader (see <a href="Shaders.html">Shaders</a>) is
-like a procedure for the GPU to apply. Shaders are passed arguments:
-A vertex array containing the geometry to render (see <a href="Buffers.html">Buffers</a>) and
-zero or more keyword arguments that the shader understands. Similar
-to how Scheme has <code>apply</code> for calling procedures, Chickadee
-provides <code>shader-apply</code> for calling shaders.
+<span id="Rendering-Engine-1"></span><h4 class="subsection">5.3.17 Rendering Engine</h4>
+
+<p>The <code>(chickadee graphics engine)</code> module provides a Scheme
+abstraction to the state of the GPU driver. When the Chickadee game
+loop launches, it takes care to initialize the engine. All draw calls
+and state changes happen within the context of this engine.
+</p>
+<p>Performing a custom draw call could look something like this:
</p>
-<p>Additionally, there is some dynamic state that effects how
-<code>shader-apply</code> 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
-<code>shader-apply</code> is called.
+<div class="example">
+<pre class="example">(with-graphics-state ((g:blend-mode blend:alpha)
+ (g:texture-0 my-texture))
+ (shader-apply my-shader #:foo 1))
+</pre></div>
+
+<span id="Render-States"></span><h4 class="subsubsection">5.3.17.1 Render States</h4>
+
+<p>Render states represent individual state values on the GPU. For
+example, the current shader. As a naming convention, Chickadee
+prefixes variables containing render states with <code>g:</code>. Render
+states can be manipulated using the <code>with-graphics-state</code> macro.
+</p>
+<dl>
+<dt id="index-with_002dgraphics_002dstate">Syntax: <strong>with-graphics-state</strong> <em>((name value) &hellip;) body &hellip;</em></dt>
+<dd><p>Evaluate <var>body</var> with render states defined by <var>name</var> changed
+to <var>value</var>. The render states are restored to their previous
+values afterwards.
+</p></dd></dl>
+
+<p>One additional piece of state that the rendering engine has, that is
+not part of the GPU state, is the current projection matrix:
</p>
-<p>The following procedures and syntax can be found in the
-<code>(chickadee graphics)</code> module.
+<dl>
+<dt id="index-current_002dprojection">Procedure: <strong>current-projection</strong></dt>
+<dd><p>Return the currently bound projection matrix (see <a href="Matrices.html">Matrices</a>).
+</p></dd></dl>
+
+<dl>
+<dt id="index-with_002dprojection">Syntax: <strong>with-projection</strong> <em>projection body &hellip;</em></dt>
+<dd><p>Evaluate <var>body</var> with the current projection matrix bound to
+<var>projection</var> (see <a href="Matrices.html">Matrices</a>).
+</p></dd></dl>
+
+<span id="Rendering"></span><h4 class="subsubsection">5.3.17.2 Rendering</h4>
+
+<p>Chickadee likens a GPU draw call to a Scheme procedure call. A shader
+(see <a href="Shaders.html">Shaders</a>) is like a procedure for the GPU to apply. Shaders
+are passed arguments: The positional arguments are vertex array
+attributes (see <a href="Buffers.html">Buffers</a>) and the keyword arguments correspond to
+the shader&rsquo;s uniform variables. Scheme uses <code>apply</code> to call a
+procedure, so Chickadee uses <code>shader-apply</code> to call a shader.
</p>
<dl>
<dt id="index-shader_002dapply">Syntax: <strong>shader-apply</strong> <em>shader vertex-array [#:uniform-key uniform-value &hellip;]</em></dt>
@@ -131,75 +164,10 @@ particle effects described in <a href="Particles.html">Particles</a> use instanc
vertices.
</p></dd></dl>
-<dl>
-<dt id="index-current_002dviewport">Procedure: <strong>current-viewport</strong></dt>
-<dd><p>Return the currently bound viewport (see <a href="Viewports.html">Viewports</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-current_002dframebuffer">Procedure: <strong>current-framebuffer</strong></dt>
-<dd><p>Return the currently bound framebuffer (see <a href="Framebuffers.html">Framebuffers</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-current_002dblend_002dmode">Procedure: <strong>current-blend-mode</strong></dt>
-<dd><p>Return the currently bound blend mode (see <a href="Blending.html">Blending</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-current_002ddepth_002dtest">Procedure: <strong>current-depth-test</strong></dt>
-<dd><p>Return <code>#t</code> if depth testing is currently enabled (see <a href="Blending.html">Blending</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-current_002dtexture">Procedure: <strong>current-texture</strong></dt>
-<dd><p>Return the currently bound texture (see <a href="Textures.html">Textures</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-current_002dprojection">Procedure: <strong>current-projection</strong></dt>
-<dd><p>Return the currently bound projection matrix (see <a href="Matrices.html">Matrices</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-with_002dviewport">Syntax: <strong>with-viewport</strong> <em>viewport body &hellip;</em></dt>
-<dd><p>Evaluate <var>body</var> with the current viewport bound to <var>viewport</var> (see <a href="Viewports.html">Viewports</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-with_002dframebuffer">Syntax: <strong>with-framebuffer</strong> <em>framebuffer body &hellip;</em></dt>
-<dd><p>Evaluate <var>body</var> with the current framebuffer bound to
-<var>framebuffer</var> (see <a href="Framebuffers.html">Framebuffers</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-with_002dblend_002dmode">Syntax: <strong>with-blend-mode</strong> <em>blend-mode body &hellip;</em></dt>
-<dd><p>Evaluate <var>body</var> with the current blend mode bound to
-<var>blend-mode</var> (see <a href="Blending.html">Blending</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-with_002ddepth_002dtest">Syntax: <strong>with-depth-test</strong> <em>depth-test? body &hellip;</em></dt>
-<dd><p>Evaluate <var>body</var> with the depth-test disabled if <var>depth-test?</var>
-is <code>#f</code>, or enabled otherwise (see <a href="Blending.html">Blending</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-with_002dtexture">Syntax: <strong>with-texture</strong> <em>texture body &hellip;</em></dt>
-<dd><p>Evaluate <var>body</var> with the current texture bound to <var>texture</var>
-(see <a href="Textures.html">Textures</a>).
-</p></dd></dl>
-
-<dl>
-<dt id="index-with_002dprojection">Syntax: <strong>with-projection</strong> <em>projection body &hellip;</em></dt>
-<dd><p>Evaluate <var>body</var> with the current projection matrix bound to
-<var>projection</var> (see <a href="Matrices.html">Matrices</a>).
-</p></dd></dl>
-
<hr>
<div class="header">
<p>
-Next: <a href="Buffers.html" accesskey="n" rel="next">Buffers</a>, Previous: <a href="Viewports.html" accesskey="p" rel="prev">Viewports</a>, Up: <a href="Graphics.html" accesskey="u" rel="up">Graphics</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
+Previous: <a href="Render-Settings.html" accesskey="p" rel="prev">Render Settings</a>, Up: <a href="Graphics.html" accesskey="u" rel="up">Graphics</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>