Explorar o código

lovr.graphics.newBuffer mentions vertex attributes;

bjorn hai 5 meses
pai
achega
11019b2116
Modificáronse 2 ficheiros con 7 adicións e 2 borrados
  1. 1 1
      api/init.lua
  2. 6 1
      api/lovr/graphics/newBuffer.lua

+ 1 - 1
api/init.lua

@@ -11931,7 +11931,7 @@ return {
               code = "-- 2 matrices\nlovr.graphics.newBuffer('mat4', 2)\n\n-- 3 integers, with initial data\nlovr.graphics.newBuffer('int', { 1, 2, 3 })\n\n-- a simple mesh:\nlovr.graphics.newBuffer({\n  { name = 'VertexPosition', type = 'vec3' },\n  { name = 'VertexColor', type = 'color' }\n}, 4)\n\n-- a uniform buffer with vec3's, using the std140 packing\nlovr.graphics.newBuffer({ 'vec3', layout = 'std140' }, data)\n\n-- a uniform buffer with key-value fields\nlovr.graphics.newBuffer({\n  { 'AmbientColor', 'vec3' },\n  { 'LightPosition', 'vec3' },\n  { 'LightType', 'u32' },\n  { 'LightColor', 'vec4' },\n  layout = 'std140'\n})\n\n-- a buffer with nested structure and array types\nlovr.graphics.newBuffer({\n  { 'globals', {\n    { 'ObjectCount', 'int' },\n    { 'WorldSize', 'vec2' },\n    { 'Scale', 'float' }\n  }},\n  { 'materials', {\n    { 'Color', 'vec4' },\n    { 'Glow', 'vec3' },\n    { 'Roughness', 'float' }\n  }, length = 32 },\n  layout = 'std430'\n})\n\n-- a buffer using a variable from a shader:\nlovr.graphics.newBuffer(shader:getBufferFormat('transforms'))"
             }
           },
-          notes = "The format table can contain a list of `DataType`s or a list of tables to provide extra information about each field.  Each inner table has the following keys:\n\n- `type` is the `DataType` of the field and is required.\n- `name` is the name of the field, used to match table keys and vertex attribute names.\n- `offset` is the byte offset of the field.  Any fields with a `nil` offset will be placed next\n  to each other sequentially in memory, subject to any padding required by the Buffer's layout.\n  In practice this means that you probably want to provide an `offset` for either all of the\n  fields or none of them.\n- `length` is the array size of the field.\n\nAs a shorthand, the name, type, and optionally the length of a field can be provided as a list instead of using keys.\n\nIf no table or Blob is used to define the initial Buffer contents, its data will be undefined.",
+          notes = "The format table can contain a list of `DataType`s or a list of tables to provide extra information about each field.  Each inner table has the following keys:\n\n- `type` is the `DataType` of the field and is required.\n- `name` is the name of the field.  The field name is used to match table keys up to buffer\n  fields when writing table data to the Buffer, and is also used to match up buffer fields with\n  vertex attribute names declared in a `Shader`.  LÖVR has a set of <a\n  href=\"Shaders#vertex-attributes\">default vertex attributes</a> that shaders will automatically\n  use, allowing you to create a custom mesh without having to write shader code or add custom\n  vertex attributes in a shader.\n- `offset` is the byte offset of the field.  Any fields with a `nil` offset will be placed next\n  to each other sequentially in memory, subject to any padding required by the Buffer's layout.\n  In practice this means that you probably want to provide an `offset` for either all of the\n  fields or none of them.\n- `length` is the array size of the field.\n\nAs a shorthand, the name, type, and optionally the length of a field can be provided as a list instead of using keys.\n\nIf no table or Blob is used to define the initial Buffer contents, its data will be undefined.",
           related = {
             "Shader:getBufferFormat"
           },

+ 6 - 1
api/lovr/graphics/newBuffer.lua

@@ -128,7 +128,12 @@ return {
     information about each field.  Each inner table has the following keys:
 
     - `type` is the `DataType` of the field and is required.
-    - `name` is the name of the field, used to match table keys and vertex attribute names.
+    - `name` is the name of the field.  The field name is used to match table keys up to buffer
+      fields when writing table data to the Buffer, and is also used to match up buffer fields with
+      vertex attribute names declared in a `Shader`.  LÖVR has a set of <a
+      href="Shaders#vertex-attributes">default vertex attributes</a> that shaders will automatically
+      use, allowing you to create a custom mesh without having to write shader code or add custom
+      vertex attributes in a shader.
     - `offset` is the byte offset of the field.  Any fields with a `nil` offset will be placed next
       to each other sequentially in memory, subject to any padding required by the Buffer's layout.
       In practice this means that you probably want to provide an `offset` for either all of the