Bläddra i källkod

Start drawing functions;

bjorn 3 år sedan
förälder
incheckning
5878674416

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 854 - 70
api/init.lua


+ 14 - 0
api/lovr/graphics/box.lua

@@ -0,0 +1,14 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a box.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'transform',
+      type = 'transform3',
+      description = 'The transform to apply to the box.'
+    }
+  },
+  returns = {},
+  notes = 'TODO material'
+}

+ 20 - 0
api/lovr/graphics/circle.lua

@@ -0,0 +1,20 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a circle.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'transform',
+      type = 'transform',
+      description = 'The transform to apply to the circle.'
+    },
+    {
+      name = 'detail',
+      type = 'number',
+      default = '4',
+      description = 'A detail value from 0 to 6.'
+    }
+  },
+  returns = {},
+  notes = 'TODO material'
+}

+ 20 - 0
api/lovr/graphics/cone.lua

@@ -0,0 +1,20 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a cone.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'transform',
+      type = 'transformxy2',
+      description = 'The transform to apply to the cone.'
+    },
+    {
+      name = 'detail',
+      type = 'number',
+      default = '4',
+      description = 'A detail value from 0 to 6.'
+    }
+  },
+  returns = {},
+  notes = 'TODO material'
+}

+ 14 - 0
api/lovr/graphics/cube.lua

@@ -0,0 +1,14 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a cube.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'transform',
+      type = 'transform',
+      description = 'The transform to apply to the cube.'
+    }
+  },
+  returns = {},
+  notes = 'TODO material'
+}

+ 26 - 0
api/lovr/graphics/cylinder.lua

@@ -0,0 +1,26 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a cylinder.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'transform',
+      type = 'transformxy2',
+      description = 'The transform to apply to the cylinder.'
+    },
+    {
+      name = 'detail',
+      type = 'number',
+      default = '4',
+      description = 'A detail value from 0 to 6.'
+    },
+    {
+      name = 'capped',
+      type = 'boolean',
+      default = 'true',
+      description = 'Whether the top and bottom of the tube should be rendered.'
+    }
+  },
+  returns = {},
+  notes = 'TODO material'
+}

+ 14 - 0
api/lovr/graphics/fill.lua

@@ -0,0 +1,14 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a fullscreen quad.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'material',
+      type = 'Material',
+      description = 'The material to use for the fill.'
+    }
+  },
+  returns = {},
+  notes = 'TODO shader, attributes, depth/stencil clears'
+}

+ 63 - 0
api/lovr/graphics/line.lua

@@ -0,0 +1,63 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a line.',
+  description = 'TODO',
+  arguments = {
+    x1 = {
+      type = 'number',
+      description = 'The x coordinate of the first point.'
+    },
+    y1 = {
+      type = 'number',
+      description = 'The y coordinate of the first point.'
+    },
+    z1 = {
+      type = 'number',
+      description = 'The z coordinate of the first point.'
+    },
+    x2 = {
+      type = 'number',
+      description = 'The x coordinate of the next point.'
+    },
+    y2 = {
+      type = 'number',
+      description = 'The y coordinate of the next point.'
+    },
+    z2 = {
+      type = 'number',
+      description = 'The z coordinate of the next point.'
+    },
+    t = {
+      type = 'table',
+      description = 'A table of numbers or Vec3 objects (not both) representing points of the line.'
+    },
+    v1 = {
+      type = 'Vec3',
+      description = 'A vector containing the position of the first point of the line.'
+    },
+    v2 = {
+      type = 'Vec3',
+      description = 'A vector containing the position of the next point on the line.'
+    },
+    ['...'] = {
+      type = '*',
+      description = 'More points to add to the line.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'x1', 'y1', 'z1', 'x2', 'y2', 'z2', '...' },
+      returns = {}
+    },
+    {
+      arguments = { 't' },
+      returns = {}
+    },
+    {
+      arguments = { 'v1', 'v2', '...' },
+      returns = {}
+    }
+  },
+  notes = 'TODO material, mesh, attributes'
+}

+ 109 - 0
api/lovr/graphics/mesh.lua

@@ -0,0 +1,109 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a mesh.',
+  description = 'TODO',
+  arguments = {
+    material = {
+      type = 'Material',
+      description = 'The Material to apply to the mesh.'
+    },
+    mode = {
+      type = 'DrawMode',
+      description = 'Whether the vertices should be drawn as `points`, `lines`, or `triangles`.'
+    },
+    vertices = {
+      type = 'Buffer',
+      default = 'nil',
+      description = [[
+        A Buffer containing the vertices to render, or `nil` if no vertex buffer is needed.
+      ]]
+    },
+    indices = {
+      type = 'Buffer',
+      description = 'A Buffer containing indices of vertices to render.'
+    },
+    transform = {
+      type = 'transform',
+      description = 'The transform to apply to the mesh.'
+    },
+    start = {
+      type = 'number',
+      default = '1',
+      description = [[
+        The 1-based index of the first vertex to render from the vertex buffer (or the first index,
+        when using an index buffer).
+      ]]
+    },
+    count = {
+      type = 'number',
+      default = 'nil',
+      description = [[
+        The number of vertices to render (or the number of indices, when using an index buffer).
+        When `nil`, as many vertices or indices as possible will be drawn (based on the length of
+        the Buffers and `start`).
+      ]]
+    },
+    instances = {
+      type = 'number',
+      default = '1',
+      description = 'The number of copies of the mesh to render.'
+    },
+    indirect = {
+      type = 'Buffer',
+      description = 'A Buffer containing parameters for the draw.'
+    },
+    indirectcount = {
+      type = 'number',
+      default = '1',
+      description = 'How many draws to read and render from the indirect buffer.'
+    },
+    indirectoffset = {
+      type = 'number',
+      default = '0',
+      description = 'A byte offset of where the draw parameters are stored in the indirect buffer.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'vertices', 'transform', 'start', 'count', 'instances' },
+      returns = {}
+    },
+    {
+      arguments = { 'vertices', 'indices', 'transform', 'start', 'count', 'instances' },
+      returns = {}
+    },
+    {
+      arguments = { 'mode', 'vertices', 'transform', 'start', 'count', 'instances' },
+      returns = {}
+    },
+    {
+      arguments = { 'mode', 'vertices', 'indices', 'transform', 'start', 'count', 'instances' },
+      returns = {}
+    },
+    {
+      arguments = { 'vertices', 'transform', 'indirect', 'indirectcount', 'indirectoffset' },
+      returns = {}
+    },
+    {
+      arguments = { 'vertices', 'indices', 'transform', 'indirect', 'indirectcount', 'indirectoffset' },
+      returns = {}
+    },
+    {
+      arguments = { 'mode', 'vertices', 'transform', 'indirect', 'indirectcount', 'indirectoffset' },
+      returns = {}
+    },
+    {
+      arguments = { 'mode', 'vertices', 'indices', 'transform', 'indirect', 'indirectcount', 'indirectoffset' },
+      returns = {}
+    }
+  },
+  notes = [[
+    When `vertices` is `nil`, the mesh will still be rendered with `count` vertices and the vertex
+    shader will still run.  The vertex shader can generate the vertex positions or read data from
+    other variables to compute the final vertex position.  An index buffer can still be used too.
+
+    TODO lots
+    TODO material combinatorial explosion
+  ]]
+}

+ 47 - 0
api/lovr/graphics/model.lua

@@ -0,0 +1,47 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a Model.',
+  description = 'TODO',
+  arguments = {
+    model = {
+      type = 'Model',
+      description = 'The Model to draw.'
+    },
+    transform = {
+      type = 'transform',
+      description = 'The transform to apply to the model.'
+    },
+    node = {
+      type = 'number',
+      default = 'nil',
+      description = 'The 1-based index of the node to render.  If `nil`, the root node is used.'
+    },
+    name = {
+      type = 'string',
+      default = 'nil',
+      description = 'The name of the node to render.  If `nil`, the root node is used.'
+    },
+    children = {
+      type = 'boolean',
+      default = 'true',
+      description = 'Whether the child nodes should be rendered recursively.'
+    },
+    instances = {
+      type = 'number',
+      default = '1',
+      description = 'How many copies of the model to render.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'model', 'transform', 'node', 'children', 'instances' },
+      returns = {}
+    },
+    {
+      arguments = { 'model', 'transform', 'name', 'children', 'instances' },
+      returns = {}
+    }
+  },
+  notes = 'TODO skinning'
+}

+ 19 - 0
api/lovr/graphics/plane.lua

@@ -0,0 +1,19 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a flat plane.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'transform',
+      type = 'transform2',
+      description = 'The transform to apply to the plane.'
+    },
+    {
+      name = 'detail',
+      type = 'number',
+      description = 'A number between 0 and 7 indicating how many times to subdivide the plane.'
+    }
+  },
+  returns = {},
+  notes = 'TODO material'
+}

+ 47 - 0
api/lovr/graphics/points.lua

@@ -0,0 +1,47 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw points.',
+  description = 'TODO',
+  arguments = {
+    x = {
+      type = 'number',
+      description = 'The x coordinate of the first point.'
+    },
+    y = {
+      type = 'number',
+      description = 'The y coordinate of the first point.'
+    },
+    z = {
+      type = 'number',
+      description = 'The z coordinate of the first point.'
+    },
+    t = {
+      type = 'table',
+      description = 'A table of numbers or Vec3 objects (not both) representing point positions.'
+    },
+    v = {
+      type = 'Vec3',
+      description = 'A vector containing the position of the first point to draw.'
+    },
+    ['...'] = {
+      type = '*',
+      description = 'More points.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'z', '...' },
+      returns = {}
+    },
+    {
+      arguments = { 't' },
+      returns = {}
+    },
+    {
+      arguments = { 'v', '...' },
+      returns = {}
+    }
+  },
+  notes = 'TODO material, mesh, attributes'
+}

+ 45 - 0
api/lovr/graphics/print.lua

@@ -0,0 +1,45 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw text.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'font',
+      type = 'Font',
+      description = 'The Font to use.'
+    },
+    {
+      name = 'text',
+      type = 'string',
+      description = 'The text to render.'
+    },
+    {
+      name = 'transform',
+      type = 'transform',
+      description = 'The transform of the text.'
+    },
+    {
+      name = 'wrap',
+      type = 'number',
+      default = '0',
+      description = [[[
+        The maximum width of each line in meters (before scale is applied).  When zero, the text
+        will not wrap.
+      ]]
+    },
+    {
+      name = 'halign',
+      type = 'HorizontalAlign',
+      default = [['center']],
+      description = 'The horizontal alignment.'
+    },
+    {
+      name = 'valign',
+      type = 'VerticalAlign',
+      default = [['middle']],
+      description = 'The vertical alignment.'
+    }
+  },
+  returns = {},
+  notes = 'TODO'
+}

+ 14 - 0
api/lovr/graphics/replay.lua

@@ -0,0 +1,14 @@
+return {
+  tag = 'drawing',
+  summary = 'Replay the draws saved in a Batch object.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'batch',
+      type = 'Batch',
+      description = 'The Batch to replay.'
+    }
+  },
+  returns = {},
+  notes = 'TODO'
+}

+ 17 - 0
api/lovr/graphics/skybox.lua

@@ -0,0 +1,17 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a skybox.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'texture',
+      type = 'Texture',
+      description = [[
+        The texture to use for the skybox.  It can be a cube texture or a 2D texture.  When 2D, the
+        texture should use spherical coordinates (also called equirectangular projection).
+      ]]
+    }
+  },
+  returns = {},
+  notes = 'TODO'
+}

+ 20 - 0
api/lovr/graphics/sphere.lua

@@ -0,0 +1,20 @@
+return {
+  tag = 'drawing',
+  summary = 'Draw a sphere.',
+  description = 'TODO',
+  arguments = {
+    {
+      name = 'transform',
+      type = 'transform',
+      description = 'The transform to apply to the sphere.'
+    },
+    {
+      name = 'detail',
+      type = 'number',
+      default = '4',
+      description = 'A detail value from 0 to 4.'
+    }
+  },
+  returns = {},
+  notes = 'TODO material'
+}

Vissa filer visades inte eftersom för många filer har ändrats