Browse Source

Fix newBuffer examples;

bjorn 1 year ago
parent
commit
93f06c6c72
2 changed files with 5 additions and 3 deletions
  1. 4 2
      api/init.lua
  2. 1 1
      api/lovr/graphics/newBuffer.lua

+ 4 - 2
api/init.lua

@@ -11039,8 +11039,10 @@ return {
           key = "lovr.graphics.newBuffer",
           module = "lovr.graphics",
           examples = {
-            description = "Examples of different buffer formats.",
-            code = "      -- 2 matrices\n      lovr.graphics.newBuffer('mat4', 2)\n\n      -- 3 integers, with initial data\n      lovr.graphics.newBuffer('int', { 1, 2, 3 })\n\n      -- a simple mesh:\n      lovr.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\n      lovr.graphics.newBuffer({ 'vec3', layout = 'std140' }, data)\n\n      -- a uniform buffer with key-value fields\n      lovr.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\n      lovr.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:\n      lovr.graphics.newBuffer(shader:getBufferFormat('transforms'))\n    "
+            {
+              description = "Examples of different buffer formats.",
+              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.",
           related = {

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

@@ -140,7 +140,7 @@ return {
 
     If no table or Blob is used to define the initial Buffer contents, its data will be undefined.
   ]],
-  examples = {
+  example = {
     description = 'Examples of different buffer formats.',
     code = [[
       -- 2 matrices