Browse Source

Document new `raw` option in `newShader`

Hendrik Mans 1 year ago
parent
commit
3464f58e6d
2 changed files with 27 additions and 2 deletions
  1. 16 1
      api/init.lua
  2. 11 1
      api/lovr/graphics/newShader.lua

+ 16 - 1
api/init.lua

@@ -12484,7 +12484,7 @@ return {
           name = "newShader",
           name = "newShader",
           tag = "graphics-objects",
           tag = "graphics-objects",
           summary = "Create a new Shader.",
           summary = "Create a new Shader.",
-          description = "Creates a Shader, which is a small program that runs on the GPU.\n\nShader code is usually written in GLSL and compiled to SPIR-V bytecode.  SPIR-V is faster to load but requires a build step.  Either form can be used to create a shader.",
+          description = "Creates a Shader, which is a small program that runs on the GPU.\n\nShader code is usually written in GLSL and compiled to SPIR-V bytecode.  SPIR-V is faster to load but requires a build step.  Either form can be used to create a shader.\n\nBy default, the provided shader code is expected to implement a `void lovrmain() { ... }` function that is called for each vertex or fragment.  If the `raw` option is set to `true`, the code is treated as a raw shader and the `lovrmain` function is not required. In this case, the shader code is expected to implement its own `main` function.",
           key = "lovr.graphics.newShader",
           key = "lovr.graphics.newShader",
           module = "lovr.graphics",
           module = "lovr.graphics",
           related = {
           related = {
@@ -12520,6 +12520,11 @@ return {
                       name = "label",
                       name = "label",
                       type = "string",
                       type = "string",
                       description = "A label to use for the shader in debugging tools."
                       description = "A label to use for the shader in debugging tools."
+                    },
+                    {
+                      name = "raw",
+                      type = "boolean",
+                      description = "If set to true, the code is treated as a raw shader."
                     }
                     }
                   }
                   }
                 }
                 }
@@ -12554,6 +12559,11 @@ return {
                       name = "label",
                       name = "label",
                       type = "string",
                       type = "string",
                       description = "A label to use for the shader in debugging tools."
                       description = "A label to use for the shader in debugging tools."
+                    },
+                    {
+                      name = "raw",
+                      type = "boolean",
+                      description = "If set to true, the code is treated as a raw shader."
                     }
                     }
                   }
                   }
                 }
                 }
@@ -12588,6 +12598,11 @@ return {
                       name = "label",
                       name = "label",
                       type = "string",
                       type = "string",
                       description = "A label to use for the shader in debugging tools."
                       description = "A label to use for the shader in debugging tools."
+                    },
+                    {
+                      name = "raw",
+                      type = "boolean",
+                      description = "If set to true, the code is treated as a raw shader."
                     }
                     }
                   }
                   }
                 }
                 }

+ 11 - 1
api/lovr/graphics/newShader.lua

@@ -6,6 +6,11 @@ return {
 
 
     Shader code is usually written in GLSL and compiled to SPIR-V bytecode.  SPIR-V is faster to
     Shader code is usually written in GLSL and compiled to SPIR-V bytecode.  SPIR-V is faster to
     load but requires a build step.  Either form can be used to create a shader.
     load but requires a build step.  Either form can be used to create a shader.
+
+    By default, the provided shader code is expected to implement a `void lovrmain() { ... }`
+    function that is called for each vertex or fragment.  If the `raw` option is set to `true`, the
+    code is treated as a raw shader and the `lovrmain` function is not required. In this case, the
+    shader code is expected to implement its own `main` function.
   ]],
   ]],
   arguments = {
   arguments = {
     vertex = {
     vertex = {
@@ -49,7 +54,12 @@ return {
           name = 'label',
           name = 'label',
           type = 'string',
           type = 'string',
           description = 'A label to use for the shader in debugging tools.'
           description = 'A label to use for the shader in debugging tools.'
-        }
+        },
+        {
+          name = 'raw',
+          type = 'boolean',
+          description = 'If set to true, the code is treated as a raw shader.'
+        },
       }
       }
     }
     }
   },
   },