diff options
author | David Thompson <dthompson2@worcester.edu> | 2021-10-07 20:17:50 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2021-10-07 20:17:50 -0400 |
commit | 0e699be281c8dea53e589e08a5831837e0eae7ea (patch) | |
tree | 4266aebec927b13ca56410be1901e3ee78dff49e /manuals/chickadee/Buffers.html | |
parent | 38daa330f2194de5f39cd41b270c89d7b2e94427 (diff) |
Updates for Chickadee 0.8.0 and Guile-SDL2 0.7.0.
Diffstat (limited to 'manuals/chickadee/Buffers.html')
-rw-r--r-- | manuals/chickadee/Buffers.html | 122 |
1 files changed, 71 insertions, 51 deletions
diff --git a/manuals/chickadee/Buffers.html b/manuals/chickadee/Buffers.html index 06b156a..ffb4714 100644 --- a/manuals/chickadee/Buffers.html +++ b/manuals/chickadee/Buffers.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 @@ -33,7 +33,7 @@ http://www.texinfo.org/ (GNU Texinfo). <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="Graphics.html" rel="up" title="Graphics"> <link href="Shaders.html" rel="next" title="Shaders"> -<link href="Rendering-Engine.html" rel="prev" title="Rendering Engine"> +<link href="Meshes.html" rel="prev" title="Meshes"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} @@ -82,10 +82,10 @@ ul.no-bullet {list-style: none} <body lang="en"> <span id="Buffers"></span><div class="header"> <p> -Next: <a href="Shaders.html" accesskey="n" rel="next">Shaders</a>, Previous: <a href="Rendering-Engine.html" accesskey="p" rel="prev">Rendering Engine</a>, Up: <a href="Graphics.html" accesskey="u" rel="up">Graphics</a> [<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> +Next: <a href="Shaders.html" accesskey="n" rel="next">Shaders</a>, Previous: <a href="Meshes.html" accesskey="p" rel="prev">Meshes</a>, Up: <a href="Graphics.html" accesskey="u" rel="up">Graphics</a> [<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="Buffers-1"></span><h4 class="subsection">2.3.14 Buffers</h4> +<span id="Buffers-1"></span><h4 class="subsection">5.3.12 Buffers</h4> <p>Alright, let’s brush aside all of those pretty high level abstractions and discuss what is going on under the hood. The GPU exists as a @@ -128,21 +128,21 @@ float is 4 bytes in length, so the buffer’s stride is 16. <p>Within a VBO, one or more “attributes”, as OpenGL calls them, may be present. Attributes are subregions within the buffer that have a particular data type. In this case, there are two attributes packed -into the buffer. To provided a typed view into a buffer, the -<code>make-buffer-view</code> procedure is needed: +into the buffer. To define vertex attributes, the +<code>make-vertex-attribute</code> procedure is needed: </p> <div class="example"> <pre class="example">(define vertices - (make-buffer-view #:buffer buffer - #:type 'vec2 - #:component-type 'float - #:length 4)) + (make-vertex-attribute #:buffer buffer + #:type 'vec2 + #:component-type 'float + #:length 4)) (define texcoords - (make-buffer-view #:buffer buffer - #:type 'vec2 - #:component-type 'float - #:length 4 - #:offset 8)) + (make-vertex-attribute #:buffer buffer + #:type 'vec2 + #:component-type 'float + #:length 4 + #:offset 8)) </pre></div> <p>To render a square, the GPU needs to draw two triangles, which means @@ -157,21 +157,20 @@ created. (make-buffer (u32vector 0 3 2 0 2 1) #:target 'index) (define indices - (make-buffer-view #:type 'scalar - #:component-type 'unsigned-int - #:buffer index-buffer)) + (make-vertex-attribute #:type 'scalar + #:component-type 'unsigned-int + #:buffer index-buffer)) </pre></div> <p>Note the use of the <code>#:target</code> keyword argument. It is required because the GPU treats index data in a special way and must be told which data is index data. </p> -<p>Now that the buffer views representing each attribute have been -created, all that’s left is to bind them all together in a “vertex -array object”, or VAO. Vertex arrays associate each buffer view -with an attribute index on the GPU. The indices that are chosen must -correspond with the indices that the shader (see <a href="Shaders.html">Shaders</a>) expects -for each attribute. +<p>Now that the vertex attributes have been created, all that’s left is +to bind them all together in a vertex array. Vertex arrays associate +each vertex attribute with an attribute index on the GPU. The indices +that are chosen must correspond with the indices that the shader +(see <a href="Shaders.html">Shaders</a>) expects for each attribute. </p> <div class="example"> <pre class="example">(define vertex-array @@ -290,14 +289,24 @@ will return a bytevector of all the data stored in <var>buffer</var>. When program execution exits this form, the data (including any modifications) is synced back to the GPU. </p> +<dl> +<dt id="index-current_002dbuffer">Procedure: <strong>current-buffer</strong></dt> +<dd><p>Return the current buffer. +</p></dd></dl> + +<dl> +<dt id="index-g_003abuffer">Variable: <strong>g:buffer</strong></dt> +<dd><p>Render state for buffers (see <a href="Rendering-Engine.html">Rendering Engine</a>.) +</p></dd></dl> + <p>This form is useful for streaming buffers that need to update their contents dynamically, such as a sprite batch. </p></dd></dl> <dl> -<dt id="index-make_002dbuffer_002dview">Procedure: <strong>make-buffer-view</strong> <em>#:buffer #:type #:component-type #:length [#:offset <code>0</code>] [#:divisor <code>1</code>] [#:name <code>"anonymous"</code>]</em></dt> +<dt id="index-make_002dvertex_002dattribute">Procedure: <strong>make-vertex-attribute</strong> <em>#:buffer #:type #:component-type #:length [#:offset <code>0</code>] [#:divisor <code>1</code>] [#:name <code>"anonymous"</code>]</em></dt> <dd> -<p>Return a new buffer view for <var>buffer</var> starting at byte index +<p>Return a new vertex attribute for <var>buffer</var> starting at byte index <var>offset</var> of <var>length</var> elements, where each element is of <var>type</var> and composed of <var>component-type</var> values. </p> @@ -350,60 +359,61 @@ for 2 instances, and so on. </p></dd></dl> <dl> -<dt id="index-buffer_002dview_003f">Procedure: <strong>buffer-view?</strong> <em>obj</em></dt> -<dd><p>Return <code>#t</code> if <var>obj</var> is a buffer view. +<dt id="index-vertex_002dattribute_003f">Procedure: <strong>vertex-attribute?</strong> <em>obj</em></dt> +<dd><p>Return <code>#t</code> if <var>obj</var> is a vertex attribute. </p></dd></dl> <dl> -<dt id="index-buffer_002dview_002d_003ebuffer">Procedure: <strong>buffer-view->buffer</strong> <em>buffer-view</em></dt> -<dd><p>Return the buffer that <var>buffer-view</var> is using. +<dt id="index-vertex_002dattribute_002d_003ebuffer">Procedure: <strong>vertex-attribute->buffer</strong> <em>vertex-attribute</em></dt> +<dd><p>Return the buffer that <var>vertex-attribute</var> is using. </p></dd></dl> <dl> -<dt id="index-buffer_002dview_002dname">Procedure: <strong>buffer-view-name</strong> <em>buffer-view</em></dt> -<dd><p>Return the name of <var>buffer-view</var>. +<dt id="index-vertex_002dattribute_002dname">Procedure: <strong>vertex-attribute-name</strong> <em>vertex-attribute</em></dt> +<dd><p>Return the name of <var>vertex-attribute</var>. </p></dd></dl> <dl> -<dt id="index-buffer_002dview_002doffset">Procedure: <strong>buffer-view-offset</strong> <em>buffer-view</em></dt> -<dd><p>Return the byte offset of <var>buffer-view</var>. +<dt id="index-vertex_002dattribute_002doffset">Procedure: <strong>vertex-attribute-offset</strong> <em>vertex-attribute</em></dt> +<dd><p>Return the byte offset of <var>vertex-attribute</var>. </p></dd></dl> <dl> -<dt id="index-buffer_002dview_002dtype">Procedure: <strong>buffer-view-type</strong> <em>buffer-view</em></dt> -<dd><p>Return the data type of <var>buffer-view</var>. +<dt id="index-vertex_002dattribute_002dtype">Procedure: <strong>vertex-attribute-type</strong> <em>vertex-attribute</em></dt> +<dd><p>Return the data type of <var>vertex-attribute</var>. </p></dd></dl> <dl> -<dt id="index-buffer_002dview_002dcomponent_002dtype">Procedure: <strong>buffer-view-component-type</strong> <em>buffer-view</em></dt> -<dd><p>Return the component data type of <var>buffer-view</var> +<dt id="index-vertex_002dattribute_002dcomponent_002dtype">Procedure: <strong>vertex-attribute-component-type</strong> <em>vertex-attribute</em></dt> +<dd><p>Return the component data type of <var>vertex-attribute</var> </p></dd></dl> <dl> -<dt id="index-buffer_002dview_002ddivisor">Procedure: <strong>buffer-view-divisor</strong> <em>buffer-view</em></dt> -<dd><p>Return the instance divisor for <var>buffer-view</var>. +<dt id="index-vertex_002dattribute_002ddivisor">Procedure: <strong>vertex-attribute-divisor</strong> <em>vertex-attribute</em></dt> +<dd><p>Return the instance divisor for <var>vertex-attribute</var>. </p></dd></dl> <dl> -<dt id="index-with_002dmapped_002dbuffer_002dview">Syntax: <strong>with-mapped-buffer-view</strong> <em>buffer-view body …</em></dt> +<dt id="index-with_002dmapped_002dvertex_002dattribute">Syntax: <strong>with-mapped-vertex-attribute</strong> <em>vertex-attribute body …</em></dt> <dd> -<p>Evaluate <var>body</var> in the context of <var>buffer-view</var> having its -data synced from GPU memory to RAM. See <code>with-mapped-buffer</code> for -more information. +<p>Evaluate <var>body</var> in the context of <var>vertex-attribute</var> having +its data synced from GPU memory to RAM. See <code>with-mapped-buffer</code> +for more information. </p></dd></dl> <dl> <dt id="index-make_002dvertex_002darray">Procedure: <strong>make-vertex-array</strong> <em>#:indices #:attributes [#:mode <code>triangles</code>]</em></dt> <dd> -<p>Return a new vertex array using the index data within the buffer view -<var>indices</var> and the vertex attribute data within <var>attributes</var>. +<p>Return a new vertex array using the index data within the vertex +attributes <var>indices</var> and the vertex attribute data within +<var>attributes</var>. </p> -<p><var>attributes</var> is an alist mapping shader attribute indices to typed -buffers containing vertex data: +<p><var>attributes</var> is an alist mapping shader attribute indices to +vertex attributes: </p> <div class="example"> -<pre class="example">`((1 . ,buffer-view-a) - (2 . ,buffer-view-b) +<pre class="example">`((1 . ,vertex-attribute-a) + (2 . ,vertex-attribute-b) …) </pre></div> @@ -450,10 +460,20 @@ data for <var>vertex-array</var>. <dd><p>Return the primitive rendering mode for <var>vertex-array</var>. </p></dd></dl> +<dl> +<dt id="index-current_002dvertex_002darray">Procedure: <strong>current-vertex-array</strong></dt> +<dd><p>Return the current vertex array. +</p></dd></dl> + +<dl> +<dt id="index-g_003avertex_002darray">Variable: <strong>g:vertex-array</strong></dt> +<dd><p>Render state for vertex arrays (see <a href="Rendering-Engine.html">Rendering Engine</a>.) +</p></dd></dl> + <hr> <div class="header"> <p> -Next: <a href="Shaders.html" accesskey="n" rel="next">Shaders</a>, Previous: <a href="Rendering-Engine.html" accesskey="p" rel="prev">Rendering Engine</a>, Up: <a href="Graphics.html" accesskey="u" rel="up">Graphics</a> [<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> +Next: <a href="Shaders.html" accesskey="n" rel="next">Shaders</a>, Previous: <a href="Meshes.html" accesskey="p" rel="prev">Meshes</a>, Up: <a href="Graphics.html" accesskey="u" rel="up">Graphics</a> [<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> |