Browse Source

Document buffer field strides;

bjorn 1 week ago
parent
commit
f439d4d9f8
2 changed files with 3 additions and 3 deletions
  1. 1 2
      api/init.lua
  2. 2 1
      api/lovr/graphics/newBuffer.lua

+ 1 - 2
api/init.lua

@@ -11891,7 +11891,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'))"
               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.  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.",
+          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 (optional, leave as `nil` for non-arrays).\n- `stride` is the number of bytes between each item in an array (optional).\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 = {
           related = {
             "Shader:getBufferFormat"
             "Shader:getBufferFormat"
           },
           },
@@ -28995,7 +28995,6 @@ return {
               description = "Returns a list of points on the Curve.  The number of points can be specified to get a more or less detailed representation, and it is also possible to render a subsection of the Curve.",
               description = "Returns a list of points on the Curve.  The number of points can be specified to get a more or less detailed representation, and it is also possible to render a subsection of the Curve.",
               key = "Curve:render",
               key = "Curve:render",
               module = "lovr.math",
               module = "lovr.math",
-              notes = "This function will always return 2 points if the Curve is a line with only 2 control points.",
               related = {
               related = {
                 "Curve:evaluate",
                 "Curve:evaluate",
                 "Curve:slice",
                 "Curve:slice",

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

@@ -108,7 +108,8 @@ return {
       to each other sequentially in memory, subject to any padding required by the Buffer's layout.
       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
       In practice this means that you probably want to provide an `offset` for either all of the
       fields or none of them.
       fields or none of them.
-    - `length` is the array size of the field.
+    - `length` is the array size of the field (optional, leave as `nil` for non-arrays).
+    - `stride` is the number of bytes between each item in an array (optional).
 
 
     As a shorthand, the name, type, and optionally the length of a field can be provided as a list
     As a shorthand, the name, type, and optionally the length of a field can be provided as a list
     instead of using keys.
     instead of using keys.