Browse Source

Remove some instances of getBuffer;

bjorn 1 year ago
parent
commit
c260802d6b
4 changed files with 10 additions and 11 deletions
  1. 1 2
      api/init.lua
  2. 0 1
      api/lovr/graphics/DataType.lua
  3. 6 4
      api/lovr/graphics/Pass/mesh.lua
  4. 3 4
      guides/Shaders.md

+ 1 - 2
api/init.lua

@@ -9642,7 +9642,6 @@ return {
           notes = "In addition to these values, the following aliases can be used:\n\n<table>\n  <thead>\n    <tr>\n      <td>Alias</td>\n      <td>Maps to</td>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code>vec2</code></td>\n      <td><code>f32x2</code></td>\n    </tr>\n    <tr>\n      <td><code>vec3</code></td>\n      <td><code>f32x3</code></td>\n    </tr>\n    <tr>\n      <td><code>vec4</code></td>\n      <td><code>f32x4</code></td>\n    </tr>\n    <tr>\n      <td><code>int</code></td>\n      <td><code>i32</code></td>\n    </tr>\n    <tr>\n      <td><code>uint</code></td>\n      <td><code>u32</code></td>\n    </tr>\n    <tr>\n      <td><code>float</code></td>\n      <td><code>f32</code></td>\n    </tr>\n    <tr>\n      <td><code>color</code></td>\n      <td><code>un8x4</code></td>\n    </tr>\n  </tbody> </table>\n\nAdditionally, the following convenience rules apply:\n\n- Field types can end in an `s`, which will be stripped off.\n- Field types can end in `x1`, which will be stripped off.\n\nSo you can write, e.g. `lovr.graphics.newBuffer(4, 'floats')`, which is cute!",
           notes = "In addition to these values, the following aliases can be used:\n\n<table>\n  <thead>\n    <tr>\n      <td>Alias</td>\n      <td>Maps to</td>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code>vec2</code></td>\n      <td><code>f32x2</code></td>\n    </tr>\n    <tr>\n      <td><code>vec3</code></td>\n      <td><code>f32x3</code></td>\n    </tr>\n    <tr>\n      <td><code>vec4</code></td>\n      <td><code>f32x4</code></td>\n    </tr>\n    <tr>\n      <td><code>int</code></td>\n      <td><code>i32</code></td>\n    </tr>\n    <tr>\n      <td><code>uint</code></td>\n      <td><code>u32</code></td>\n    </tr>\n    <tr>\n      <td><code>float</code></td>\n      <td><code>f32</code></td>\n    </tr>\n    <tr>\n      <td><code>color</code></td>\n      <td><code>un8x4</code></td>\n    </tr>\n  </tbody> </table>\n\nAdditionally, the following convenience rules apply:\n\n- Field types can end in an `s`, which will be stripped off.\n- Field types can end in `x1`, which will be stripped off.\n\nSo you can write, e.g. `lovr.graphics.newBuffer(4, 'floats')`, which is cute!",
           related = {
           related = {
             "lovr.graphics.newBuffer",
             "lovr.graphics.newBuffer",
-            "lovr.graphics.getBuffer",
             "Buffer:getFormat"
             "Buffer:getFormat"
           },
           },
           values = {
           values = {
@@ -19110,7 +19109,7 @@ return {
               module = "lovr.graphics",
               module = "lovr.graphics",
               examples = {
               examples = {
                 {
                 {
-                  code = "function lovr.draw(pass)\n  local vertices = {\n    vec3(  0,  .4, 0), vec4(1, 0, 0, 1),\n    vec3(-.5, -.4, 0), vec4(0, 1, 0, 1),\n    vec3( .5, -.4, 0), vec4(0, 0, 1, 1)\n  }\n\n  local format = {\n    { type = 'vec3', location = 'VertexPosition' },\n    { type = 'vec4', location = 'VertexColor' }\n  }\n\n  local triangle = lovr.graphics.getBuffer(vertices, format)\n\n  pass:mesh(triangle, 0, 1.7, -1)\nend"
+                  code = "function lovr.load()\n  local vertices = {\n    vec3(  0,  .4, 0), vec4(1, 0, 0, 1),\n    vec3(-.5, -.4, 0), vec4(0, 1, 0, 1),\n    vec3( .5, -.4, 0), vec4(0, 0, 1, 1)\n  }\n\n  local format = {\n    { name = 'VertexPosition', type = 'vec3' },\n    { name = 'VertexColor', type = 'vec4' }\n  }\n\n  triangle = lovr.graphics.newBuffer(format, vertices)\nend\n\nfunction lovr.draw(pass)\n  pass:mesh(triangle, 0, 1.7, -1)\nend"
                 }
                 }
               },
               },
               notes = "The index buffer defines the order the vertices are drawn in.  It can be used to reorder, reuse, or omit vertices from the mesh.\n\nWhen drawing without a vertex buffer, the `VertexIndex` variable can be used in shaders to compute the position of each vertex, possibly by reading data from other `Buffer` or `Texture` resources.\n\nThe active `DrawMode` controls whether the vertices are drawn as points, lines, or triangles.\n\nThe active `Material` is applied to the mesh.",
               notes = "The index buffer defines the order the vertices are drawn in.  It can be used to reorder, reuse, or omit vertices from the mesh.\n\nWhen drawing without a vertex buffer, the `VertexIndex` variable can be used in shaders to compute the position of each vertex, possibly by reading data from other `Buffer` or `Texture` resources.\n\nThe active `DrawMode` controls whether the vertices are drawn as points, lines, or triangles.\n\nThe active `Material` is applied to the mesh.",

+ 0 - 1
api/lovr/graphics/DataType.lua

@@ -207,7 +207,6 @@ return {
   ]],
   ]],
   related = {
   related = {
     'lovr.graphics.newBuffer',
     'lovr.graphics.newBuffer',
-    'lovr.graphics.getBuffer',
     'Buffer:getFormat'
     'Buffer:getFormat'
   }
   }
 }
 }

+ 6 - 4
api/lovr/graphics/Pass/mesh.lua

@@ -180,7 +180,7 @@ return {
     The active `Material` is applied to the mesh.
     The active `Material` is applied to the mesh.
   ]],
   ]],
   example = [[
   example = [[
-    function lovr.draw(pass)
+    function lovr.load()
       local vertices = {
       local vertices = {
         vec3(  0,  .4, 0), vec4(1, 0, 0, 1),
         vec3(  0,  .4, 0), vec4(1, 0, 0, 1),
         vec3(-.5, -.4, 0), vec4(0, 1, 0, 1),
         vec3(-.5, -.4, 0), vec4(0, 1, 0, 1),
@@ -188,12 +188,14 @@ return {
       }
       }
 
 
       local format = {
       local format = {
-        { type = 'vec3', location = 'VertexPosition' },
-        { type = 'vec4', location = 'VertexColor' }
+        { name = 'VertexPosition', type = 'vec3' },
+        { name = 'VertexColor', type = 'vec4' }
       }
       }
 
 
-      local triangle = lovr.graphics.getBuffer(vertices, format)
+      triangle = lovr.graphics.newBuffer(format, vertices)
+    end
 
 
+    function lovr.draw(pass)
       pass:mesh(triangle, 0, 1.7, -1)
       pass:mesh(triangle, 0, 1.7, -1)
     end
     end
   ]]
   ]]

+ 3 - 4
guides/Shaders.md

@@ -554,11 +554,10 @@ buffer has multiple fields per element).
 A Buffer can be sent to one of the above variables like this:
 A Buffer can be sent to one of the above variables like this:
 
 
     -- palette is a table with 100 colors in it
     -- palette is a table with 100 colors in it
-    buffer = lovr.graphics.getBuffer(palette, 'vec4')
-    pass:send('Colors', buffer)
+    buffer = lovr.graphics.newBuffer('vec4', palette)
 
 
-    -- or, using the binding number
-    pass:send(0, buffer)
+    -- bind it to the shader later
+    pass:send('Colors', buffer)
 
 
 The shader can then use the `colors` array to access the data from the `palette` table.
 The shader can then use the `colors` array to access the data from the `palette` table.