return {
callbacks = {
{
name = "conf",
tag = "callbacks",
summary = "Called to read configuration settings at startup.",
description = "The `lovr.conf` callback lets you configure default settings for LÖVR. It is called once right before the game starts. Make sure you put `lovr.conf` in a file called `conf.lua`, a special file that's loaded before the rest of the framework initializes.",
key = "lovr.conf",
module = "lovr",
variants = {
{
arguments = {
{
name = "t",
type = "table",
description = "The table to edit the configuration settings on.",
table = {
{
name = "identity",
type = "string",
description = "A unique label for this project."
},
{
name = "headset",
type = "table",
description = "Configuration for the headset.",
table = {
{
name = "drivers",
type = "table",
description = "An ordered list of preferred headset drivers."
},
{
name = "mirror",
type = "boolean",
description = "Whether the desktop window should display a mirror of what's in the headset."
},
{
name = "msaa",
type = "number",
description = "The amount of antialiasing to use when rendering to the headset."
},
{
name = "offset",
type = "number",
description = "The vertical offset for seated experiences."
}
}
},
{
name = "modules",
type = "table",
description = "The set of enabled modules to use.",
table = {
{
name = "audio",
type = "boolean",
description = "Whether the audio module should be enabled."
},
{
name = "data",
type = "boolean",
description = "Whether the data module should be enabled."
},
{
name = "event",
type = "boolean",
description = "Whether the event module should be enabled."
},
{
name = "filesystem",
type = "boolean",
description = "Whether the filesystem module should be enabled."
},
{
name = "graphics",
type = "boolean",
description = "Whether the graphics module should be enabled."
},
{
name = "headset",
type = "boolean",
description = "Whether the headset module should be enabled."
},
{
name = "math",
type = "boolean",
description = "Whether the math module should be enabled."
},
{
name = "physics",
type = "boolean",
description = "Whether the physics module should be enabled."
},
{
name = "thread",
type = "boolean",
description = "Whether the thread module should be enabled."
},
{
name = "timer",
type = "boolean",
description = "Whether the timer module should be enabled."
}
}
},
{
name = "gammacorrect",
type = "boolean",
description = "Whether colors are gamma corrected."
},
{
name = "window",
type = "table",
description = "Configuration for the window.",
table = {
{
name = "width",
type = "number",
description = "The width of the window."
},
{
name = "height",
type = "number",
description = "The height of the window."
},
{
name = "fullscreen",
type = "boolean",
description = "Whether the window is fullscreen."
},
{
name = "msaa",
type = "number",
description = "The number of antialiasing samples to use."
},
{
name = "title",
type = "string",
description = "The window title."
},
{
name = "icon",
type = "string",
description = "The path to the window icon file."
}
}
}
}
}
},
returns = {}
}
},
related = {
"lovr.load"
},
examples = {
{
description = "A noop conf.lua that sets all configuration settings to their defaults:",
code = "function lovr.conf(t)\n\n -- Set the project identity\n t.identity = 'default'\n\n -- Headset settings\n t.headset.drivers = { 'openvr', 'webvr', 'fake' }\n t.headset.mirror = true\n t.headset.msaa = 4\n t.headset.offset = 1.7\n\n -- Enable or disable different modules\n t.modules.audio = true\n t.modules.data = true\n t.modules.event = true\n t.modules.graphics = true\n t.modules.headset = true\n t.modules.math = true\n t.modules.physics = true\n t.modules.thread = true\n t.modules.timer = true\n\n -- Configure gamma correction\n t.gammacorrect = false\n\n -- Configure the desktop window\n t.window.width = 1080\n t.window.height = 600\n t.window.fullscreen = false\n t.window.msaa = 0\n t.window.title = 'LÖVR'\n t.window.icon = nil\nend"
}
},
notes = "Disabling the `headset` module can improve startup time a lot if you aren't intending to use `lovr.headset`.\n\nYou can set `t.window` to nil to avoid creating the window. You can do it yourself later by using `lovr.graphics.createWindow`.\n\nIf the `lovr.graphics` module is disabled or the window isn't created, attempting to use any functionality requiring graphics may cause a crash.\n\nThe `headset.offset` field is a vertical offset applied to the scene for headsets that do not center their tracking origin on the floor. This can be thought of as a \"default user height\". Setting this offset makes it easier to design experiences that work in both seated and standing VR configurations."
},
{
name = "controlleradded",
tag = "callbacks",
summary = "Called when a Controller is connected.",
description = "This callback is called when a Controller is connected, discovered, or woken up.",
key = "lovr.controlleradded",
module = "lovr",
related = {
"lovr.controllerremoved",
"lovr.headset.getControllers",
"lovr.headset.getControllerCount"
},
variants = {
{
arguments = {
{
name = "controller",
type = "Controller",
description = "The new controller object."
}
},
returns = {}
}
}
},
{
name = "controllerpressed",
tag = "callbacks",
summary = "Called when a Controller button is pressed.",
description = "This callback is called when a button on a Controller is pressed.",
key = "lovr.controllerpressed",
module = "lovr",
related = {
"lovr.controllerreleased",
"Controller:isDown",
"ControllerButton"
},
variants = {
{
arguments = {
{
name = "controller",
type = "Controller",
description = "The new controller object."
},
{
name = "button",
type = "ControllerButton",
description = "The button that was pressed."
}
},
returns = {}
}
}
},
{
name = "controllerreleased",
tag = "callbacks",
summary = "Called when a Controller button is released.",
description = "This callback is called when a button on a Controller is released.",
key = "lovr.controllerreleased",
module = "lovr",
related = {
"lovr.controllerpressed",
"Controller:isDown",
"ControllerButton"
},
variants = {
{
arguments = {
{
name = "controller",
type = "Controller",
description = "The new controller object."
},
{
name = "button",
type = "ControllerButton",
description = "The button that was released."
}
},
returns = {}
}
}
},
{
name = "controllerremoved",
tag = "callbacks",
summary = "Called when a Controller is disconnected.",
description = "This callback is called when a Controller is disconnected or turned off.",
key = "lovr.controllerremoved",
module = "lovr",
related = {
"lovr.controlleradded",
"lovr.headset.getControllers",
"lovr.headset.getControllerCount"
},
variants = {
{
arguments = {
{
name = "controller",
type = "Controller",
description = "The controller that was removed."
}
},
returns = {}
}
}
},
{
name = "draw",
tag = "callbacks",
summary = "Called continuously to render frames to the display.",
description = "This callback is called every frame. Use it to render the scene. If a VR headset is connected, this function will be called twice per frame (once for each eye) and the function will instead draw to the headset's display.",
key = "lovr.draw",
module = "lovr",
related = {
"lovr.headset.renderTo"
},
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "errhand",
tag = "callbacks",
summary = "Called when an error occurs.",
description = "The `lovr.errhand` callback is run whenever an error occurs. It receives a single string parameter containing the error message. It should return a function to run in a loop to show the error screen.\n\nA default error handler is supplied that renders the error message as text to the headset and to the window.",
key = "lovr.errhand",
module = "lovr",
variants = {
{
arguments = {
{
name = "message",
type = "string",
description = "The error message."
}
},
returns = {
{
name = "handler",
type = "function",
description = "The error handler function."
}
}
}
},
examples = {
{
code = "function lovr.errhand(message)\n print('ohh NOOOO!', message)\n return function()\n lovr.graphics.print('There was an error', 0, 2, -5)\n end\nend"
}
},
related = {
"lovr.quit"
}
},
{
name = "focus",
tag = "callbacks",
summary = "Called when the application gets or loses focus.",
description = "The `lovr.focus` callback is called whenever the application acquires or loses focus (for example, when opening or closing the Steam dashboard). The callback receives a single argument, focused, which is a boolean indicating whether or not the application is now focused. It may make sense to pause the game or reduce visual fidelity when the application loses focus.",
key = "lovr.focus",
module = "lovr",
related = {},
variants = {
{
arguments = {
{
name = "focused",
type = "boolean",
description = "Whether the program is now focused."
}
},
returns = {}
}
}
},
{
name = "load",
tag = "callbacks",
summary = "Called once at startup.",
description = "This callback is called once when the app starts. It should be used to perform initial setup work, like loading resources and initializing classes and variables.",
key = "lovr.load",
module = "lovr",
variants = {
{
arguments = {
{
name = "args",
type = "table",
description = "The command line arguments provided to the program."
}
},
returns = {}
}
},
examples = {
{
code = "function lovr.load(args)\n model = lovr.graphics.newModel('cena.fbx')\n texture = lovr.graphics.newTexture('cena.png')\n levelGeometry = lovr.graphics.newMesh(1000)\n effects = lovr.graphics.newShader('vert.glsl', 'frag.glsl')\n loadLevel(1)\nend"
}
},
related = {
"lovr.quit"
}
},
{
name = "mount",
tag = "callbacks",
summary = "Called when the headset is put on or taken off.",
description = "The `lovr.mount` callback is called when the headset is put on or taken off. This hardware feature is sometimes called a \"proximity sensor\" and it not supported by all headsets. You can use it to pause the app or show a message in the window if the headset isn't put on yet.",
key = "lovr.mount",
module = "lovr",
related = {},
variants = {
{
arguments = {
{
name = "mounted",
type = "boolean",
description = "Whether the headset is mounted."
}
},
returns = {}
}
}
},
{
name = "quit",
tag = "callbacks",
summary = "Called before quitting.",
description = "This callback is called right before the game is about to quit. Use it to perform any cleanup you need to do. You can also return a \"truthy\" value from this callback to abort quitting.",
key = "lovr.quit",
module = "lovr",
variants = {
{
arguments = {},
returns = {
{
name = "abort",
type = "boolean",
description = "Whether quitting should be aborted."
}
}
}
},
examples = {
{
code = "function lovr.quit()\n if shouldQuit() then\n return false\n else\n return true\n end\nend"
}
},
related = {
"lovr.event.quit",
"lovr.load"
}
},
{
name = "run",
tag = "callbacks",
summary = "The main entry point.",
description = "This callback is the main entry point for a LÖVR program. It is responsible for calling `lovr.load` and returning the main loop function.",
key = "lovr.run",
module = "lovr",
variants = {
{
arguments = {},
returns = {
{
name = "loop",
type = "function",
description = "The main loop function. It should return nil to continue running, \"restart\" to restart the app, or a number representing an exit status.",
arguments = {},
returns = {
{
name = "result",
type = "*"
}
}
}
}
}
},
examples = {
{
description = "The default `lovr.run`:",
code = "function lovr.run()\n lovr.timer.step()\n if lovr.load then lovr.load() end\n return function()\n lovr.event.pump()\n for name, a, b, c, d in lovr.event.poll() do\n if name == 'quit' and (not lovr.quit or not lovr.quit()) then\n return a or 0\n end\n if lovr.handlers[name] then lovr.handlers[name](a, b, c, d) end\n end\n local dt = lovr.timer.step()\n if lovr.headset then\n lovr.headset.update(dt)\n end\n if lovr.audio then\n lovr.audio.update()\n if lovr.headset then\n lovr.audio.setOrientation(lovr.headset.getOrientation())\n lovr.audio.setPosition(lovr.headset.getPosition())\n lovr.audio.setVelocity(lovr.headset.getVelocity())\n end\n end\n if lovr.update then lovr.update(dt) end\n if lovr.graphics then\n lovr.graphics.origin()\n if lovr.draw then\n if lovr.headset then\n lovr.headset.renderTo(lovr.draw)\n else\n lovr.graphics.clear()\n lovr.draw()\n end\n end\n lovr.graphics.present()\n end\n end\nend"
}
},
related = {
"lovr.load",
"lovr.quit"
}
},
{
name = "threaderror",
tag = "callbacks",
summary = "Called when an error occurs in a thread.",
description = "The `lovr.threaderror` callback is called whenever an error occurs in a Thread. It receives a the Thread object where the error occurred and an error message.\n\nThe default implementation of this callback will call `lovr.errhand` with the error.",
key = "lovr.threaderror",
module = "lovr",
related = {
"Thread",
"Thread:getError",
"lovr.errhand"
},
variants = {
{
arguments = {
{
name = "thread",
type = "Thread",
description = "The Thread that errored."
},
{
name = "message",
type = "string",
description = "The error message."
}
},
returns = {}
}
}
},
{
name = "update",
tag = "callbacks",
summary = "Called every frame to update the application logic.",
description = "The `lovr.update` callback should be used to update your game's logic. It receives a single parameter, `dt`, which represents the amount of elapsed time between frames. You can use this value to scale timers, physics, and animations in your game so they play at a smooth, consistent speed.",
key = "lovr.update",
module = "lovr",
variants = {
{
arguments = {
{
name = "dt",
type = "number",
description = "The number of seconds elapsed since the last update."
}
},
returns = {}
}
},
examples = {
{
code = "function lovr.update(dt)\n ball.vy = ball.vy + ball.gravity * dt\n ball.y = ball.y + ball.vy * dt\nend"
}
},
related = {
"lovr.timer.getDelta"
}
}
},
modules = {
{
name = "enet",
tag = "library",
summary = "Multiplayer utilities.",
description = "ENet is a UDP networking library bundled with LÖVR that allows you to create multiplayer experiences.\n\nTo use it, `require` the `enet` module.\n\nMore information, including full documentation and examples can be found on the [lua-enet](http://leafo.net/lua-enet/) page.",
key = "enet",
functions = {},
objects = {},
enums = {},
external = true,
examples = {
{
description = "Here's a simple echo server example. The client sends a message to the server and waits for a response. The server waits for a message and sends it back to the client.",
code = "-- client/main.lua\nlocal enet = require 'enet'\n\nfunction lovr.load()\n local host = enet.host_create()\n local server = host:connect('localhost:6789')\n\n local done = false\n while not done do\n local event = host:service(100)\n if event then\n if event.type == 'connect' then\n print('Connected to', event.peer)\n event.peer:send('hello world')\n elseif event.type == 'receive' then\n print('Got message: ', event.data, event.peer)\n done = true\n end\n end\n end\n\n server:disconnect()\n host:flush()\nend\n\n-- server/main.lua\nlocal enet = require 'enet'\n\nfunction lovr.load()\n local host = enet.host_create('localhost:6789')\n while true do\n local event = host:service(100)\n if event and event.type == 'receive' then\n print('Got message: ', event.data, event.peer)\n event.peer:send(event.data)\n end\n end\nend"
}
}
},
{
name = "json",
tag = "library",
summary = "Encodes and decodes JSON.",
description = "The json module exposes functions for encoding and decoding JSON. You can use it by requiring the `json` module.",
key = "json",
functions = {},
objects = {},
enums = {},
external = true,
examples = {
{
code = "local json = require 'json'\nlocal data = { health = 10, position = { 1, 2, 3 } }\nlocal encoded = json.encode(data)\nprint(encoded)\nlocal decoded = json.decode(encoded)\nprint(decoded.health, unpack(decoded.position))"
}
}
},
{
name = "lovr",
summary = "In the beginning, there was nothing.",
description = "`lovr` is the single global table that is exposed to every LÖVR app. It contains a set of **modules** and a set of **callbacks**.",
key = "lovr",
enums = {},
sections = {
{
name = "Modules",
tag = "modules",
description = "Modules are the **what** of your app; you can use the functions in modules to tell LÖVR to do things. For example, you can draw things on the screen, figure out what buttons on a controller are pressed, or load a 3D model from a file. Each module does what it says on the tin, so the `lovr.graphics` module deals with rendering graphics and `lovr.headset` allows you to interact with VR hardware."
},
{
name = "Callbacks",
tag = "callbacks",
description = "Callbacks are the **when** of the application; you write code inside callbacks which LÖVR then calls at certain points in time. For example, the `lovr.load` callback is called once at startup and `lovr.controlleradded` is called when controllers are connected."
},
{
name = "System",
tag = "system",
description = "The lovr module also exposes some functions for retrieving information about the system."
},
{
name = "Libraries",
tag = "library",
description = "A few helpful third-party libraries are included with LÖVR for convenience."
}
},
functions = {
{
name = "getOS",
tag = "system",
summary = "Get the current operating system.",
description = "Returns the current operating system.",
key = "lovr.getOS",
module = "lovr",
variants = {
{
arguments = {},
returns = {
{
name = "os",
type = "string",
description = "Either \"Windows\", \"macOS\", \"Linux\", or \"Web\"."
}
}
}
}
},
{
name = "getVersion",
tag = "system",
summary = "Get the current version.",
description = "Get the current major, minor, and patch version of LÖVR.",
key = "lovr.getVersion",
module = "lovr",
variants = {
{
arguments = {},
returns = {
{
name = "major",
type = "number",
description = "The major version."
},
{
name = "minor",
type = "number",
description = "The minor version."
},
{
name = "patch",
type = "number",
description = "The patch number."
}
}
}
}
}
},
objects = {}
},
{
name = "audio",
tag = "modules",
summary = "Plays sound.",
description = "The `lovr.audio` module is responsible for playing sound effects and music. Currently, the only supported audio format is .ogg (Vorbis). Playing a sound involves creating a `Source` object for the sound and calling `Source:play` on it.",
key = "lovr.audio",
sections = {
{
name = "Sources",
tag = "sources",
description = "Sources are objects that represent a single sound instance."
},
{
name = "Listener",
tag = "listener",
description = "The listener is a virtual object in 3D space that \"hears\" all the sounds that are playing. The listener can be positioned and oriented in 3D space, which controls how Sources in the world are heard. For example, sounds further away from the listener will be more quiet, and sounds to the left of the listener will be heard from the left speaker. By default, the listener will be synchronized with any connected headset so audio is positioned properly as the headset is moved around and rotated."
},
{
name = "Microphones",
tag = "microphones",
description = "Microphones can be used to receive audio input."
}
},
enums = {
{
name = "SourceType",
summary = "Different ways to handle audio data for Source objects.",
description = "When you create a Source, you can either decode audio data gradually over time or you can decode it all at once. Streaming it over time will use less memory but cause higher processing overhead because audio is continuously being decoded. On the other hand, decoding a sound all at once means it will take more time to load and use more memory, but after it's loaded there is virtually no processing overhead. It's recommended to use the 'static' mode for short sound effects and the 'stream' mode for longer music tracks.",
key = "SourceType",
module = "lovr.audio",
values = {
{
name = "static",
description = "Decode the entire sound file up front."
},
{
name = "stream",
description = "Decode the sound gradually over time."
}
}
},
{
name = "TimeUnit",
summary = "Time units for sound samples.",
description = "When figuring out how long a Source is or seeking to a specific position in the sound file, units can be expressed in terms of seconds or in terms of samples.",
key = "TimeUnit",
module = "lovr.audio",
values = {
{
name = "seconds",
description = "Seconds."
},
{
name = "samples",
description = "Samples."
}
}
}
},
functions = {
{
name = "getDopplerEffect",
tag = "listener",
summary = "Get the doppler effect parameters.",
description = "Returns the parameters that control the simulated doppler effect: The effect intensity and the speed of sound.",
key = "lovr.audio.getDopplerEffect",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "factor",
type = "number",
description = "The doppler effect scaling factor."
},
{
name = "speedOfSound",
type = "number",
description = "The speed of sound, in meters per second."
}
}
}
},
notes = "The default factor is 1 and the default speed of sound is 343.29."
},
{
name = "getMicrophoneNames",
tag = "microphones",
summary = "Get a table containing the names of all connected microphones.",
description = "Returns a table containing the names of all microphones connected to the system.",
key = "lovr.audio.getMicrophoneNames",
module = "lovr.audio",
related = {
"lovr.audio.newMicrophone",
"Microphone"
},
variants = {
{
arguments = {},
returns = {
{
name = "names",
type = "table",
description = "The list of microphone names as strings."
}
}
},
{
arguments = {
{
name = "t",
type = "table",
description = "A table to fill with the microphone names."
}
},
returns = {
{
name = "t",
type = "table",
description = "The original table that was passed in."
}
}
}
}
},
{
name = "getOrientation",
tag = "listener",
summary = "Get the orientation of the listener.",
description = "Returns the orientation of the virtual audio listener in angle/axis representation.",
key = "lovr.audio.getOrientation",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "angle",
type = "number",
description = "The number of radians the listener is rotated around its axis of rotation."
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation."
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation."
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation."
}
}
}
}
},
{
name = "getPosition",
tag = "listener",
summary = "Get the position of the listener.",
description = "Returns the position of the virtual audio listener, in meters.",
key = "lovr.audio.getPosition",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "x",
type = "number",
description = "The x position of the listener."
},
{
name = "y",
type = "number",
description = "The y position of the listener."
},
{
name = "z",
type = "number",
description = "The z position of the listener."
}
}
}
}
},
{
name = "getVelocity",
tag = "listener",
summary = "Get the velocity of the audio listener.",
description = "Returns the velocity of the audio listener, in meters per second. This affects the doppler effect.",
key = "lovr.audio.getVelocity",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "x",
type = "number",
description = "The x velocity."
},
{
name = "y",
type = "number",
description = "The y velocity."
},
{
name = "z",
type = "number",
description = "The z velocity."
}
}
}
},
notes = "The audio listener does not move based on its velocity."
},
{
name = "getVolume",
tag = "listener",
summary = "Get the master volume.",
description = "Returns the master volume. All Source objects have their volume multiplied by this factor.",
key = "lovr.audio.getVolume",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "volume",
type = "number",
description = "The master volume."
}
}
}
},
notes = "The default is 1.0."
},
{
name = "isSpatialized",
tag = "listener",
summary = "Check if audio is spatialized.",
description = "Returns whether or not audio is currently spatialized with HRTFs. Spatialized audio is much more immersive.",
key = "lovr.audio.isSpatialized",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "spatialized",
type = "boolean",
description = "Whether or not audio is spatialized."
}
}
}
}
},
{
name = "newMicrophone",
tag = "microphones",
summary = "Create a new Microphone.",
description = "Creates a new Microphone based on the name of an existing micrphone and a set of capture parameters. If the specified parameters are not supported, `nil` will be returned.",
key = "lovr.audio.newMicrophone",
module = "lovr.audio",
related = {
"lovr.audio.getMicrophoneNames",
"Microphone"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the microphone that this Microphone will record from."
},
{
name = "samples",
type = "number",
description = "The maximum number of samples that will be stored in the Microphone's internal buffer.",
default = "1024"
},
{
name = "sampleRate",
type = "number",
description = "The number of audio samples to record each second.",
default = "8000"
},
{
name = "bitDepth",
type = "number",
description = "The number of bits occupied by each sample. Usually 8 or 16.",
default = "16"
},
{
name = "channelCount",
type = "number",
description = "The number of channels to record (1 for mono, 2 for stereo).",
default = "1"
}
},
returns = {
{
name = "microphone",
type = "Microphone",
description = "The new Microphone, or `nil` if the capture settings are not supported."
}
}
}
}
},
{
name = "newSource",
tag = "sources",
summary = "Create a new Source.",
description = "Creates a new Source from an ogg file.",
key = "lovr.audio.newSource",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the sound to load."
},
{
name = "type",
type = "SourceType",
description = "How to stream in audio data."
}
},
returns = {
{
name = "source",
type = "Source",
description = "The new Source."
}
}
},
{
arguments = {
{
name = "blob",
type = "Blob",
description = "The Blob containing the Source data."
},
{
name = "type",
type = "SourceType",
description = "How to stream in audio data."
}
},
returns = {
{
name = "source",
type = "Source",
description = "The new Source."
}
}
},
{
arguments = {
{
name = "stream",
type = "AudioStream",
description = "The AudioStream used to stream audio data to the Source."
},
{
name = "type",
type = "SourceType",
description = "How to stream in audio data."
}
},
returns = {
{
name = "source",
type = "Source",
description = "The new Source."
}
}
},
{
arguments = {
{
name = "soundData",
type = "SoundData",
description = "The SoundData containing raw audio samples to play."
}
},
returns = {
{
name = "source",
type = "Source",
description = "The new Source."
}
}
}
}
},
{
name = "pause",
tag = "sources",
summary = "Pause all Sources.",
description = "Pause all playing audio.",
key = "lovr.audio.pause",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "resume",
tag = "sources",
summary = "Resume all Sources.",
description = "Resume all Sources. Has no effect on Sources that are playing or stopped.",
key = "lovr.audio.resume",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "rewind",
tag = "sources",
summary = "Rewind all Sources.",
description = "Rewind all playing audio.",
key = "lovr.audio.rewind",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
},
notes = "Sources that are paused will remain paused. Sources that are currently playing will restart from the beginning."
},
{
name = "setDopplerEffect",
tag = "listener",
summary = "Set the doppler effect parameters.",
description = "Sets the parameters that control the simulated doppler effect: The effect intensity and the speed of sound.",
key = "lovr.audio.setDopplerEffect",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "factor",
type = "number",
description = "The doppler effect scaling factor.",
default = "1.0"
},
{
name = "speedOfSound",
type = "number",
description = "The speed of sound, in meters per second.",
default = "343.29"
}
},
returns = {}
}
},
notes = "The default factor is 1 and the default speed of sound is 343.29."
},
{
name = "setOrientation",
tag = "listener",
summary = "Set the orientation of the listener.",
description = "Sets the orientation of the virtual audio listener in angle/axis representation.",
key = "lovr.audio.setOrientation",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "angle",
type = "number",
description = "The number of radians the listener should be rotated around its rotation axis."
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation."
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation."
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation."
}
},
returns = {}
}
}
},
{
name = "setPosition",
tag = "listener",
summary = "Set the position of the listener.",
description = "Sets the position of the virtual audio listener, in meters.",
key = "lovr.audio.setPosition",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x position of the listener."
},
{
name = "y",
type = "number",
description = "The y position of the listener."
},
{
name = "z",
type = "number",
description = "The z position of the listener."
}
},
returns = {}
}
}
},
{
name = "setVelocity",
tag = "listener",
summary = "Set the velocity of the audio listener.",
description = "Sets the velocity of the audio listener, in meters per second. This affects the doppler effect.",
key = "lovr.audio.setVelocity",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x velocity."
},
{
name = "y",
type = "number",
description = "The y velocity."
},
{
name = "z",
type = "number",
description = "The z velocity."
}
},
returns = {}
}
},
notes = "The audio listener does not move based on its velocity."
},
{
name = "setVolume",
tag = "listener",
summary = "Set the master volume.",
description = "Sets the master volume. The volume of all Sources will be multiplied by this factor.",
key = "lovr.audio.setVolume",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "volume",
type = "number",
description = "The master volume."
}
}
}
},
notes = "The default is 1.0."
},
{
name = "stop",
tag = "sources",
summary = "Stop all Sources.",
description = "Stops all audio.",
key = "lovr.audio.stop",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
},
notes = "If you want to resume the stopped audio later, see `lovr.audio.pause`."
},
{
name = "update",
tag = "sources",
summary = "Updates the audio system.",
description = "Updates all playing sources. This must be called regularly for audio playback to occur. Normally this is called for you by `lovr.run`.",
key = "lovr.audio.update",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
}
}
},
objects = {
{
name = "Microphone",
summary = "An object that records audio.",
description = "A Microphone object provides audio input by recording sounds.",
key = "Microphone",
module = "lovr.audio",
methods = {
{
name = "getBitDepth",
summary = "Get the bit depth of the Microphone.",
description = "Returns the number of bits occupied for each recorded sample. This is a rough indicator of the quality of the recording, and is 16 by default.",
key = "Microphone:getBitDepth",
module = "lovr.audio",
related = {
"Microphone:getChannelCount",
"Microphone:getSampleRate",
"lovr.audio.newMicrophone"
},
variants = {
{
arguments = {},
returns = {
{
name = "bits",
type = "number",
description = "The number of bits per sample."
}
}
}
}
},
{
name = "getChannelCount",
summary = "Get the number of channels recorded by the Microphone.",
description = "Returns the number of channels recorded by the Microphone. One recorded channel will result in a mono sound, and there will be two channels for a stereo sound. Most microphones only support recording a single channel.",
key = "Microphone:getChannelCount",
module = "lovr.audio",
related = {
"Microphone:getBitDepth",
"Microphone:getSampleRate",
"lovr.audio.newMicrophone"
},
variants = {
{
arguments = {},
returns = {
{
name = "channels",
type = "number",
description = "The number of channels recorded."
}
}
}
}
},
{
name = "getData",
summary = "Get a new SoundData with recorded audio.",
description = "Returns a new SoundData with all of the buffered audio samples that the Microphone has recorded.",
key = "Microphone:getData",
module = "lovr.audio",
related = {
"Microphone:getSampleCount",
"Microphone:startRecording",
"Microphone:stopRecording",
"Microphone:isRecording",
"SoundData"
},
variants = {
{
arguments = {},
returns = {
{
name = "channels",
type = "number",
description = "The number of channels recorded."
}
}
}
},
notes = "There's a limit on the number of samples the Microphone is able to hold, which can be set at creation time in `lovr.audio.newMicrophone`. While the Microphone is recording, be sure to call this function periodically to get a new chunk of audio in order to make room for more.\n\nYou can use `Microphone:getSampleCount` to figure out how many samples the Microphone is currently holding."
},
{
name = "getName",
summary = "Get the name of the Microphone.",
description = "Returns the name of the Microphone.",
key = "Microphone:getName",
module = "lovr.audio",
related = {
"lovr.audio.getMicrophoneNames",
"lovr.audio.newMicrophone"
},
variants = {
{
arguments = {},
returns = {
{
name = "name",
type = "string",
description = "The name of the Microphone."
}
}
}
}
},
{
name = "getSampleCount",
summary = "Get the number of recorded audio samples.",
description = "Returns the number of audio samples the Microphone has recorded so far. This will be zero if the Microphone hasn't started recording yet, see `Microphone:startRecording`.\n\nThere's a limit on the number of samples the Microphone is able to hold, which can be set at creation time in `lovr.audio.newMicrophone`. While the Microphone is recording, be sure to call `Microphone:getData` periodically to get a new chunk of audio in order to make room for more.",
key = "Microphone:getSampleCount",
module = "lovr.audio",
related = {
"Microphone:getData",
"Microphone:isRecording",
"Microphone:startRecording",
"Microphone:stopRecording",
"lovr.audio.newMicrophone"
},
variants = {
{
arguments = {},
returns = {
{
name = "samples",
type = "number",
description = "The number of recorded samples."
}
}
}
}
},
{
name = "getSampleRate",
summary = "Get the sample rate of the Microphone.",
description = "Returns the number of samples recorded each second. Higher sample rates lead to higher quality audio, but they can reduce performance and may not be supported by all microphones.",
key = "Microphone:getSampleRate",
module = "lovr.audio",
related = {
"Microphone:getBitDepth",
"Microphone:getChannelCount",
"lovr.audio.newMicrophone"
},
variants = {
{
arguments = {},
returns = {
{
name = "sampleRate",
type = "number",
description = "The number of samples recorded every second."
}
}
}
}
},
{
name = "isRecording",
summary = "Get whether the Microphone is recording.",
description = "Returns whether or not the Microphone is currently recording.",
key = "Microphone:isRecording",
module = "lovr.audio",
related = {
"Microphone:startRecording",
"Microphone:stopRecording"
},
variants = {
{
arguments = {},
returns = {
{
name = "recording",
type = "boolean",
description = "Whether the Microphone is recording."
}
}
}
}
},
{
name = "startRecording",
summary = "Start recording.",
description = "Starts recording audio samples from the Microphone. You can use `Microphone:getData` to periodically read the captured audio samples, and use `Microphone:stopRecording` when you're done.",
key = "Microphone:startRecording",
module = "lovr.audio",
related = {
"Microphone:getData",
"Microphone:stopRecording",
"Microphone:isRecording"
},
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "stopRecording",
summary = "Stop recording.",
description = "Stops recording from the Microphone.",
key = "Microphone:stopRecording",
module = "lovr.audio",
related = {
"Microphone:startRecording",
"Microphone:isRecording"
},
variants = {
{
arguments = {},
returns = {}
}
}
}
},
constructors = {
"lovr.audio.newMicrophone"
},
related = {
"lovr.audio.getMicrophoneNames",
"SoundData"
}
},
{
name = "Source",
summary = "A playable sound object.",
description = "A Source is an object representing a single sound. Currently, only ogg sounds are supported. Sources can be in three different states:\n\n
\n
\n
Playing
\n
The source is currently playing. It can be stopped, paused, or rewound.
\n
\n
\n
Paused
\n
The source is paused. It can be stopped, played/resumed, or rewound.
\n
\n
\n
Stopped
\n
The source has been stopped. It can be played.
\n
",
key = "Source",
module = "lovr.audio",
methods = {
{
name = "getBitDepth",
summary = "Get the bit depth of the Source.",
description = "Returns the number of bits per sample in the Source. This is a rough indicator of the resolution of the Source, and is usually 16.",
key = "Source:getBitDepth",
module = "lovr.audio",
related = {
"SoundData:getBitDepth",
"AudioStream:getBitDepth"
},
variants = {
{
arguments = {},
returns = {
{
name = "bits",
type = "number",
description = "The number of bits per sample."
}
}
}
}
},
{
name = "getChannelCount",
summary = "Get the number of channels in the Source.",
description = "Returns the number of channels in the Source. Mono sounds have 1 channel and stereo sounds have 2 channels.",
key = "Source:getChannelCount",
module = "lovr.audio",
related = {
"SoundData:getChannelCount",
"AudioStream:getChannelCount"
},
variants = {
{
arguments = {},
returns = {
{
name = "channels",
type = "number",
description = "The number of channels."
}
}
}
}
},
{
name = "getCone",
summary = "Get the Source's volume cone.",
description = "Returns the directional volume cone of the Source. The cone is specified by three values: `innerAngle`, `outerAngle`, and `outerVolume`. If the listener is inside the `innerAngle`, the Source won't have its volume changed. Otherwise, the volume will start to decrease, reaching a minimum volume of `outerVolume` once the listener is `outerAngle` degrees from the direction of the Source.",
key = "Source:getCone",
module = "lovr.audio",
notes = "The default `innerAngle` for a Source is `0`.\n\nThe default `outerAngle` for a Source is `2 * math.pi`.\n\nThe default `outerVolume` for a Source is `0`.\n\nMake sure to set the direction of a Source before setting its cone.",
variants = {
{
arguments = {},
returns = {
{
name = "innerAngle",
type = "number",
description = "The inner cone angle, in radians."
},
{
name = "outerAngle",
type = "number",
description = "The outer cone angle, in radians."
},
{
name = "outerVolume",
type = "number",
description = "The outer cone angle, in radians."
}
}
}
}
},
{
name = "getDirection",
summary = "Get the direction vector of the Source.",
description = "Returns the direction vector of the Source (the direction it's playing in).",
key = "Source:getDirection",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "x",
type = "number",
description = "The x component of the direction vector."
},
{
name = "y",
type = "number",
description = "The y component of the direction vector."
},
{
name = "z",
type = "number",
description = "The z component of the direction vector."
}
}
}
}
},
{
name = "getDuration",
summary = "Get the duration of the Source.",
description = "Returns the duration of the Source.",
key = "Source:getDuration",
module = "lovr.audio",
related = {
"AudioStream:getDuration",
"SoundData:getDuration"
},
variants = {
{
arguments = {
{
name = "unit",
type = "TimeUnit",
description = "The unit to return.",
default = "'seconds'"
}
},
returns = {
{
name = "duration",
type = "number",
description = "The duration of the Source."
}
}
}
}
},
{
name = "getFalloff",
summary = "Get the falloff parameters for the Source.",
description = "Returns parameters that control how the volume of the Source falls of with distance.",
key = "Source:getFalloff",
module = "lovr.audio",
related = {
"Source:getVolumeLimits",
"Source:setVolumeLimits"
},
variants = {
{
arguments = {},
returns = {
{
name = "reference",
type = "number",
description = "The distance at which the volume will start to decrease."
},
{
name = "max",
type = "number",
description = "The distance at which the Source will be its quietest."
},
{
name = "rolloff",
type = "number",
description = "How quickly the sound falls off between the reference and max distances (1.0 is the default)."
}
}
}
}
},
{
name = "getPitch",
summary = "Get the pitch of the Source.",
description = "Returns the current pitch factor of the Source. The default is 1.0.",
key = "Source:getPitch",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "pitch",
type = "number",
description = "The current pitch."
}
}
}
}
},
{
name = "getPosition",
summary = "Get the position of the Source.",
description = "Returns the position of the Source, in meters. Setting the position will cause the Source to be distorted and attenuated based on its position relative to the listener.",
key = "Source:getPosition",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "x",
type = "number",
description = "The x coordinate."
},
{
name = "y",
type = "number",
description = "The y coordinate."
},
{
name = "z",
type = "number",
description = "The z coordinate."
}
}
}
}
},
{
name = "getSampleRate",
summary = "Get the sample rate of the Source.",
description = "Returns the number of samples per second in the Source. This is usually a high number like 44100.",
key = "Source:getSampleRate",
module = "lovr.audio",
related = {
"SoundData:getSampleRate",
"AudioStream:getSampleRate"
},
variants = {
{
arguments = {},
returns = {
{
name = "frequency",
type = "number",
description = "The number of samples per second in the Source."
}
}
}
}
},
{
name = "getType",
summary = "Get the SourceType of the Source.",
description = "Returns the SourceType of the Source that controls how the Source decodes audio. See `SourceType` for more info.",
key = "Source:getType",
module = "lovr.audio",
related = {
"SourceType",
"lovr.audio.newSource"
},
variants = {
{
arguments = {},
returns = {
{
name = "type",
type = "SourceType",
description = "The SourceType of the Source."
}
}
}
}
},
{
name = "getVelocity",
summary = "Get the velocity of the Source.",
description = "Returns the velocity of the Source, in meters per second. This affects the doppler effect.",
key = "Source:getVelocity",
module = "lovr.audio",
notes = "The Source does not move based on its velocity.",
variants = {
{
arguments = {},
returns = {
{
name = "x",
type = "number",
description = "The x velocity."
},
{
name = "y",
type = "number",
description = "The y velocity."
},
{
name = "z",
type = "number",
description = "The z velocity."
}
}
}
}
},
{
name = "getVolume",
summary = "Get the volume of the Source.",
description = "Returns the current volume factor for the Source. 1.0 is the default and the maximum.",
key = "Source:getVolume",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "volume",
type = "number",
description = "The volume of the Source."
}
}
}
}
},
{
name = "getVolumeLimits",
summary = "Get the volume limits of the Source.",
description = "Returns the minimum and maximum volume of the Source. These limits have priority over the parameters set by `Source:setFalloff` and `Source:setCone`, so they can be used to make sure a Source can always be heard even if it's far away.",
key = "Source:getVolumeLimits",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "min",
type = "number",
description = "The minimum volume of the Source."
},
{
name = "max",
type = "number",
description = "The maximum volume of the Source."
}
}
}
}
},
{
name = "isLooping",
summary = "Check if the Source is looping.",
description = "Returns whether or not the Source will loop when it finishes.",
key = "Source:isLooping",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "looping",
type = "boolean",
description = "Whether or not the Source is looping."
}
}
}
}
},
{
name = "isPaused",
summary = "Check if the Source is paused.",
description = "Returns whether or not the Source is paused.",
key = "Source:isPaused",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "paused",
type = "boolean",
description = "Whether the Source is paused."
}
}
}
}
},
{
name = "isPlaying",
summary = "Check if the Source is playing.",
description = "Returns whether or not the Source is playing.",
key = "Source:isPlaying",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "playing",
type = "boolean",
description = "Whether the Source is playing."
}
}
}
}
},
{
name = "isRelative",
summary = "Check if the Source is relative to the listener.",
description = "Returns whether or not the Source is relative to the listener. If a Source is relative then its position, velocity, cone, and direction are all relative to the audio listener.",
key = "Source:isRelative",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "relative",
type = "boolean",
description = "Whether or not the Source is relative."
}
}
}
}
},
{
name = "isStopped",
summary = "Check if the Source is stopped.",
description = "Returns whether or not the Source is stopped.",
key = "Source:isStopped",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {
{
name = "stopped",
type = "boolean",
description = "Whether the Source is stopped."
}
}
}
}
},
{
name = "pause",
summary = "Pause the Source.",
description = "Pauses the source. It can be resumed with `Source:resume` or `Source:play`. If a paused source is rewound, it will remain paused.",
key = "Source:pause",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "play",
summary = "Play the Source.",
description = "Plays the Source. This has no effect if the Source is already playing.",
key = "Source:play",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "resume",
summary = "Resume the Source.",
description = "Resumes the Source.",
key = "Source:resume",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "rewind",
summary = "Rewind the Source.",
description = "Rewinds the Source, starting it over at the beginning. Paused Sources will remain paused.",
key = "Source:rewind",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "seek",
summary = "Set the playback position of the Source.",
description = "Seeks the Source to the specified position.",
key = "Source:seek",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "position",
type = "number",
description = "The position to seek to."
},
{
name = "unit",
type = "TimeUnit",
description = "The units for the seek position.",
default = "'seconds'"
}
},
returns = {}
}
}
},
{
name = "setCone",
summary = "Set the Source's volume cone.",
description = "Sets the directional volume cone of the Source. The cone is specified by three values: `innerAngle`, `outerAngle`, and `outerVolume`. If the listener is inside the `innerAngle`, the Source won't have its volume changed. Otherwise, the volume will start to decrease, reaching a minimum volume of `outerVolume` once the listener is `outerAngle` degrees from the direction of the Source.",
key = "Source:setCone",
module = "lovr.audio",
notes = "The default `innerAngle` for a Source is `0`.\n\nThe default `outerAngle` for a Source is `2 * math.pi`.\n\nThe default `outerVolume` for a Source is `0`.\n\nMake sure to set the direction of a Source before setting its cone.",
variants = {
{
arguments = {
{
name = "innerAngle",
type = "number",
description = "The inner cone angle, in radians."
},
{
name = "outerAngle",
type = "number",
description = "The outer cone angle, in radians."
},
{
name = "outerVolume",
type = "number",
description = "The outer cone angle, in radians."
}
},
returns = {}
}
}
},
{
name = "setDirection",
summary = "Set the direction vector of the Source.",
description = "Sets the direction vector of the Source (the direction it's playing in).",
key = "Source:setDirection",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x component of the direction vector."
},
{
name = "y",
type = "number",
description = "The y component of the direction vector."
},
{
name = "z",
type = "number",
description = "The z component of the direction vector."
}
},
returns = {}
}
}
},
{
name = "setFalloff",
summary = "Set the falloff parameters for the Source.",
description = "Sets parameters that control how the volume of the Source falls of with distance.",
key = "Source:setFalloff",
module = "lovr.audio",
related = {
"Source:getVolumeLimits",
"Source:setVolumeLimits"
},
variants = {
{
arguments = {
{
name = "reference",
type = "number",
description = "The distance at which the volume will start to decrease."
},
{
name = "max",
type = "number",
description = "The distance at which the Source will be its quietest."
},
{
name = "rolloff",
type = "number",
description = "How quickly the sound falls off between the reference and max distances (1.0 is the default)."
}
},
returns = {}
}
}
},
{
name = "setLooping",
summary = "Set whether or not the Source loops.",
description = "Sets whether or not the Source loops.",
key = "Source:setLooping",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "loop",
type = "boolean",
description = "Whether or not the Source will loop."
}
},
returns = {}
}
}
},
{
name = "setPitch",
summary = "Set the pitch of the Source.",
description = "Sets the pitch of the Source. The default is 1.0.",
key = "Source:setPitch",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "pitch",
type = "number",
description = "The new pitch."
}
},
returns = {}
}
}
},
{
name = "setPosition",
summary = "Set the position of the Source.",
description = "Sets the position of the Source, in meters. Setting the position will cause the Source to be distorted and attenuated based on its position relative to the listener.\n\nOnly mono sources can be positioned.",
key = "Source:setPosition",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x coordinate."
},
{
name = "y",
type = "number",
description = "The y coordinate."
},
{
name = "z",
type = "number",
description = "The z coordinate."
}
},
returns = {}
}
}
},
{
name = "setRelative",
summary = "Set whether or not the Source is relative.",
description = "Sets whether or not the Source is relative to the listener. If a Source is relative then its position, velocity, cone, and direction are all relative to the audio listener.",
key = "Source:setRelative",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "relative",
type = "boolean",
description = "Whether or not the Source is relative."
}
},
returns = {}
}
}
},
{
name = "setVelocity",
summary = "Set the velocity of the Source.",
description = "Sets the velocity of the Source, in meters per second. This affects the doppler effect.",
key = "Source:setVelocity",
module = "lovr.audio",
notes = "The Source does not move based on its velocity.",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x velocity."
},
{
name = "y",
type = "number",
description = "The y velocity."
},
{
name = "z",
type = "number",
description = "The z velocity."
}
},
returns = {}
}
}
},
{
name = "setVolume",
summary = "Set the volume of the Source.",
description = "Sets the current volume factor for the Source. 1.0 is the default and the maximum.",
key = "Source:setVolume",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "volume",
type = "number",
description = "The new volume."
}
},
returns = {}
}
}
},
{
name = "setVolumeLimits",
summary = "Set the volume limits of the Source.",
description = "Sets the minimum and maximum volume of the Source. These limits have priority over the parameters set by `Source:setFalloff` and `Source:setCone`, so they can be used to make sure a Source can always be heard even if it's far away.",
key = "Source:setVolumeLimits",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "min",
type = "number",
description = "The minimum volume of the Source."
},
{
name = "max",
type = "number",
description = "The maximum volume of the Source."
}
},
returns = {}
}
}
},
{
name = "stop",
summary = "Stop the Source.",
description = "Stops the source.",
key = "Source:stop",
module = "lovr.audio",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "tell",
summary = "Get the playback position of the Source.",
description = "Returns the current playback position of the Source.",
key = "Source:tell",
module = "lovr.audio",
variants = {
{
arguments = {
{
name = "unit",
type = "TimeUnit",
description = "The unit to return.",
default = "'seconds'"
}
},
returns = {
{
name = "position",
type = "number",
description = "The current playback position."
}
}
}
}
}
},
constructors = {
"lovr.audio.newSource"
}
}
}
},
{
name = "data",
tag = "modules",
summary = "Exposes low level functions for working with data.",
description = "The `lovr.data` module provides functions for accessing underlying data representations for several LÖVR objects.",
key = "lovr.data",
functions = {
{
name = "newAudioStream",
summary = "Create a new AudioStream.",
description = "Creates a new AudioStream from ogg data.",
key = "lovr.data.newAudioStream",
module = "lovr.data",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the audio file to load."
},
{
name = "bufferSize",
type = "number",
description = "The size of the stream's audio buffer, in samples.",
default = "4096"
}
},
returns = {
{
name = "audioStream",
type = "AudioStream",
description = "The new AudioStream."
}
}
},
{
arguments = {
{
name = "blob",
type = "Blob",
description = "The Blob containing audio data to decode."
},
{
name = "bufferSize",
type = "number",
description = "The size of the stream's audio buffer, in samples.",
default = "4096"
}
},
returns = {
{
name = "audioStream",
type = "AudioStream",
description = "The new AudioStream."
}
}
}
}
},
{
name = "newBlob",
summary = "Create a new Blob.",
description = "Creates a new Blob. A Blob is a piece of binary data.",
key = "lovr.data.newBlob",
module = "lovr.data",
notes = "Note that `VertexData` and `TextureData` are Blobs and can be cloned using this function.",
variants = {
{
arguments = {
{
name = "size",
type = "number",
description = "The amount of data to allocate for the Blob, in bytes. Its content will be set to zero."
},
{
name = "name",
type = "string",
description = "A name for the Blob (used in error messages)",
default = "''"
}
},
returns = {
{
name = "blob",
type = "Blob",
description = "The new Blob."
}
}
},
{
arguments = {
{
name = "contents",
type = "string",
description = "A string containing the Blob's contents."
},
{
name = "name",
type = "string",
description = "A name for the Blob (used in error messages)",
default = "''"
}
},
returns = {
{
name = "blob",
type = "Blob",
description = "The new Blob."
}
}
},
{
arguments = {
{
name = "source",
type = "Blob",
description = "A Blob to copy the contents from."
},
{
name = "name",
type = "string",
description = "A name for the Blob (used in error messages)",
default = "''"
}
},
returns = {
{
name = "blob",
type = "Blob",
description = "The new Blob."
}
}
}
}
},
{
name = "newModelData",
summary = "Create a new ModelData.",
description = "Creates a new ModelData from a 3D model file.",
key = "lovr.data.newModelData",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "modelData",
type = "ModelData",
description = "The new ModelData."
}
}
},
{
arguments = {
{
name = "blob",
type = "Blob",
description = "The Blob containing model to decode."
}
},
returns = {
{
name = "modelData",
type = "ModelData",
description = "The new ModelData."
}
}
}
}
},
{
name = "newRasterizer",
summary = "Create a new Rasterizer.",
description = "Creates a new Rasterizer from a TTF file.",
key = "lovr.data.newRasterizer",
module = "lovr.data",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the font file to load."
},
{
name = "size",
type = "number",
description = "The resolution to render the fonts at, in pixels.",
default = "32"
}
},
returns = {
{
name = "rasterizer",
type = "Rasterizer",
description = "The new Rasterizer."
}
}
},
{
arguments = {
{
name = "blob",
type = "Blob",
description = "The Blob containing font data."
},
{
name = "size",
type = "number",
description = "The resolution to render the fonts at, in pixels.",
default = "32"
}
},
returns = {
{
name = "rasterizer",
type = "Rasterizer",
description = "The new Rasterizer."
}
}
}
}
},
{
name = "newSoundData",
summary = "Create a new SoundData.",
description = "Creates a new SoundData. You can pass a filename or Blob to decode, an existing AudioStream to decode audio samples from, or you can create an empty SoundData that is able to hold a certain number of samples.",
key = "lovr.data.newSoundData",
module = "lovr.data",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the sound to decode."
}
},
returns = {
{
name = "soundData",
type = "TextureData",
description = "The new TextureData."
}
}
},
{
arguments = {
{
name = "samples",
type = "number",
description = "The total number of samples in each channel."
},
{
name = "sampleRate",
type = "number",
description = "The number of samples per second.",
default = "44100"
},
{
name = "bitDepth",
type = "number",
description = "The number of bits stored for each sample.",
default = "16"
}
},
returns = {
{
name = "soundData",
type = "TextureData",
description = "The new TextureData."
}
}
},
{
arguments = {},
returns = {
{
name = "soundData",
type = "TextureData",
description = "The new TextureData."
}
}
},
{
arguments = {
{
name = "blob",
type = "string",
description = "The Blob containing sound data to decode."
}
},
returns = {
{
name = "soundData",
type = "TextureData",
description = "The new TextureData."
}
}
}
}
},
{
name = "newTextureData",
summary = "Create a new TextureData.",
description = "Creates a new TextureData with a given width and height or from an image file.",
key = "lovr.data.newTextureData",
module = "lovr.data",
variants = {
{
description = "Load image data from a file.",
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the image to load."
}
},
returns = {
{
name = "textureData",
type = "TextureData",
description = "The new TextureData."
}
}
},
{
description = "Create an empty TextureData, initializing all color components to 0.",
arguments = {
{
name = "width",
type = "number",
description = "The width of the texture data."
},
{
name = "height",
type = "number",
description = "The height of the texture data."
},
{
name = "format",
type = "TextureFormat",
description = "The format of the texture's pixels.",
default = "rgba"
}
},
returns = {
{
name = "textureData",
type = "TextureData",
description = "The new TextureData."
}
}
},
{
description = "Decode image data from a Blob.",
arguments = {
{
name = "blob",
type = "Blob",
description = "The Blob containing image data to decode."
}
},
returns = {
{
name = "textureData",
type = "TextureData",
description = "The new TextureData."
}
}
}
}
},
{
name = "newVertexData",
summary = "Create a new VertexData.",
description = "Creates a new VertexData with a given capacity and format.",
key = "lovr.data.newVertexData",
module = "lovr.data",
notes = "The format table specifies the data held in each vertex. Each entry in the table indicates the name of the attribute, the data type, and the number of components in the attribute. The default format table contains attributes for vertex positions, normals and texture coordinates:\n\n {\n { 'lovrPosition', 'float', 3 },\n { 'lovrNormal', 'float', 3 },\n { 'lovrTexCoord', 'float', 2 }\n }",
variants = {
{
arguments = {
{
name = "count",
type = "number",
description = "The maximum number of vertices the VertexData can hold."
},
{
name = "format",
type = "table",
description = "The format table containing the vertex layout for the VertexData.",
default = "nil"
}
},
returns = {
{
name = "vertexData",
type = "VertexData",
description = "The new VertexData."
}
}
}
}
}
},
enums = {},
objects = {
{
name = "AudioStream",
summary = "An object that gradually decodes audio data.",
description = "An AudioStream is an object that reads and decodes compressed sound data. All Source objects are powered by AudioStreams.\n\nUsually you can just use Sources without having to deal with AudioStreams, but sometimes you may need low-level access to the audio stream.",
key = "AudioStream",
module = "lovr.data",
methods = {
{
name = "decode",
summary = "Decode the next chunk of audio in the AudioStream.",
description = "Returns a new SoundData containing the next chunk of audio in the AudioStream.",
key = "AudioStream:decode",
module = "lovr.data",
notes = "This function may return nil if there isn't any audio left in the stream.",
variants = {
{
arguments = {},
returns = {
{
name = "soundData",
type = "SoundData",
description = "The SoundData object containing raw audio samples."
}
}
}
}
},
{
name = "getBitDepth",
summary = "Get the bit depth of the AudioStream.",
description = "Returns the number of bits per sample in the stream's sound data. This is a rough indicator of the \"resolution\" of the sound, and is usually 16.",
key = "AudioStream:getBitDepth",
module = "lovr.data",
related = {
"SoundData:getBitDepth",
"Source:getBitDepth"
},
variants = {
{
arguments = {},
returns = {
{
name = "bits",
type = "number",
description = "The number of bits per sample."
}
}
}
}
},
{
name = "getChannelCount",
summary = "Get the number of channels in the AudioStream.",
description = "Returns the number of channels present in the stream's sound data. Mono sounds have 1 channel and stereo sounds have 2 channels.",
key = "AudioStream:getChannelCount",
module = "lovr.data",
related = {
"SoundData:getChannelCount",
"Source:getChannelCount"
},
variants = {
{
arguments = {},
returns = {
{
name = "channels",
type = "number",
description = "The number of channels."
}
}
}
}
},
{
name = "getDuration",
summary = "Get the duration of the AudioStream.",
description = "Returns the duration of the sound data in seconds.",
key = "AudioStream:getDuration",
module = "lovr.data",
related = {
"SoundData:getDuration",
"Source:getDuration"
},
variants = {
{
arguments = {},
returns = {
{
name = "duration",
type = "number",
description = "The duration of the sound."
}
}
}
}
},
{
name = "getSampleRate",
summary = "Get the sample rate of the AudioStream.",
description = "Returns the number of samples per second in the stream's sound data. This is usually a high number like 44100.",
key = "AudioStream:getSampleRate",
module = "lovr.data",
related = {
"SoundData:getSampleRate",
"Source:getSampleRate"
},
variants = {
{
arguments = {},
returns = {
{
name = "frequency",
type = "number",
description = "The number of samples per second in the AudioStream."
}
}
}
}
}
},
constructors = {
"lovr.data.newAudioStream"
}
},
{
name = "Blob",
summary = "A chunk of binary data.",
description = "A Blob is an object that holds binary data. It can be passed to most functions that take filename arguments, like `lovr.graphics.newModel` or `lovr.audio.newSource`. Blobs aren't usually necessary for simple projects, but they can be really helpful if:\n\n- You need to work with low level binary data, potentially using the LuaJIT FFI for increased\n performance.\n- You are working with data that isn't stored as a file, such as programmatically generated data\n or a string from a network request.\n- You want to load data from a file once and then use it to create many different objects.\n\nA Blob's size cannot be changed once it is created.",
key = "Blob",
module = "lovr.data",
methods = {
{
name = "getName",
summary = "Get the label of the Blob.",
description = "Returns the filename the Blob was loaded from, or the custom name given to it when it was created. This label is also used in error messages.",
key = "Blob:getName",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "name",
type = "string",
description = "The name of the Blob."
}
}
}
}
},
{
name = "getPointer",
summary = "Get a raw pointer to the Blob's data.",
description = "Returns a raw pointer to the Blob's data. This can be used to interface with other C libraries using the LuaJIT FFI. Use this only if you know what you're doing!",
key = "Blob:getPointer",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "pointer",
type = "userdata",
description = "A pointer to the data."
}
}
}
}
},
{
name = "getSize",
summary = "Get the size of the Blob's data.",
description = "Returns the size of the Blob's contents, in bytes.",
key = "Blob:getSize",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "bytes",
type = "number",
description = "The size of the Blob, in bytes."
}
}
}
}
},
{
name = "getString",
summary = "Get the Blob's contents as a string.",
description = "Returns a binary string containing the Blob's data.",
key = "Blob:getString",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "data",
type = "string",
description = "The Blob's data."
}
}
}
},
examples = {
{
description = "Manually copy a file using Blobs:",
code = "blob = lovr.filesystem.newBlob('image.png')\nlovr.filesystem.write('copy.png', blob:getString())"
}
}
}
},
constructors = {
"lovr.data.newBlob",
"lovr.filesystem.newBlob"
}
},
{
name = "ModelData",
summary = "An object that loads and stores data for 3D models.",
description = "A ModelData is a container object that loads and holds data contained in 3D model files. This can include a variety of things like the node structure of the asset, the `VertexData` it contains, the `TextureData` and `Material` properties, and any included animations.\n\nThe current supported formats are `obj`, `fbx`, and `gltf`. glTF files do not currently load animations.\n\nUsually you can just load a `Model` directly, but using a `ModelData` can be helpful if you want to load models in a thread or access more low-level information about the Model.",
key = "ModelData",
module = "lovr.data",
methods = {
{
name = "getAnimationCount",
summary = "Get the number of animations in the ModelData.",
description = "Returns the number of animations in the ModelData.",
key = "ModelData:getAnimationCount",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "count",
type = "number",
description = "The number of animations in the ModelData."
}
}
}
}
},
{
name = "getDiffuseColor",
summary = "Get the diffuse color of a material in the ModelData.",
description = "Returns the diffuse color of a material in the ModelData.",
key = "ModelData:getDiffuseColor",
module = "lovr.data",
related = {
"ModelData:getDiffuseTexture",
"ModelData:getEmissiveColor",
"Material:getColor",
"MaterialColor"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "r",
type = "number",
description = "The red channel of the diffuse color, from 0.0 to 1.0."
},
{
name = "g",
type = "number",
description = "The green channel of the diffuse color, from 0.0 to 1.0."
},
{
name = "b",
type = "number",
description = "The blue channel of the diffuse color, from 0.0 to 1.0."
},
{
name = "a",
type = "number",
description = "The alpha channel of the diffuse color, from 0.0 to 1.0."
}
}
}
}
},
{
name = "getDiffuseTexture",
summary = "Get the diffuse texture of a material in the ModelData.",
description = "Returns the diffuse texture of a material in the ModelData.",
key = "ModelData:getDiffuseTexture",
module = "lovr.data",
related = {
"ModelData:getDiffuseColor",
"Material:getTexture",
"MaterialTexture"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "texture",
type = "TextureData",
description = "The diffuse texture data."
}
}
}
}
},
{
name = "getEmissiveColor",
summary = "Get the emissive color of a material in the ModelData.",
description = "Returns the emissive color of a material in the ModelData.",
key = "ModelData:getEmissiveColor",
module = "lovr.data",
related = {
"ModelData:getEmissiveTexture",
"ModelData:getDiffuseColor",
"Material:getColor",
"MaterialColor"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "r",
type = "number",
description = "The red channel of the emissive color, from 0.0 to 1.0."
},
{
name = "g",
type = "number",
description = "The green channel of the emissive color, from 0.0 to 1.0."
},
{
name = "b",
type = "number",
description = "The blue channel of the emissive color, from 0.0 to 1.0."
},
{
name = "a",
type = "number",
description = "The alpha channel of the emissive color, from 0.0 to 1.0."
}
}
}
}
},
{
name = "getEmissiveTexture",
summary = "Get the emissive texture of a material in the ModelData.",
description = "Returns the emissive texture of a material in the ModelData.",
key = "ModelData:getEmissiveTexture",
module = "lovr.data",
related = {
"ModelData:getEmissiveColor",
"Material:getTexture",
"MaterialTexture"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "texture",
type = "TextureData",
description = "The emissive texture data."
}
}
}
}
},
{
name = "getGlobalNodeTransform",
summary = "Get the global transform of a node.",
description = "Returns the transform of a node in the ModelData relative to the root.",
key = "ModelData:getGlobalNodeTransform",
module = "lovr.data",
related = {
"ModelData:getLocalNodeTransform"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node (1-indexed)."
}
},
returns = {
{
name = "x",
type = "number",
description = "The x position of the node."
},
{
name = "y",
type = "number",
description = "The y position of the node."
},
{
name = "z",
type = "number",
description = "The z position of the node."
},
{
name = "sx",
type = "number",
description = "The x scale of the node."
},
{
name = "sy",
type = "number",
description = "The y scale of the node."
},
{
name = "sz",
type = "number",
description = "The z scale of the node."
},
{
name = "angle",
type = "number",
description = "The angle the node is rotated around its axis of rotation."
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation."
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation."
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation."
}
}
},
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node (1-indexed)."
},
{
name = "transform",
type = "Transform",
description = "The Transform object to fill with the node's transform."
}
},
returns = {
{
name = "transform",
type = "Transform",
description = "The supplied Transform."
}
}
}
},
notes = "An error will be thrown if an invalid node index is supplied."
},
{
name = "getLocalNodeTransform",
summary = "Get the local transform of a node.",
description = "Returns the transform of a node in the ModelData relative to its parent.",
key = "ModelData:getLocalNodeTransform",
module = "lovr.data",
related = {
"ModelData:getGlobalNodeTransform"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node (1-indexed)."
}
},
returns = {
{
name = "x",
type = "number",
description = "The x position of the node."
},
{
name = "y",
type = "number",
description = "The y position of the node."
},
{
name = "z",
type = "number",
description = "The z position of the node."
},
{
name = "sx",
type = "number",
description = "The x scale of the node."
},
{
name = "sy",
type = "number",
description = "The y scale of the node."
},
{
name = "sz",
type = "number",
description = "The z scale of the node."
},
{
name = "angle",
type = "number",
description = "The angle the node is rotated around its axis of rotation."
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation."
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation."
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation."
}
}
},
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node (1-indexed)."
},
{
name = "transform",
type = "Transform",
description = "The Transform object to fill with the node's transform."
}
},
returns = {
{
name = "transform",
type = "Transform",
description = "The supplied Transform."
}
}
}
},
notes = "An error will be thrown if an invalid node index is supplied."
},
{
name = "getMaterialCount",
summary = "Get the number of materials in the ModelData.",
description = "Returns the number of materials in the ModelData.",
key = "ModelData:getMaterialCount",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "count",
type = "number",
description = "The number of materials in the ModelData."
}
}
}
}
},
{
name = "getMetalness",
summary = "Get the metalness factor of a material in the ModelData.",
description = "Returns the metalness factor of a material in the ModelData.",
key = "ModelData:getMetalness",
module = "lovr.data",
related = {
"ModelData:getMetalnessTexture",
"ModelData:getRoughness",
"Material:getScalar",
"MaterialScalar"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "metalness",
type = "number",
description = "The metalness factor for the material, from 0.0 to 1.0."
}
}
}
}
},
{
name = "getMetalnessTexture",
summary = "Get the metalness texture of a material in the ModelData.",
description = "Returns the metalness texture of a material in the ModelData.",
key = "ModelData:getMetalnessTexture",
module = "lovr.data",
related = {
"ModelData:getMetalness",
"ModelData:getRoughnessTexture",
"Material:getTexture",
"MaterialTexture"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "texture",
type = "TextureData",
description = "The metalness texture data."
}
}
}
}
},
{
name = "getNodeChildren",
summary = "Get the children of a node.",
description = "Returns the children of a node in the ModelData.",
key = "ModelData:getNodeChildren",
module = "lovr.data",
notes = "An error will be thrown if an invalid node index is supplied.",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node to get the children of (1-indexed)."
}
},
returns = {
{
name = "children",
type = "table",
description = "A table of node indices representing the children of the node."
}
}
},
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node to get the children of (1-indexed)."
},
{
name = "table",
type = "table",
description = "A table to fill with the children."
}
},
returns = {
{
name = "table",
type = "table",
description = "The supplied table."
}
}
}
}
},
{
name = "getNodeComponent",
summary = "Get a subcomponent of a node.",
description = "Returns a subcomponent of a node of the ModelData.\n\nEach node is composed of several pieces of geometry. These are called the components of a node. A component is a range of vertices and a material. To render a node, the appropriate material is applied and the component's range of vertices is rendered with that material.",
key = "ModelData:getNodeComponent",
module = "lovr.data",
related = {
"ModelData:getNodeComponentCount"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node to get the number of components of (1-indexed)."
},
{
name = "subcomponent",
type = "number",
description = "The index of the subcomponent to retrieve."
}
},
returns = {
{
name = "start",
type = "number",
description = "The index of the first vertex in the subcomponent."
},
{
name = "count",
type = "number",
description = "The number of vertices in the subcomponent."
},
{
name = "material",
type = "number",
description = "The index of the subcomponent's material."
}
}
}
},
notes = "An error will be thrown if an invalid node index or subcomponent index is supplied."
},
{
name = "getNodeComponentCount",
summary = "Get the number of subcomponents that comprise a node.",
description = "Returns the number of subcomponents of a node in the ModelData.\n\nEach node is composed of several pieces of geometry. These are called the components of a node. A component is a range of vertices and a material. To render a node, the appropriate material is applied and the component's range of vertices is rendered with that material.",
key = "ModelData:getNodeComponentCount",
module = "lovr.data",
related = {
"ModelData:getNodeComponent"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node to get the number of components of (1-indexed)."
}
},
returns = {
{
name = "count",
type = "number",
description = "The number of components of the node."
}
}
}
},
notes = "An error will be thrown if an invalid node index is supplied."
},
{
name = "getNodeCount",
summary = "Get the number of nodes in the ModelData.",
description = "Returns the number of nodes in the ModelData.",
key = "ModelData:getNodeCount",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "nodes",
type = "number",
description = "The number of nodes."
}
}
}
}
},
{
name = "getNodeName",
summary = "Get the name of a node.",
description = "Returns the name of a node in the ModelData.",
key = "ModelData:getNodeName",
module = "lovr.data",
notes = "An error will be thrown if an invalid node index is supplied.",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node to get the name of (1-indexed)."
}
},
returns = {
{
name = "name",
type = "string",
description = "The name of the node."
}
}
}
}
},
{
name = "getNodeParent",
summary = "Get the parent of a node.",
description = "Returns the parent of a node in the ModelData.",
key = "ModelData:getNodeParent",
module = "lovr.data",
related = {
"ModelData:getNodeChildren"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the node to get the parent of (1-indexed)."
}
},
returns = {
{
name = "parent",
type = "number",
description = "The index of the node's parent, or `nil` if the node is the root node."
}
}
}
},
notes = "An error will be thrown if an invalid node index is supplied."
},
{
name = "getNormalTexture",
summary = "Get the normal texture of a material in the ModelData.",
description = "Returns the normal texture of a material in the ModelData.",
key = "ModelData:getNormalTexture",
module = "lovr.data",
related = {
"Material:getTexture",
"MaterialTexture"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "texture",
type = "TextureData",
description = "The normal texture data."
}
}
}
}
},
{
name = "getOcclusionTexture",
summary = "Get the occlusion texture of a material in the ModelData.",
description = "Returns the occlusion texture of a material in the ModelData.",
key = "ModelData:getOcclusionTexture",
module = "lovr.data",
related = {
"Material:getTexture",
"MaterialTexture"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "texture",
type = "TextureData",
description = "The occlusion texture data."
}
}
}
}
},
{
name = "getRoughness",
summary = "Get the roughness factor of a material in the ModelData.",
description = "Returns the roughness factor of a material in the ModelData.",
key = "ModelData:getRoughness",
module = "lovr.data",
related = {
"ModelData:getMetalness",
"ModelData:getRoughnessTexture",
"Material:getScalar",
"MaterialScalar"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "roughness",
type = "number",
description = "The roughness factor for the material, from 0.0 to 1.0."
}
}
}
}
},
{
name = "getRoughnessTexture",
summary = "Get the roughness texture of a material in the ModelData.",
description = "Returns the roughness texture of a material in the ModelData.",
key = "ModelData:getRoughnessTexture",
module = "lovr.data",
related = {
"ModelData:getRoughness",
"ModelData:getMetalnessTexture",
"Material:getTexture",
"MaterialTexture"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the material."
}
},
returns = {
{
name = "texture",
type = "TextureData",
description = "The roughness texture data."
}
}
}
}
},
{
name = "getTriangle",
summary = "Get a triangle in the ModelData.",
description = "Returns a single triangle in the ModelData.",
key = "ModelData:getTriangle",
module = "lovr.data",
related = {
"ModelData:getTriangleCount"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the triangle to get."
}
},
returns = {
{
name = "i",
type = "number",
description = "The index of the first vertex in the triangle."
},
{
name = "j",
type = "number",
description = "The index of the second vertex in the triangle."
},
{
name = "k",
type = "number",
description = "The index of the third vertex in the triangle."
}
}
}
}
},
{
name = "getTriangleCount",
summary = "Get the number of triangles in the ModelData.",
description = "Returns the number of triangles in the ModelData.",
key = "ModelData:getTriangleCount",
module = "lovr.data",
related = {
"ModelData:getTriangle"
},
variants = {
{
arguments = {},
returns = {
{
name = "triangles",
type = "number",
description = "The number of triangles."
}
}
}
},
notes = "This is the number of unique triangles in the ModelData. A larger or smaller number of triangles may be rendered when the model is drawn because nodes and components of a model can be reused."
},
{
name = "getVertexData",
summary = "Get the VertexData contained in the ModelData.",
description = "Returns the VertexData contained in the ModelData.",
key = "ModelData:getVertexData",
module = "lovr.data",
related = {
"VertexData",
"ModelData:getTriangle",
"ModelData:getTriangles",
"ModelData:getTriangleCount"
},
variants = {
{
arguments = {},
returns = {
{
name = "vertexData",
type = "VertexData",
description = "The VertexData."
}
}
}
}
}
},
constructors = {
"lovr.data.newModelData"
}
},
{
name = "Rasterizer",
summary = "An object that rasterizes glyphs from font files.",
description = "A Rasterizer is an object that parses a TTF file, decoding and rendering glyphs from it.\n\nUsually you can just use `Font` objects.",
key = "Rasterizer",
module = "lovr.data",
methods = {
{
name = "getAdvance",
summary = "Get the advance of the font.",
description = "Returns the advance metric of the font, in pixels. The advance is how many pixels the font advances horizontally after each glyph is rendered. This does not include kerning.",
key = "Rasterizer:getAdvance",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "advance",
type = "number",
description = "The advance of the font, in pixels."
}
}
}
}
},
{
name = "getAscent",
summary = "Get the ascent of the font.",
description = "Returns the ascent metric of the font, in pixels. The ascent represents how far any glyph of the font ascends above the baseline.",
key = "Rasterizer:getAscent",
module = "lovr.data",
related = {
"Rasterizer:getDescent",
"Font:getAscent"
},
variants = {
{
arguments = {},
returns = {
{
name = "ascent",
type = "number",
description = "The ascent of the font, in pixels."
}
}
}
}
},
{
name = "getDescent",
summary = "Get the descent of the font.",
description = "Returns the descent metric of the font, in pixels. The descent represents how far any glyph of the font descends below the baseline.",
key = "Rasterizer:getDescent",
module = "lovr.data",
related = {
"Rasterzer:getAscent",
"Font:getDescent"
},
variants = {
{
arguments = {},
returns = {
{
name = "descent",
type = "number",
description = "The descent of the font, in pixels."
}
}
}
}
},
{
name = "getGlyphCount",
summary = "Get the number of glyphs stored in the font file.",
description = "Returns the number of glyphs stored in the font file.",
key = "Rasterizer:getGlyphCount",
module = "lovr.data",
related = {
"Rasterizer:hasGlyphs"
},
variants = {
{
arguments = {},
returns = {
{
name = "count",
type = "number",
description = "The number of glyphs stored in the font file."
}
}
}
}
},
{
name = "getHeight",
summary = "Get the height of the font.",
description = "Returns the height metric of the font, in pixels.",
key = "Rasterizer:getHeight",
module = "lovr.data",
related = {
"Font:getHeight"
},
variants = {
{
arguments = {},
returns = {
{
name = "height",
type = "number",
description = "The height of the font, in pixels."
}
}
}
}
},
{
name = "getLineHeight",
summary = "Get the line height of the font.",
description = "Returns the line height metric of the font, in pixels. This is how far apart lines are.",
key = "Rasterizer:getLineHeight",
module = "lovr.data",
related = {
"Rasterizer:getHeight",
"Font:getLineHeight",
"Font:setLineHeight"
},
variants = {
{
arguments = {},
returns = {
{
name = "height",
type = "number",
description = "The line height of the font, in pixels."
}
}
}
}
},
{
name = "hasGlyphs",
summary = "Get whether the Rasterizer can rasterize a set of glyphs.",
description = "Check if the Rasterizer can rasterize a set of glyphs.",
key = "Rasterizer:hasGlyphs",
module = "lovr.data",
related = {
"Rasterizer:getGlyphCount"
},
variants = {
{
arguments = {
{
name = "...",
type = "*",
description = "Strings (sets of characters) or numbers (character codes) to check for."
}
},
returns = {
{
name = "hasGlyphs",
type = "boolean",
description = "true if the Rasterizer can rasterize all of the supplied characters, false otherwise."
}
}
}
}
}
},
constructors = {
"lovr.data.newRasterizer"
}
},
{
name = "SoundData",
summary = "An object that holds raw audio samples.",
description = "A SoundData stores raw audio samples that make up a sound file. You can use `Source` objects to play SoundData.",
key = "SoundData",
module = "lovr.data",
methods = {
{
name = "getBitDepth",
summary = "Get the bit depth of the SoundData.",
description = "Returns the number of bits taken up by each sample in the SoundData. Higher bit depths mean the sound is higher quality and takes up more space. This is usually 8 or 16.",
key = "SoundData:getBitDepth",
module = "lovr.data",
related = {
"AudioStream:getBitDepth",
"Source:getBitDepth"
},
variants = {
{
arguments = {},
returns = {
{
name = "bitDepth",
type = "number",
description = "The size of each sample, in bits."
}
}
}
}
},
{
name = "getChannelCount",
summary = "Get the number of channels in the SoundData.",
description = "Returns the number of channels in the SoundData. Mono sounds have 1 channel and stereo sounds have 2 channels.",
key = "SoundData:getChannelCount",
module = "lovr.data",
related = {
"AudioStream:getChannelCount",
"Source:getChannelCount"
},
variants = {
{
arguments = {},
returns = {
{
name = "channels",
type = "number",
description = "The number of channels."
}
}
}
},
notes = "It's important to keep in mind the channel count if you're using `SoundData:getSample` and `SoundData:setSample`. The SoundData stores its samples in an \"interleaved\" manner, meaning the samples from different channels are stored next to each other.\n\nIf you want to get the 3rd sample of the second channel of a stereo sound, you would use sample number 5, since samples start at zero and `(sample * channelCount) + channelIndex = 5`."
},
{
name = "getDuration",
summary = "Get the duration of the SoundData.",
description = "Returns the duration of the sound data in seconds.",
key = "SoundData:getDuration",
module = "lovr.data",
related = {
"SoundData:getSampleCount",
"AudioStream:getDuration",
"Source:getDuration"
},
variants = {
{
arguments = {},
returns = {
{
name = "duration",
type = "number",
description = "The duration of the sound."
}
}
}
}
},
{
name = "getSample",
summary = "Get a sample from the SoundData.",
description = "Returns a single sample from the SoundData. Sample indices start at 0, and the returned value will be between -1 and 1.",
key = "SoundData:getSample",
module = "lovr.data",
related = {
"SoundData:getSampleCount",
"SoundData:getSampleRate"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the sample to get."
}
},
returns = {
{
name = "value",
type = "number",
description = "A number indicating the value of the sample at the given index."
}
}
}
},
notes = "Note that samples for individual channels in stereo sounds are stored next to each other."
},
{
name = "getSampleCount",
summary = "Get the number of samples stored in the SoundData.",
description = "Returns the number of samples in the SoundData (per channel).",
key = "SoundData:getSampleCount",
module = "lovr.data",
related = {
"SoundData:getSample",
"SoundData:getChannelCount",
"Source:getDuration"
},
variants = {
{
arguments = {},
returns = {
{
name = "samples",
type = "number",
description = "The total number of channels per channel."
}
}
}
}
},
{
name = "getSampleRate",
summary = "Get the sample rate of the SoundData.",
description = "Returns the number of samples per second in the SoundData. This is usually a high number like 44100.",
key = "SoundData:getSampleRate",
module = "lovr.data",
related = {
"AudioStream:getSampleRate",
"Source:getSampleRate"
},
variants = {
{
arguments = {},
returns = {
{
name = "frequency",
type = "number",
description = "The number of samples per second in the SoundData."
}
}
}
}
},
{
name = "setSample",
summary = "Modify a sample in the SoundData.",
description = "Modify a single sample in the SoundData. Sample indices start at zero, and samples should be between -1 and 1.",
key = "SoundData:setSample",
module = "lovr.data",
related = {
"SoundData:getSampleCount",
"SoundData:getSampleRate"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the sample to set."
},
{
name = "value",
type = "number",
description = "The new value of the sample."
}
},
returns = {}
}
},
notes = "Note that samples for individual channels in stereo sounds are stored next to each other."
}
},
constructors = {
"lovr.data.newSoundData",
"AudioStream:decode",
"Microphone:getData"
}
},
{
name = "TextureData",
summary = "An object that stores pixel data for Textures.",
description = "A TextureData stores raw 2D pixel info for `Texture`s. It has a width, height, and format. The TextureData can be initialized with the contents of an image file or it can be created with uninitialized contents. The supported image formats are `png`, `jpg`, `hdr`, and `dds`.\n\nUsually you can just use Textures, but TextureData can be useful if you want to manipulate individual pixels or load Textures in a background thread.",
key = "TextureData",
module = "lovr.data",
methods = {
{
name = "encode",
summary = "Encode the TextureData as png and write it to a file.",
description = "Encodes the TextureData to png and writes it to the specified file.",
key = "TextureData:encode",
module = "lovr.data",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The file to write the png data to."
}
},
returns = {
{
name = "success",
type = "boolean",
description = "Whether or not the file was successfully written to."
}
}
}
}
},
{
name = "getDimensions",
summary = "Get the dimensions of the TextureData.",
description = "Returns the dimensions of the TextureData, in pixels.",
key = "TextureData:getDimensions",
module = "lovr.data",
related = {
"TextureData:getWidth",
"TextureData:getHeight",
"Texture:getDimensions"
},
variants = {
{
arguments = {},
returns = {
{
name = "width",
type = "number",
description = "The width of the TextureData, in pixels."
},
{
name = "height",
type = "number",
description = "The height of the TextureData, in pixels."
}
}
}
}
},
{
name = "getHeight",
summary = "Get the height of the TextureData.",
description = "Returns the height of the TextureData, in pixels.",
key = "TextureData:getHeight",
module = "lovr.data",
related = {
"TextureData:getWidth",
"TextureData:getDimensions",
"Texture:getHeight"
},
variants = {
{
arguments = {},
returns = {
{
name = "height",
type = "number",
description = "The height of the TextureData, in pixels."
}
}
}
}
},
{
name = "getPixel",
summary = "Get the value of a pixel of the TextureData.",
description = "Returns the value of a pixel of the TextureData.",
key = "TextureData:getPixel",
module = "lovr.data",
related = {
"TextureData:setPixel",
"Texture:replacePixels"
},
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x coordinate of the pixel to get (0-indexed)."
},
{
name = "y",
type = "number",
description = "The y coordinate of the pixel to get (0-indexed)."
}
},
returns = {
{
name = "r",
type = "number",
description = "The red component of the pixel, from 0.0 to 1.0."
},
{
name = "g",
type = "number",
description = "The green component of the pixel, from 0.0 to 1.0."
},
{
name = "b",
type = "number",
description = "The blue component of the pixel, from 0.0 to 1.0."
},
{
name = "a",
type = "number",
description = "The alpha component of the pixel, from 0.0 to 1.0."
}
}
}
}
},
{
name = "getWidth",
summary = "Get the width of the TextureData.",
description = "Returns the width of the TextureData, in pixels.",
key = "TextureData:getWidth",
module = "lovr.data",
related = {
"TextureData:getHeight",
"TextureData:getDimensions",
"Texture:getWidth"
},
variants = {
{
arguments = {},
returns = {
{
name = "width",
type = "number",
description = "The width of the TextureData, in pixels."
}
}
}
}
},
{
name = "setPixel",
summary = "Set the value of a pixel of the TextureData.",
description = "Sets the value of a pixel of the TextureData.",
key = "TextureData:setPixel",
module = "lovr.data",
related = {
"TextureData:getPixel",
"Texture:replacePixels"
},
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x coordinate of the pixel to set (0-indexed)."
},
{
name = "y",
type = "number",
description = "The y coordinate of the pixel to set (0-indexed)."
},
{
name = "r",
type = "number",
description = "The red component of the pixel, from 0.0 to 1.0."
},
{
name = "g",
type = "number",
description = "The green component of the pixel, from 0.0 to 1.0."
},
{
name = "b",
type = "number",
description = "The blue component of the pixel, from 0.0 to 1.0."
},
{
name = "a",
type = "number",
description = "The alpha component of the pixel, from 0.0 to 1.0.",
default = "1.0"
}
},
returns = {}
}
}
}
},
constructors = {
"lovr.data.newTextureData",
"Canvas:newTextureData"
}
},
{
name = "VertexData",
summary = "Stores vertices.",
description = "VertexData stores a list of vertices, each with a set of attributes. It can be used to create or modify `Mesh` objects.",
key = "VertexData",
module = "lovr.data",
methods = {
{
name = "getCount",
summary = "Get the number vertices the VertexData can hold.",
description = "Returns the vertex capacity of the VertexData.",
key = "VertexData:getCount",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "count",
type = "number",
description = "The number of vertices the VertexData can hold."
}
}
}
}
},
{
name = "getFormat",
summary = "Get the format table of the VertexData.",
description = "Returns the format of the VertexData. The format table specifies the data held in each vertex. Each entry in the table indicates the name of the attribute, the data type, and the number of components in the attribute.",
key = "VertexData:getFormat",
module = "lovr.data",
variants = {
{
arguments = {},
returns = {
{
name = "format",
type = "table",
description = "The format table."
}
}
}
}
},
{
name = "getVertex",
summary = "Get a single vertex from the VertexData.",
description = "Gets the data for a single vertex in the VertexData. The set of data returned depends on the vertex format.",
key = "VertexData:getVertex",
module = "lovr.data",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to retrieve, starting at 1 for the first vertex."
}
},
returns = {
{
name = "...",
type = "numbers",
description = "All attributes of the vertex."
}
}
}
}
},
{
name = "getVertexAttribute",
summary = "Get an attribute of a single vertex in the VertexData.",
description = "Get the components of a specific attribute of a single vertex in the VertexData.",
key = "VertexData:getVertexAttribute",
module = "lovr.data",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to retrieve the attribute of."
},
{
name = "attribute",
type = "number",
description = "The index of the attribute to retrieve the components of."
}
},
returns = {
{
name = "...",
type = "number",
description = "The components of the vertex attribute."
}
}
}
}
},
{
name = "setVertex",
summary = "Update a single vertex in the VertexData.",
description = "Update a single vertex in the VertexData.",
key = "VertexData:setVertex",
module = "lovr.data",
notes = "Any unspecified components will be set to 0 for float and int attributes, or 255 for byte attributes.",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to set."
},
{
name = "...",
type = "number",
description = "The attributes of the vertex."
}
},
returns = {}
},
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to set."
},
{
name = "vertexData",
type = "table",
description = "A table containing the attributes of the vertex."
}
},
returns = {}
}
}
},
{
name = "setVertexAttribute",
summary = "Update a specific attribute of a single vertex in the VertexData.",
description = "Set the components of a specific attribute of a vertex in the VertexData.",
key = "VertexData:setVertexAttribute",
module = "lovr.data",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to update."
},
{
name = "attribute",
type = "number",
description = "The index of the attribute to update."
},
{
name = "...",
type = "number",
description = "Thew new components for the attribute."
}
},
returns = {}
}
}
},
{
name = "setVertices",
summary = "Update multiple vertices in the VertexData.",
description = "Update multiple vertices in the VertexData.",
key = "VertexData:setVertices",
module = "lovr.data",
notes = "The start index plus the number of vertices in the table should not exceed the maximum size of the VertexData.",
variants = {
{
arguments = {
{
name = "vertices",
type = "table",
description = "The new set of vertices."
},
{
name = "start",
type = "number",
description = "The index of the vertex to start replacing at.",
default = "1"
}
},
returns = {}
}
}
}
},
constructors = {
"lovr.data.newVertexData"
}
}
}
},
{
name = "event",
tag = "modules",
summary = "Handles events from the operating system.",
description = "The `lovr.event` module handles events from the operating system.\n\nDue to its low-level nature, it's rare to use `lovr.event` in simple projects.",
key = "lovr.event",
functions = {
{
name = "clear",
summary = "Clear the event queue.",
description = "Clears the event queue, removing any unprocessed events.",
key = "lovr.event.clear",
module = "lovr.event",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "poll",
summary = "Iterate over unprocessed events in the queue.",
description = "This function returns a Lua iterator for all of the unprocessed items in the event queue. Each event consists of a name as a string, followed by event-specific arguments. Typically this function is automatically called for you by `lovr.run`.",
key = "lovr.event.poll",
module = "lovr.event",
variants = {
{
arguments = {},
returns = {
{
name = "iterator",
type = "function",
description = "The iterator function, usable in a for loop.",
arguments = {},
returns = {}
}
}
}
}
},
{
name = "pump",
summary = "Pump new events into the queue for processing.",
description = "Fills the event queue with unprocessed events from the operating system. This function should be called often, otherwise the operating system will consider your application unresponsive. By default, this function is called automatically by `lovr.run`.",
key = "lovr.event.pump",
module = "lovr.event",
related = {
"lovr.event.poll"
},
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "push",
summary = "Manually push an event onto the queue.",
description = "Pushes an event onto the event queue. It will be processed the next time `lovr.event.poll` is called. For an event to be processed properly, there needs to be a function in the `lovr.handlers` table with a key that's the same as the event name.",
key = "lovr.event.push",
module = "lovr.event",
related = {
"lovr.event.poll",
"lovr.event.quit"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the event."
},
{
name = "...",
type = "*",
description = "The arguments for the event. Currently, up to 4 are supported."
}
},
returns = {}
}
},
notes = "Only nil, booleans, numbers, strings, and LÖVR objects are supported types for event payloads."
},
{
name = "quit",
summary = "Quit the application.",
description = "Pushes an event to quit or restart the application. An optional number can be passed to set the exit code for the application. An exit code of zero indicates normal termination, whereas a nonzero exit code indicates that an error occurred.",
key = "lovr.event.quit",
module = "lovr.event",
related = {
"lovr.quit",
"lovr.event.poll"
},
variants = {
{
arguments = {
{
name = "code",
type = "number",
description = "The exit code of the program.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "'restart'",
type = "string",
description = "Restart instead of quitting."
}
},
returns = {}
}
},
notes = "This function is equivalent to calling `lovr.event.push('quit', )`.\n\nThe program won't actually exit until the next time `lovr.event.poll` is called."
}
},
examples = {
{
description = "Adding a custom event.",
code = "function lovr.load()\n lovr.handlers['customevent'] = function(a, b, c)\n print('custom event handled with args:', a, b, c)\n end\n\n lovr.event.push('customevent', 1, 2, 3)\nend"
}
},
enums = {},
objects = {},
notes = "You can define your own custom events by adding a function to the `lovr.handlers` table with a key of the name of the event you want to add. Then, push the event using `lovr.event.push`."
},
{
name = "filesystem",
tag = "modules",
summary = "Provides access to the filesystem.",
description = "The `lovr.filesystem` module provides access to the filesystem.",
key = "lovr.filesystem",
enums = {},
notes = "LÖVR programs can only write to a single directory, called the save directory. The location of the save directory is platform-specific:\n\n
\n\n`` should be a unique identifier for your app. It can be set either in `lovr.conf` or by using `lovr.filesystem.setIdentity`.\n\nAll filenames are relative to either the save directory or the directory containing the project source. Files in the save directory take precedence over files in the project.",
functions = {
{
name = "append",
summary = "Append content to the end of a file.",
description = "Appends content to the end of the file.",
key = "lovr.filesystem.append",
module = "lovr.filesystem",
notes = "If the file does not exist, it is created.",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The file to append to."
},
{
name = "content",
type = "string",
description = "A string to write to the end of the file."
}
},
returns = {
{
name = "bytes",
type = "number",
description = "The number of bytes written."
}
}
}
}
},
{
name = "createDirectory",
summary = "Create a directory.",
description = "Creates a directory in the save directory.",
key = "lovr.filesystem.createDirectory",
module = "lovr.filesystem",
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "The directory to create."
}
},
returns = {
{
name = "success",
type = "boolean",
description = "Whether the directory was created."
}
}
}
}
},
{
name = "getAppdataDirectory",
summary = "Get the application data directory.",
description = "Returns the application data directory. This will be something like `C:\\Users\\user\\AppData` on Windows, or `/Users/user/Library/Application Support` on macOS.",
key = "lovr.filesystem.getAppdataDirectory",
module = "lovr.filesystem",
variants = {
{
arguments = {},
returns = {
{
name = "path",
type = "string",
description = "The absolute path to the appdata directory."
}
}
}
}
},
{
name = "getDirectoryItems",
summary = "Get a list of files in a directory..",
description = "Returns an unsorted table containing all files and subfolders in a directory.",
key = "lovr.filesystem.getDirectoryItems",
module = "lovr.filesystem",
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "The directory."
}
},
returns = {
{
name = "table",
type = "items",
description = "A table with a string for each file and subfolder in the directory."
}
}
}
}
},
{
name = "getExecutablePath",
summary = "Get the path of the LÖVR executable.",
description = "Returns the absolute path of the LÖVR executable.",
key = "lovr.filesystem.getExecutablePath",
module = "lovr.filesystem",
variants = {
{
arguments = {},
returns = {
{
name = "path",
type = "string",
description = "The absolute path of the LÖVR executable."
}
}
}
}
},
{
name = "getIdentity",
summary = "Get the name of the save directory.",
description = "Returns the identity of the game, which is used as the name of the save directory. The default is `default`.",
key = "lovr.filesystem.getIdentity",
module = "lovr.filesystem",
variants = {
{
arguments = {},
returns = {
{
name = "identity",
type = "string",
description = "The name of the save directory."
}
}
}
}
},
{
name = "getLastModified",
summary = "Get the modification time of a file.",
description = "Returns when a file was last modified.",
key = "lovr.filesystem.getLastModified",
module = "lovr.filesystem",
variants = {
{
arguments = {
{
name = "file",
type = "string",
description = "The file."
}
},
returns = {
{
name = "time",
type = "number",
description = "The time when the file was last modified, in seconds."
}
}
}
}
},
{
name = "getRealDirectory",
summary = "Get the absolute path to a file.",
description = "Get the absolute path of a directory containing a path in the virtual filesystem. This can be used to determine if a file is in the game's source directory or the save directory.",
key = "lovr.filesystem.getRealDirectory",
module = "lovr.filesystem",
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "The path to check."
}
},
returns = {
{
name = "realpath",
type = "string",
description = "The absolute path of the directory containing `path`."
}
}
}
}
},
{
name = "getRequirePath",
summary = "Get the require path.",
description = "Returns the require path. The require path is a semicolon-separated list of patterns that LÖVR will use to search for files when they are `require`d. Any question marks in the pattern will be replaced with the module that is being required. It is similar to Lua\\'s `package.path` variable, but the main difference is that the patterns are relative to the save directory and the project directory.\n\nFor the C require path, double question marks will be replaced by the name of the module with the operating system's native extension for shared libraries. For example, if you do `require('lib')` and the C require path is `??`, LÖVR will try to load `lib.dll` if you're on Windows or `lib.so` if you're on Linux.",
key = "lovr.filesystem.getRequirePath",
module = "lovr.filesystem",
notes = "The default reqiure path is '?.lua;?/init.lua;lua_modules/?.lua;lua_modules/?/init.lua'. The default C require path is '??'.",
variants = {
{
arguments = {},
returns = {
{
name = "path",
type = "string",
description = "The semicolon separated list of search patterns."
},
{
name = "cpath",
type = "string",
description = "The semicolon separated list of search patterns for C libraries."
}
}
}
}
},
{
name = "getSaveDirectory",
summary = "Get the location of the save directory.",
description = "Returns the absolute path to the save directory.",
key = "lovr.filesystem.getSaveDirectory",
module = "lovr.filesystem",
variants = {
{
arguments = {},
returns = {
{
name = "path",
type = "string",
description = "The absolute path to the save directory."
}
}
}
}
},
{
name = "getSize",
summary = "Get the size of a file.",
description = "Returns the size of a file, in bytes.",
key = "lovr.filesystem.getSize",
module = "lovr.filesystem",
variants = {
{
arguments = {
{
name = "file",
type = "string",
description = "The file."
}
},
returns = {
{
name = "size",
type = "number",
description = "The size of the file, in bytes."
}
}
}
}
},
{
name = "getSource",
summary = "Get the location of the project source.",
description = "Get the absolute path of the project's source directory or archive.",
key = "lovr.filesystem.getSource",
module = "lovr.filesystem",
variants = {
{
arguments = {},
returns = {
{
name = "path",
type = "string",
description = "The absolute path of the project's source."
}
}
}
}
},
{
name = "getUserDirectory",
summary = "Get the location of the user's home directory.",
description = "Returns the absolute path of the user's home directory.",
key = "lovr.filesystem.getUserDirectory",
module = "lovr.filesystem",
variants = {
{
arguments = {},
returns = {
{
name = "path",
type = "string",
description = "The absolute path of the user's home directory."
}
}
}
}
},
{
name = "getWorkingDirectory",
summary = "Get the current working directory.",
description = "Returns the absolute path of the working directory. Usually this is where the executable was started from.",
key = "lovr.filesystem.getWorkingDirectory",
module = "lovr.filesystem",
variants = {
{
arguments = {},
returns = {
{
name = "path",
type = "string",
description = "The current working directory."
}
}
}
}
},
{
name = "isDirectory",
summary = "Check whether a path is a directory.",
description = "Check if a path exists and is a directory.",
key = "lovr.filesystem.isDirectory",
module = "lovr.filesystem",
related = {
"lovr.filesystem.isFile"
},
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "The path to check."
}
},
returns = {
{
name = "isDirectory",
type = "boolean",
description = "Whether or not path is a directory."
}
}
}
}
},
{
name = "isFile",
summary = "Check whether a path is a file.",
description = "Check if a path exists and is a file.",
key = "lovr.filesystem.isFile",
module = "lovr.filesystem",
related = {
"lovr.filesystem.isDirectory"
},
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "The path to check."
}
},
returns = {
{
name = "isFile",
type = "boolean",
description = "Whether or not path is a file."
}
}
}
}
},
{
name = "isFused",
summary = "Check if the project is fused.",
description = "Returns whether the current project source is fused to the executable.",
key = "lovr.filesystem.isFused",
module = "lovr.filesystem",
variants = {
{
arguments = {},
returns = {
{
name = "fused",
type = "boolean",
description = "Whether or not the project is fused."
}
}
}
}
},
{
name = "load",
summary = "Load a file as Lua code.",
description = "Load a file containing Lua code, returning a Lua chunk that can be run.",
key = "lovr.filesystem.load",
module = "lovr.filesystem",
notes = "An error is thrown if the file contains syntax errors.",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The file to load."
}
},
returns = {
{
name = "chunk",
type = "function",
description = "The runnable chunk.",
arguments = {
{
name = "...",
type = "*"
}
},
returns = {
{
name = "...",
type = "*"
}
}
}
}
}
},
examples = {
{
description = "Safely loading code:",
code = "local success, chunk = pcall(lovr.filesystem.load, filename)\nif not success then\n print('Oh no! There was an error: ' .. tostring(chunk))\nelse\n local success, result = pcall(chunk)\n print(success, result)\nend"
}
}
},
{
name = "mount",
summary = "Mount a directory or archive.",
description = "Mounts a directory or `.zip` archive, adding it to the virtual filesystem. This allows you to read files from it.",
key = "lovr.filesystem.mount",
module = "lovr.filesystem",
related = {
"lovr.filesystem.unmount"
},
notes = "The `append` option lets you control the priority of the archive's files in the event of naming collisions.",
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "The path to mount."
},
{
name = "mountpoint",
type = "string",
description = "The path in the virtual filesystem to mount to.",
default = "'/'"
},
{
name = "append",
type = "boolean",
description = "Whether the archive will be added to the end or the beginning of the search path.",
default = "false"
}
},
returns = {}
}
},
examples = {
{
description = "Mount `data.zip` with a file `images/background.png`:",
code = "lovr.filesystem.mount('data.zip', 'assets')\nprint(lovr.filesystem.isFile('assets/images/background.png')) -- true"
}
}
},
{
name = "newBlob",
summary = "Create a new Blob from a file.",
description = "Creates a new Blob that contains the contents of a file.",
key = "lovr.filesystem.newBlob",
module = "lovr.filesystem",
related = {
"lovr.data.newBlob",
"Blob"
},
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The file to load."
}
},
returns = {
{
name = "blob",
type = "Blob",
description = "The new Blob."
}
}
}
}
},
{
name = "read",
summary = "Read a file.",
description = "Read the contents of a file.",
key = "lovr.filesystem.read",
module = "lovr.filesystem",
notes = "If the file does not exist or cannot be read, an error is thrown.",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The name of the file to read."
}
},
returns = {
{
name = "contents",
type = "string",
description = "The contents of the file."
}
}
}
}
},
{
name = "remove",
summary = "Remove a file or directory.",
description = "Remove a file or directory in the save directory.",
key = "lovr.filesystem.remove",
module = "lovr.filesystem",
notes = "A directory can only be removed if it is empty.",
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "The file or folder to remove.."
}
},
returns = {
{
name = "success",
type = "boolean",
description = "Whether the path was removed."
}
}
}
}
},
{
name = "setIdentity",
summary = "Set the name of the save directory.",
description = "Set the name of the save directory.",
key = "lovr.filesystem.setIdentity",
module = "lovr.filesystem",
variants = {
{
arguments = {
{
name = "identity",
type = "string",
description = "The new name of the save directory."
}
},
returns = {}
}
}
},
{
name = "setRequirePath",
summary = "Set the require path.",
description = "Sets the require path. The require path is a semicolon-separated list of patterns that LÖVR will use to search for files when they are `require`d. Any question marks in the pattern will be replaced with the module that is being required. It is similar to Lua\\'s `package.path` variable, but the main difference is that the patterns are relative to the save directory and the project directory.\n\nFor the C require path, double question marks will be replaced by the name of the module with the operating system's native extension for shared libraries. For example, if you do `require('lib')` and the C require path is `??`, LÖVR will try to load `lib.dll` if you're on Windows or `lib.so` if you're on Linux.",
key = "lovr.filesystem.setRequirePath",
module = "lovr.filesystem",
notes = "The default reqiure path is '?.lua;?/init.lua;lua_modules/?.lua;lua_modules/?/init.lua'. The default C require path is '??'.",
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "An optional semicolon separated list of search patterns.",
default = "nil"
},
{
name = "cpath",
type = "string",
description = "An optional semicolon separated list of search patterns for C libraries.",
default = "nil"
}
},
returns = {}
}
}
},
{
name = "setSource",
summary = "Set the project source.",
description = "Sets the location of the project's source. This can only be done once, and is usually done internally.",
key = "lovr.filesystem.setSource",
module = "lovr.filesystem",
variants = {
{
arguments = {
{
name = "identity",
type = "string",
description = "The path containing the project's source."
}
},
returns = {}
}
}
},
{
name = "unmount",
summary = "Unmount a mounted archive.",
description = "Unmounts a directory or archive previously mounted with `lovr.filesystem.mount`.",
key = "lovr.filesystem.unmount",
module = "lovr.filesystem",
related = {
"lovr.filesystem.mount"
},
variants = {
{
arguments = {
{
name = "path",
type = "string",
description = "The path to unmount."
}
},
returns = {
{
name = "success",
type = "boolean",
description = "Whether the archive was unmounted."
}
}
}
}
},
{
name = "write",
summary = "Write to a file.",
description = "Write to a file.",
key = "lovr.filesystem.write",
module = "lovr.filesystem",
notes = "If the file does not exist, it is created.",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The file to write to."
},
{
name = "content",
type = "string",
description = "A string to write to the file."
}
},
returns = {
{
name = "bytes",
type = "number",
description = "The number of bytes written."
}
}
}
}
}
},
objects = {}
},
{
name = "graphics",
tag = "modules",
summary = "Renders graphics.",
description = "The `lovr.graphics` module renders graphics to displays. Anything rendered using this module will automatically show up in the VR headset if one is connected, otherwise it will just show up in a window on the desktop.",
key = "lovr.graphics",
sections = {
{
name = "Drawing",
tag = "graphicsPrimitives",
description = "Simple functions for drawing simple shapes."
},
{
name = "Objects",
tag = "graphicsObjects",
description = "Several graphics-related objects can be created with the graphics module. Try to avoid calling these functions in `lovr.update` or `lovr.draw`, because then the objects will be loaded every frame, which can really slow things down!"
},
{
name = "Transforms",
tag = "graphicsTransforms",
description = "These functions manipulate the 3D coordinate system. By default the negative z axis points forwards and the positive y axis points up. Manipulating the coordinate system can be used to create a hierarchy of rendered objects. Thinking in many different coordinate systems can be challenging though, so be sure to brush up on 3D math first!"
},
{
name = "State",
tag = "graphicsState",
description = "These functions get or set graphics state. Graphics state is is a collection of small settings like the background color of the scene or the active shader. Keep in mind that all this state is **global**, so if you change a setting, the change will persist until that piece of state is changed again."
},
{
name = "Window",
tag = "window",
description = "Get info about the desktop window or operate on the underlying graphics context."
}
},
enums = {
{
name = "ArcMode",
summary = "Different ways arcs can be drawn.",
description = "Different ways arcs can be drawn with `lovr.graphics.arc`.",
key = "ArcMode",
module = "lovr.graphics",
values = {
{
name = "pie",
description = "The arc is drawn with the center of its circle included in the list of points (default)."
},
{
name = "open",
description = "The curve of the arc is drawn as a single line."
},
{
name = "closed",
description = "The starting and ending points of the arc's curve are connected."
}
}
},
{
name = "BlendAlphaMode",
summary = "Different ways of blending alpha.",
description = "Different ways the alpha channel of pixels affects blending.",
key = "BlendAlphaMode",
module = "lovr.graphics",
notes = "The premultiplied mode should be used if pixels being drawn have already been blended, or \"pre-multiplied\", by the alpha channel. This happens when rendering a framebuffer that contains pixels with transparent alpha values, since the stored color values have already been faded by alpha and don't need to be faded a second time with the alphamultiply blend mode.",
related = {
"BlendMode",
"lovr.graphics.getBlendMode",
"lovr.graphics.setBlendMode"
},
values = {
{
name = "alphamultiply",
description = "Color channel values are multiplied by the alpha channel during blending."
},
{
name = "premultiplied",
description = "Color channels are not multiplied by the alpha channel. This should be used if the pixels being drawn have already been blended, or \"pre-multiplied\", by the alpha channel."
}
}
},
{
name = "BlendMode",
summary = "Different blend modes.",
description = "Blend modes control how overlapping pixels are blended together, similar to layers in Photoshop.",
key = "BlendMode",
module = "lovr.graphics",
values = {
{
name = "alpha",
description = "Normal blending where the alpha value controls how the colors are blended."
},
{
name = "add",
description = "The incoming pixel color is added to the destination pixel color."
},
{
name = "subtract",
description = "The incoming pixel color is subtracted from the destination pixel color."
},
{
name = "multiply",
description = "The color channels from the two pixel values are multiplied together to produce a result."
},
{
name = "lighten",
description = "The maximum value from each color channel is used, resulting in a lightening effect."
},
{
name = "darken",
description = "The minimum value from each color channel is used, resulting in a darkening effect."
},
{
name = "screen",
description = "The opposite of multiply: The pixel values are inverted, multiplied, and inverted again, resulting in a lightening effect."
},
{
name = "replace",
description = "The incoming pixel replaces the destination pixel."
}
},
related = {
"BlendAlphaMode",
"lovr.graphics.getBlendMode",
"lovr.graphics.setBlendMode"
}
},
{
name = "CompareMode",
summary = "Different depth test modes.",
description = "The method used to compare z values when deciding how to overlap rendered objects. This is called the \"depth test\", and it happens on a pixel-by-pixel basis every time new objects are drawn. If the depth test \"passes\" for a pixel, then the pixel color will be replaced by the new color and the depth value in the depth buffer will be updated. Otherwise, the pixel will not be changed and the depth value will not be updated.",
key = "CompareMode",
module = "lovr.graphics",
values = {
{
name = "equal",
description = "The depth test passes when the depth values are equal."
},
{
name = "notequal",
description = "The depth test passes when the depth values are not equal."
},
{
name = "less",
description = "The depth test passes when the new depth value is less than the existing one."
},
{
name = "lequal",
description = "The depth test passes when the new depth value is less than or equal to the existing one."
},
{
name = "gequal",
description = "The depth test passes when the new depth value is greater than or equal to the existing one."
},
{
name = "greater",
description = "The depth test passes when the new depth value is greater than the existing one."
}
},
related = {
"lovr.graphics.getDepthTest",
"lovr.graphics.setDepthTest",
"lovr.graphics.getStencilTest",
"lovr.graphics.setStencilTest"
}
},
{
name = "DepthFormat",
summary = "Different types of depth maps used by Canvases.",
description = "When you create a Canvas, you can give it a depth buffer, which stores the 3D positions of pixels to ensure that the depth of objects is sorted properly. This depth information can be stored in various formats that differ in size and precision. Additionally, this depth buffer can also be used for stenciling information.",
key = "DepthFormat",
module = "lovr.graphics",
values = {
{
name = "d16",
description = "A 16 bit depth buffer."
},
{
name = "d32f",
description = "A 32 bit floating point depth buffer."
},
{
name = "d24s8",
description = "A depth buffer with 24 bits for depth and 8 bits for stencil."
}
},
related = {
"lovr.graphics.newCanvas",
"Canvas:getDepthFormat",
"lovr.graphics.getDepthTest",
"lovr.graphics.setDepthTest",
"lovr.graphics.stencil",
"Canvas"
}
},
{
name = "DrawMode",
summary = "Different ways graphics primitives can be drawn.",
description = "Most graphics primitives can be drawn in one of two modes: a filled mode and a wireframe mode.",
key = "DrawMode",
module = "lovr.graphics",
values = {
{
name = "fill",
description = "The shape is drawn as a filled object."
},
{
name = "line",
description = "The shape is drawn as a wireframe object."
}
}
},
{
name = "FilterMode",
summary = "How textures are sampled.",
description = "The method used to downsample (or upsample) a texture. \"nearest\" can be used for a pixelated effect, whereas \"linear\" leads to more smooth results. Nearest is slightly faster than linear.",
key = "FilterMode",
module = "lovr.graphics",
values = {
{
name = "nearest",
description = "Fast nearest-neighbor sampling. Leads to a pixelated style."
},
{
name = "bilinear",
description = "Smooth pixel sampling."
},
{
name = "trilinear",
description = "Smooth pixel sampling, with smooth sampling across mipmap levels."
},
{
name = "anisotropic",
description = "Anisotropic texture filtering. The level of anisotropy can also be specified when setting this filter mode. Gives the best results but is also slower."
}
}
},
{
name = "HorizontalAlign",
summary = "Different ways to horizontally align text.",
description = "Different ways to horizontally align text when using `lovr.graphics.print`.",
key = "HorizontalAlign",
module = "lovr.graphics",
values = {
{
name = "left",
description = "Left aligned lines of text."
},
{
name = "center",
description = "Centered aligned lines of text."
},
{
name = "right",
description = "Right aligned lines of text."
}
},
related = {
"VerticalAlign",
"lovr.graphics.print"
}
},
{
name = "MaterialColor",
summary = "Different material color parameters.",
description = "The different types of color parameters `Material`s can hold.",
key = "MaterialColor",
module = "lovr.graphics",
values = {
{
name = "diffuse",
description = "The diffuse color."
},
{
name = "emissive",
description = "The emissive color."
}
},
related = {
"Material:getColor",
"Material:setColor",
"MaterialScalar",
"MaterialTexture",
"Material"
}
},
{
name = "MaterialScalar",
summary = "Different material parameters.",
description = "The different types of float parameters `Material`s can hold.",
key = "MaterialScalar",
module = "lovr.graphics",
values = {
{
name = "metalness",
description = "The constant metalness factor."
},
{
name = "roughness",
description = "The constant roughness factor."
}
},
related = {
"Material:getScalar",
"Material:setScalar",
"MaterialColor",
"MaterialTexture",
"Material"
}
},
{
name = "MaterialTexture",
summary = "Different material texture parameters.",
description = "The different types of texture parameters `Material`s can hold.",
key = "MaterialTexture",
module = "lovr.graphics",
values = {
{
name = "diffuse",
description = "The diffuse texture."
},
{
name = "emissive",
description = "The emissive texture."
},
{
name = "metalness",
description = "The metalness texture."
},
{
name = "roughness",
description = "The roughness texture."
},
{
name = "occlusion",
description = "The ambient occlusion texture."
},
{
name = "normal",
description = "The normal map."
},
{
name = "environment",
description = "The environment map, should be specified as a cubemap texture."
}
},
related = {
"Material:getTexture",
"Material:setTexture",
"MaterialColor",
"MaterialScalar",
"Material"
}
},
{
name = "MeshDrawMode",
summary = "Different ways Mesh objects can be drawn.",
description = "Meshes are lists of arbitrary vertices. These vertices can be drawn in a few different ways, leading to different results.",
key = "MeshDrawMode",
module = "lovr.graphics",
values = {
{
name = "points",
description = "Draw each vertex as a single point."
},
{
name = "lines",
description = "The vertices represent a list of line segments. Each pair of vertices will have a line drawn between them."
},
{
name = "linestrip",
description = "The first two vertices have a line drawn between them, and each vertex after that will be connected to the previous vertex with a line."
},
{
name = "lineloop",
description = "Similar to linestrip, except the last vertex is connected back to the first."
},
{
name = "strip",
description = "The first three vertices define a triangle. Each vertex after that creates a triangle using the new vertex and last two vertices."
},
{
name = "triangles",
description = "Each set of three vertices represents a discrete triangle."
},
{
name = "fan",
description = "Draws a set of triangles. Each one shares the first vertex as a common point, leading to a fan-like shape."
}
}
},
{
name = "MeshUsage",
summary = "How a Mesh is going to be updated.",
description = "Meshes can have a usage hint, describing how they are planning on being updated. Setting the usage hint allows the graphics driver optimize how it handles the data in the Mesh.",
key = "MeshUsage",
module = "lovr.graphics",
values = {
{
name = "static",
description = "The Mesh contents will rarely change."
},
{
name = "dynamic",
description = "The Mesh contents will change often."
},
{
name = "stream",
description = "The Mesh contents will change constantly, potentially multiple times each frame."
}
}
},
{
name = "ShaderType",
summary = "Different types of shaders.",
description = "Shaders can be used for either rendering operations or generic compute tasks. Graphics shaders are created with `lovr.graphics.newShader` and compute shaders are created with `lovr.graphics.newComputeShader`. `Shader:getType` can be used on an existing Shader to figure out what type it is.",
key = "ShaderType",
module = "lovr.graphics",
values = {
{
name = "graphics",
description = "A graphics shader."
},
{
name = "compute",
description = "A compute shader."
}
},
related = {
"Shader",
"lovr.graphics.newShader",
"lovr.graphics.newComputeShader"
}
},
{
name = "StencilAction",
summary = "Different stencil operations available.",
description = "How to modify pixels in the stencil buffer when using `lovr.graphics.stencil`.",
key = "StencilAction",
module = "lovr.graphics",
values = {
{
name = "replace",
description = "Stencil values will be replaced with a custom value."
},
{
name = "increment",
description = "Stencil values will increment every time they are rendered to."
},
{
name = "decrement",
description = "Stencil values will decrement every time they are rendered to."
},
{
name = "incrementwrap",
description = "Similar to `increment`, but the stencil value will be set to 0 if it exceeds 255."
},
{
name = "decrementwrap",
description = "Similar to `decrement`, but the stencil value will be set to 255 if it drops below 0."
},
{
name = "invert",
description = "Stencil values will be bitwise inverted every time they are rendered to."
}
}
},
{
name = "TextureFormat",
summary = "Different storage formats for pixels in Textures.",
description = "Textures can store their pixels in different formats. The set of color channels and the number of bits stored for each channel can differ, allowing Textures to optimize their storage for certain kinds of image formats or rendering techniques.",
key = "TextureFormat",
module = "lovr.graphics",
values = {
{
name = "rgb",
description = "Each pixel is 24 bits, or 8 bits for each channel."
},
{
name = "rgba",
description = "Each pixel is 32 bits, or 8 bits for each channel (including alpha)."
},
{
name = "rgba4",
description = "An rgba format where the colors occupy 4 bits instead of the usual 8."
},
{
name = "rgba16f",
description = "Each pixel is 64 bits. Each channel is a 16 bit floating point number."
},
{
name = "rgba32f",
description = "Each pixel is 128 bits. Each channel is a 32 bit floating point number."
},
{
name = "r16f",
description = "A 16-bit floating point format with a single color channel."
},
{
name = "r32f",
description = "A 32-bit floating point format with a single color channel."
},
{
name = "rg16f",
description = "A 16-bit floating point format with two color channels."
},
{
name = "rg32f",
description = "A 32-bit floating point format with two color channels."
},
{
name = "rgb5a1",
description = "A 16 bit format with 5-bit color channels and a single alpha bit."
},
{
name = "rgb10a2",
description = "A 32 bit format with 10-bit color channels and two alpha bits."
},
{
name = "rg11b10f",
description = "Each pixel is 32 bits, and packs three color channels into 10 or 11 bits each."
}
}
},
{
name = "TextureType",
summary = "Different types of Textures.",
description = "Different types of Textures.",
key = "TextureType",
module = "lovr.graphics",
values = {
{
name = "2d",
description = "A 2D texture."
},
{
name = "array",
description = "A 2D array texture with multiple independent 2D layers."
},
{
name = "cube",
description = "A cubemap texture with 6 2D faces."
},
{
name = "volume",
description = "A 3D volumetric texture consisting of multiple 2D layers."
}
}
},
{
name = "VerticalAlign",
summary = "Different ways to vertically align text.",
description = "Different ways to vertically align text when using `lovr.graphics.print`.",
key = "VerticalAlign",
module = "lovr.graphics",
values = {
{
name = "top",
description = "Align the top of the text to the origin."
},
{
name = "middle",
description = "Vertically center the text."
},
{
name = "bottom",
description = "Align the bottom of the text to the origin."
}
},
related = {
"HorizontalAlign",
"lovr.graphics.print"
}
},
{
name = "Winding",
summary = "Different winding directions.",
description = "Whether the points on triangles are specified in a clockwise or counterclockwise order.",
key = "Winding",
module = "lovr.graphics",
values = {
{
name = "clockwise",
description = "Triangle vertices are specified in a clockwise order."
},
{
name = "counterclockwise",
description = "Triangle vertices are specified in a counterclockwise order."
}
}
},
{
name = "WrapMode",
summary = "How to wrap Textures.",
description = "The method used to render textures when texture coordinates are outside of the 0-1 range.",
key = "WrapMode",
module = "lovr.graphics",
values = {
{
name = "clamp",
description = "The texture will be clamped at its edges."
},
{
name = "repeat",
description = "The texture repeats."
},
{
name = "mirroredrepeat",
description = "The texture will repeat, mirroring its appearance each time it repeats."
}
}
}
},
functions = {
{
name = "arc",
tag = "graphicsPrimitives",
summary = "Draw an arc.",
description = "Draws an arc.",
key = "lovr.graphics.arc",
module = "lovr.graphics",
notes = "The local normal vector of the circle is `(0, 0, 1)`.",
variants = {
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "Whether the arc is filled or outlined."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the arc.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the arc.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the arc.",
default = "0"
},
{
name = "radius",
type = "number",
description = "The radius of the arc, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the arc around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the arc's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the arc's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the arc's axis of rotation.",
default = "0"
},
{
name = "start",
type = "number",
description = "The starting angle of the arc, in radians.",
default = "0"
},
{
name = "end",
type = "number",
description = "The ending angle of the arc, in radians.",
default = "2 * math.pi"
},
{
name = "segments",
type = "number",
description = "The number of segments to use for the full circle. A smaller number of segments will be used, depending on how long the arc is.",
default = "32"
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the arc."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the arc.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the arc.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the arc.",
default = "0"
},
{
name = "radius",
type = "number",
description = "The radius of the arc, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the arc around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the arc's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the arc's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the arc's axis of rotation.",
default = "0"
},
{
name = "start",
type = "number",
description = "The starting angle of the arc, in radians.",
default = "0"
},
{
name = "end",
type = "number",
description = "The ending angle of the arc, in radians.",
default = "2 * math.pi"
},
{
name = "segments",
type = "number",
description = "The number of segments to use for the full circle. A smaller number of segments will be used, depending on how long the arc is.",
default = "32"
}
},
returns = {}
},
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "Whether the arc is filled or outlined."
},
{
name = "transform",
type = "Transform",
description = "The arc's transform."
},
{
name = "start",
type = "number",
description = "The starting angle of the arc, in radians.",
default = "0"
},
{
name = "end",
type = "number",
description = "The ending angle of the arc, in radians.",
default = "2 * math.pi"
},
{
name = "segments",
type = "number",
description = "The number of segments to use for the full circle. A smaller number of segments will be used, depending on how long the arc is.",
default = "32"
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the arc."
},
{
name = "transform",
type = "Transform",
description = "The arc's transform."
},
{
name = "start",
type = "number",
description = "The starting angle of the arc, in radians.",
default = "0"
},
{
name = "end",
type = "number",
description = "The ending angle of the arc, in radians.",
default = "2 * math.pi"
},
{
name = "segments",
type = "number",
description = "The number of segments to use for the full circle. A smaller number of segments will be used, depending on how long the arc is.",
default = "32"
}
},
returns = {}
},
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "Whether the arc is filled or outlined."
},
{
name = "arcmode",
type = "ArcMode",
description = "How to draw the arc.",
default = "'pie'"
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the arc.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the arc.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the arc.",
default = "0"
},
{
name = "radius",
type = "number",
description = "The radius of the arc, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the arc around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the arc's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the arc's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the arc's axis of rotation.",
default = "0"
},
{
name = "start",
type = "number",
description = "The starting angle of the arc, in radians.",
default = "0"
},
{
name = "end",
type = "number",
description = "The ending angle of the arc, in radians.",
default = "2 * math.pi"
},
{
name = "segments",
type = "number",
description = "The number of segments to use for the full circle. A smaller number of segments will be used, depending on how long the arc is.",
default = "32"
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the arc."
},
{
name = "arcmode",
type = "ArcMode",
description = "How to draw the arc.",
default = "'pie'"
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the arc.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the arc.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the arc.",
default = "0"
},
{
name = "radius",
type = "number",
description = "The radius of the arc, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the arc around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the arc's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the arc's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the arc's axis of rotation.",
default = "0"
},
{
name = "start",
type = "number",
description = "The starting angle of the arc, in radians.",
default = "0"
},
{
name = "end",
type = "number",
description = "The ending angle of the arc, in radians.",
default = "2 * math.pi"
},
{
name = "segments",
type = "number",
description = "The number of segments to use for the full circle. A smaller number of segments will be used, depending on how long the arc is.",
default = "32"
}
},
returns = {}
},
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "Whether the arc is filled or outlined."
},
{
name = "arcmode",
type = "ArcMode",
description = "How to draw the arc.",
default = "'pie'"
},
{
name = "transform",
type = "Transform",
description = "The arc's transform."
},
{
name = "start",
type = "number",
description = "The starting angle of the arc, in radians.",
default = "0"
},
{
name = "end",
type = "number",
description = "The ending angle of the arc, in radians.",
default = "2 * math.pi"
},
{
name = "segments",
type = "number",
description = "The number of segments to use for the full circle. A smaller number of segments will be used, depending on how long the arc is.",
default = "32"
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the arc."
},
{
name = "arcmode",
type = "ArcMode",
description = "How to draw the arc.",
default = "'pie'"
},
{
name = "transform",
type = "Transform",
description = "The arc's transform."
},
{
name = "start",
type = "number",
description = "The starting angle of the arc, in radians.",
default = "0"
},
{
name = "end",
type = "number",
description = "The ending angle of the arc, in radians.",
default = "2 * math.pi"
},
{
name = "segments",
type = "number",
description = "The number of segments to use for the full circle. A smaller number of segments will be used, depending on how long the arc is.",
default = "32"
}
},
returns = {}
}
},
related = {
"lovr.graphics.arc"
}
},
{
name = "box",
tag = "graphicsPrimitives",
summary = "Draw a box.",
description = "Draws a box. This is similar to `lovr.graphics.cube` except you can have different values for the width, height, and depth of the box.",
key = "lovr.graphics.box",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "How to draw the box."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the box.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the box.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the box.",
default = "0"
},
{
name = "width",
type = "number",
description = "The width of the box, in meters.",
default = "1"
},
{
name = "height",
type = "number",
description = "The height of the box, in meters.",
default = "1"
},
{
name = "depth",
type = "number",
description = "The depth of the box, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the box around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the box."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the box.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the box.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the box.",
default = "0"
},
{
name = "width",
type = "number",
description = "The width of the box, in meters.",
default = "1"
},
{
name = "height",
type = "number",
description = "The height of the box, in meters.",
default = "1"
},
{
name = "depth",
type = "number",
description = "The depth of the box, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the box around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "How to draw the box."
},
{
name = "transform",
type = "Transform",
description = "The transform of the box."
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the box."
},
{
name = "transform",
type = "Transform",
description = "The transform of the box."
}
},
returns = {}
}
}
},
{
name = "circle",
tag = "graphicsPrimitives",
summary = "Draw a 2D circle.",
description = "Draws a 2D circle.",
key = "lovr.graphics.circle",
module = "lovr.graphics",
notes = "The local normal vector of the circle is `(0, 0, 1)`.",
variants = {
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "Whether the circle is filled or outlined."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the circle.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the circle.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the circle.",
default = "0"
},
{
name = "radius",
type = "number",
description = "The radius of the circle, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the circle around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the circle's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the circle's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the circle's axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the circle."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the circle.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the circle.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the circle.",
default = "0"
},
{
name = "radius",
type = "number",
description = "The radius of the circle, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the circle around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the circle's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the circle's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the circle's axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "Whether the circle is filled or outlined."
},
{
name = "transform",
type = "Transform",
description = "The circle's transform."
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the circle."
},
{
name = "transform",
type = "Transform",
description = "The circle's transform."
}
},
returns = {}
}
},
related = {
"lovr.graphics.arc"
}
},
{
name = "clear",
tag = "window",
summary = "Clear the screen.",
description = "Clears the screen, resetting the color, depth, and stencil information to default values. This function is called automatically by `lovr.run` at the beginning of each frame to clear out the data from the previous frame.",
key = "lovr.graphics.clear",
module = "lovr.graphics",
notes = "The two variants of this function can be mixed and matched, meaning you can use booleans for some of the values and numeric values for others.",
variants = {
{
description = "Clears the color, depth, and stencil to their default values. Color will be cleared to the current background color, depth will be cleared to 1.0, and stencil will be cleared to 0.",
arguments = {
{
name = "color",
type = "boolean",
description = "Whether or not to clear color information on the screen.",
default = "true"
},
{
name = "depth",
type = "boolean",
description = "Whether or not to clear the depth information on the screen.",
default = "true"
},
{
name = "stencil",
type = "boolean",
description = "Whether or not to clear the stencil information on the screen.",
default = "true"
}
},
returns = {}
},
{
arguments = {
{
name = "r",
type = "number",
description = "The value to clear the red channel to, from 0.0 to 1.0."
},
{
name = "g",
type = "number",
description = "The value to clear the green channel to, from 0.0 to 1.0."
},
{
name = "b",
type = "number",
description = "The value to clear the blue channel to, from 0.0 to 1.0."
},
{
name = "a",
type = "number",
description = "The value to clear the alpha channel to, from 0.0 to 1.0."
},
{
name = "z",
type = "number",
description = "The value to clear the depth buffer to.",
default = "1.0"
},
{
name = "s",
type = "number",
description = "The integer value to clear the stencil buffer to.",
default = "0"
}
},
returns = {}
}
},
related = {
"lovr.graphics.setBackgroundColor"
}
},
{
name = "compute",
tag = "graphicsPrimitives",
summary = "Run a compute shader.",
description = "This function runs a compute shader on the GPU. Compute shaders must be created with `lovr.graphics.newComputeShader` and they should implement the `void compute();` GLSL function. Running a compute shader doesn't actually do anything, but the Shader can modify data stored in `Texture`s or `ShaderBlock`s to get interesting things to happen.\n\nWhen running the compute shader, you can specify the number of times to run it in 3 dimensions, which is useful to iterate over large numbers of elements like pixels or array elements.",
key = "lovr.graphics.compute",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "shader",
type = "Shader",
description = "The compute shader to run."
},
{
name = "x",
type = "number",
description = "The amount of times to run in the x direction.",
default = "1"
},
{
name = "y",
type = "number",
description = "The amount of times to run in the y direction.",
default = "1"
},
{
name = "z",
type = "number",
description = "The amount of times to run in the z direction.",
default = "1"
}
},
returns = {}
}
},
related = {
"lovr.graphics.newComputeShader",
"lovr.graphics.getShader",
"lovr.graphics.setShader",
"Shader"
},
notes = "Only compute shaders created with `lovr.graphics.newComputeShader` can be used here."
},
{
name = "createWindow",
tag = "window",
summary = "Creates the window.",
description = "Create the desktop window, usually used to mirror the headset display.",
key = "lovr.graphics.createWindow",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "width",
type = "number",
description = "The width of the window.",
default = "1080"
},
{
name = "height",
type = "number",
description = "The height of the window.",
default = "600"
},
{
name = "fullscreen",
type = "boolean",
description = "Whether the window should be fullscreen.",
default = "false"
},
{
name = "msaa",
type = "number",
description = "The number of samples to use for multisample antialiasing.",
default = "0"
},
{
name = "title",
type = "string",
description = "The window title.",
default = "nil"
},
{
name = "icon",
type = "string",
description = "A path to an image to use for the window icon.",
default = "nil"
}
},
returns = {}
}
},
notes = "This function can only be called once. It is normally called internally, but you can override this by setting window to `nil` in conf.lua. See `lovr.conf` for more information."
},
{
name = "cube",
tag = "graphicsPrimitives",
summary = "Draw a cube.",
description = "Draws a cube.",
key = "lovr.graphics.cube",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "How to draw the cube."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the cube.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the cube.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the cube.",
default = "0"
},
{
name = "size",
type = "number",
description = "The size of the cube, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the cube around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the cube's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the cube's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the cube's axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the cube faces."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the cube.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the cube.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the cube.",
default = "0"
},
{
name = "size",
type = "number",
description = "The size of the cube, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the cube around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the cube's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the cube's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the cube's axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "How to draw the cube."
},
{
name = "transform",
type = "Transform",
description = "The cube's transform."
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply to the cube faces."
},
{
name = "transform",
type = "Transform",
description = "The cube's transform."
}
},
returns = {}
}
}
},
{
name = "cylinder",
tag = "graphicsPrimitives",
summary = "Draw a cylinder.",
description = "Draws a cylinder.",
key = "lovr.graphics.cylinder",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "x1",
type = "number",
description = "The x coordinate of the top of the cylinder."
},
{
name = "y1",
type = "number",
description = "The y coordinate of the top of the cylinder."
},
{
name = "z1",
type = "number",
description = "The z coordinate of the top of the cylinder."
},
{
name = "x2",
type = "number",
description = "The x coordinate of the bottom of the cylinder."
},
{
name = "y2",
type = "number",
description = "The y coordinate of the bottom of the cylinder."
},
{
name = "z2",
type = "number",
description = "The z coordinate of the bottom of the cylinder."
},
{
name = "r1",
type = "number",
description = "The radius of the top of the cylinder.",
default = "1"
},
{
name = "r2",
type = "number",
description = "The radius of the bottom of the cylinder.",
default = "1"
},
{
name = "capped",
type = "boolean",
description = "Whether the top and bottom should be rendered.",
default = "true"
},
{
name = "segments",
type = "number",
description = "The number of radial segments to use for the cylinder. If nil, the segment count is automatically determined from the radii.",
default = "nil"
}
},
returns = {}
}
}
},
{
name = "fill",
tag = "graphicsPrimitives",
summary = "Fill the screen with a texture.",
description = "Draws a fullscreen textured quad.",
key = "lovr.graphics.fill",
module = "lovr.graphics",
notes = "This function ignores stereo rendering, so it will stretch the input across the entire Canvas if it's stereo.",
variants = {
{
description = "Fills the screen with a Texture.",
arguments = {
{
name = "texture",
type = "Texture",
description = "The texture to use."
}
},
returns = {}
},
{
description = "Fills the screen with the first Texture attached to a Canvas.",
arguments = {
{
name = "canvas",
type = "Canvas",
description = "The first Texture attached to this Canvas will be used."
}
},
returns = {}
},
{
description = "Fills the screen with the active color.",
arguments = {},
returns = {}
}
}
},
{
name = "getBackgroundColor",
tag = "graphicsState",
summary = "Get the background color.",
description = "Returns the current background color. Color components are from 0.0 to 1.0.",
key = "lovr.graphics.getBackgroundColor",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "r",
type = "number",
description = "The red component of the background color."
},
{
name = "g",
type = "number",
description = "The green component of the background color."
},
{
name = "b",
type = "number",
description = "The blue component of the background color."
},
{
name = "a",
type = "number",
description = "The alpha component of the background color."
}
}
}
},
notes = "The default background color is black."
},
{
name = "getBlendMode",
tag = "graphicsState",
summary = "Get the blend mode.",
description = "Returns the current blend mode. The blend mode controls how each pixel's color is blended with the previous pixel's color when drawn.",
key = "lovr.graphics.getBlendMode",
module = "lovr.graphics",
related = {
"BlendMode",
"BlendAlphaMode"
},
variants = {
{
arguments = {},
returns = {
{
name = "blend",
type = "BlendMode",
description = "The current blend mode."
},
{
name = "alphaBlend",
type = "BlendAlphaMode",
description = "The current alpha blend mode."
}
}
}
}
},
{
name = "getCanvas",
tag = "graphicsState",
summary = "Get the active Canvas.",
description = "Returns the active Canvas. Usually when you render something it will render directly to the headset. If a Canvas object is active, things will be rendered to the textures attached to the Canvas instead.",
key = "lovr.graphics.getCanvas",
module = "lovr.graphics",
related = {
"Canvas:renderTo",
"Canvas"
},
variants = {
{
arguments = {},
returns = {
{
name = "canvas",
type = "Canvas",
description = "The active Canvas, or `nil` if no canvas is set."
}
}
}
}
},
{
name = "getColor",
tag = "graphicsState",
summary = "Get the global color factor.",
description = "Returns the current global color factor. Color components are from 0.0 to 1.0. Every pixel drawn will be multiplied (i.e. tinted) by this color.",
key = "lovr.graphics.getColor",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "r",
type = "number",
description = "The red component of the color."
},
{
name = "g",
type = "number",
description = "The green component of the color."
},
{
name = "b",
type = "number",
description = "The blue component of the color."
},
{
name = "a",
type = "number",
description = "The alpha component of the color."
}
}
}
},
notes = "The default color is white."
},
{
name = "getDefaultFilter",
tag = "graphicsState",
summary = "Get the default filter mode for Textures.",
description = "Returns the default filter mode for new Textures. This controls how textures are sampled when they are minified, magnified, or stretched.",
key = "lovr.graphics.getDefaultFilter",
module = "lovr.graphics",
related = {
"Texture:getFilter",
"Texture:setFilter"
},
variants = {
{
arguments = {},
returns = {
{
name = "mode",
type = "FilterMode",
description = "The filter mode."
},
{
name = "anisotropy",
type = "number",
description = "If the filtering mode is \"anisotropic\", returns the level of anisotropy. Otherwise, this will be nil."
}
}
}
}
},
{
name = "getDepthTest",
tag = "graphicsState",
summary = "Get the depth test mode.",
description = "Returns the current depth test settings.",
key = "lovr.graphics.getDepthTest",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "compareMode",
type = "CompareMode",
description = "The current comparison method for depth testing."
},
{
name = "write",
type = "boolean",
description = "Whether pixels will have their z value updated when rendered to."
}
}
}
},
notes = "The depth test is an advanced technique to control how 3D objects overlap each other when they are rendered. It works as follows:\n\n- Each pixel keeps track of its z value as well as its color.\n- If `write` is enabled when something is drawn, then any pixels that are drawn will have their\n z values updated.\n- Additionally, anything drawn will first compare the existing z value of a pixel with the new z\n value. The `compareMode` setting determines how this comparison is performed. If the\n comparison succeeds, the new pixel will overwrite the previous one, otherwise that pixel won't\n be rendered to.\n\nSmaller z values are closer to the camera.\n\nThe default compare mode is `lequal`, which usually gives good results for normal 3D rendering."
},
{
name = "getDimensions",
tag = "window",
summary = "Get the dimensions of the window.",
description = "Returns the dimensions of the desktop window.",
key = "lovr.graphics.getDimensions",
module = "lovr.graphics",
related = {
"lovr.graphics.getWidth",
"lovr.graphics.getHeight"
},
variants = {
{
arguments = {},
returns = {
{
name = "width",
type = "number",
description = "The width of the window, in pixels."
},
{
name = "height",
type = "number",
description = "The height of the window, in pixels."
}
}
}
}
},
{
name = "getFont",
tag = "graphicsState",
summary = "Get the active font.",
description = "Returns the active font.",
key = "lovr.graphics.getFont",
module = "lovr.graphics",
related = {
"lovr.graphics.print"
},
variants = {
{
arguments = {},
returns = {
{
name = "font",
type = "Font",
description = "The active font object."
}
}
}
}
},
{
name = "getHeight",
tag = "window",
summary = "Get the height of the window.",
description = "Returns the height of the desktop window.",
key = "lovr.graphics.getHeight",
module = "lovr.graphics",
related = {
"lovr.graphics.getWidth",
"lovr.graphics.getDimensions"
},
variants = {
{
arguments = {},
returns = {
{
name = "height",
type = "number",
description = "The height of the window, in pixels."
}
}
}
}
},
{
name = "getLineWidth",
tag = "graphicsState",
summary = "Get the line width.",
description = "Returns the current line width.",
key = "lovr.graphics.getLineWidth",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "width",
type = "number",
description = "The current line width, in pixels."
}
}
}
},
related = {
"lovr.graphics.line"
},
notes = "The default line width is `1.0`."
},
{
name = "getPointSize",
tag = "graphicsState",
summary = "Get the point size.",
description = "Returns the current point size.",
key = "lovr.graphics.getPointSize",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "size",
type = "number",
description = "The current point size, in pixels."
}
}
}
},
related = {
"lovr.graphics.points"
},
notes = "The default point size is `1.0`."
},
{
name = "getShader",
tag = "graphicsState",
summary = "Get the active shader.",
description = "Returns the active shader.",
key = "lovr.graphics.getShader",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "shader",
type = "Shader",
description = "The active shader object, or `nil` if none is active."
}
}
}
}
},
{
name = "getStats",
tag = "graphicsState",
summary = "Get renderer stats for the current frame.",
description = "Returns graphics-related performance statistics for the current frame.",
key = "lovr.graphics.getStats",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "stats",
type = "table",
description = "The table of stats.",
table = {
{
name = "drawcalls",
type = "number",
description = "The number of draw calls."
},
{
name = "shaderswitches",
type = "number",
description = "The number of times the shader has been switched."
}
}
}
}
}
}
},
{
name = "getStencilTest",
tag = "graphicsState",
summary = "Get the current stencil test.",
description = "Returns the current stencil test. The stencil test lets you mask out pixels that meet certain criteria, based on the contents of the stencil buffer. The stencil buffer can be modified using `lovr.graphics.stencil`. After rendering to the stencil buffer, the stencil test can be set to control how subsequent drawing functions are masked by the stencil buffer.",
key = "lovr.graphics.getStencilTest",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "compareMode",
type = "CompareMode",
description = "The comparison method used to decide if a pixel should be visible, or nil if the stencil test is disabled."
},
{
name = "compareValue",
type = "number",
description = "The value stencil values are compared against, or nil if the stencil test is disabled."
}
}
}
},
related = {
"lovr.graphics.stencil"
},
notes = "Stencil values are between 0 and 255."
},
{
name = "getSupported",
tag = "window",
summary = "Check if certain features are supported.",
description = "Returns whether certain features are supported by the system\\'s graphics card.",
key = "lovr.graphics.getSupported",
module = "lovr.graphics",
related = {
"lovr.graphics.getSystemLimits"
},
variants = {
{
arguments = {},
returns = {
{
name = "features",
type = "table",
description = "A table of features and whether or not they are supported.",
table = {
{
name = "computeshaders",
type = "boolean",
description = "Whether compute shaders are available."
},
{
name = "singlepass",
type = "boolean",
description = "Whether single pass stereo rendering is supported."
}
}
}
}
}
}
},
{
name = "getSystemLimits",
tag = "window",
summary = "Get capabilities of the graphics card.",
description = "Returns information about the capabilities of the graphics card, such as the maximum texture size or the amount of supported antialiasing.",
key = "lovr.graphics.getSystemLimits",
module = "lovr.graphics",
related = {
"lovr.graphics.getSupported"
},
variants = {
{
arguments = {},
returns = {
{
name = "limits",
type = "table",
description = "The table of limits.",
table = {
{
name = "pointsize",
type = "number",
description = "The maximum size of points, in pixels."
},
{
name = "texturesize",
type = "number",
description = "The maximum width or height of textures, in pixels."
},
{
name = "texturemsaa",
type = "number",
description = "The maximum MSAA value supported by `lovr.graphics.newTexture`."
},
{
name = "anisotropy",
type = "number",
description = "The maximum anisotropy value supported by `Texture:setFilter`."
}
}
}
}
}
}
},
{
name = "getWidth",
tag = "window",
summary = "Get the width of the window.",
description = "Returns the width of the desktop window.",
key = "lovr.graphics.getWidth",
module = "lovr.graphics",
related = {
"lovr.graphics.getHeight",
"lovr.graphics.getDimensions"
},
variants = {
{
arguments = {},
returns = {
{
name = "width",
type = "number",
description = "The width of the window, in pixels."
}
}
}
}
},
{
name = "getWinding",
tag = "graphicsState",
summary = "Get the winding direction.",
description = "Returns the current polygon winding. The winding direction determines which face of a triangle is the front face and which is the back face. This lets the graphics engine cull the back faces of polygons, improving performance.",
key = "lovr.graphics.getWinding",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "winding",
type = "Winding",
description = "The current winding direction."
}
}
}
},
related = {
"lovr.graphics.setCullingEnabled",
"lovr.graphics.isCullingEnabled"
},
notes = "Culling is initially disabled and must be enabled using `lovr.graphics.setCullingEnabled`.\n\nThe default winding direction is counterclockwise."
},
{
name = "isCullingEnabled",
tag = "graphicsState",
summary = "Get whether backface culling is enabled.",
description = "Returns whether or not culling is active. Culling is an optimization that avoids rendering the back face of polygons. This improves performance by reducing the number of polygons drawn, but requires that the vertices in triangles are specified in a consistent clockwise or counter clockwise order.",
key = "lovr.graphics.isCullingEnabled",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "isEnabled",
type = "boolean",
description = "Whether or not culling is enabled."
}
}
}
},
notes = "Culling is disabled by default."
},
{
name = "isGammaCorrect",
tag = "graphicsState",
summary = "Get whether wireframe mode is enabled.",
description = "Get whether or not gamma correct rendering is supported and enabled. When enabled, lovr will automatically perform gamma correction on colors set via `lovr.graphics.setColor`, `lovr.graphics.setBackgroundColor`, `Material:setColor`, and textures created without the linear flag set. Gamma correction will subtly improve lighting quality, especially in darker regions.",
key = "lovr.graphics.isGammaCorrect",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "isGammaCorrect",
type = "boolean",
description = "Whether or not gamma correction is applied to colors."
}
}
}
},
related = {
"lovr.conf",
"lovr.math.gammaToLinear",
"lovr.math.linearToGamma"
},
notes = "Gamma correction must first be enabled in `lovr.conf`."
},
{
name = "isWireframe",
tag = "graphicsState",
summary = "Get whether wireframe mode is enabled.",
description = "Returns a boolean indicating whether or not wireframe rendering is enabled.",
key = "lovr.graphics.isWireframe",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "isWireframe",
type = "boolean",
description = "Whether or not wireframe rendering is enabled."
}
}
}
},
notes = "Wireframe rendering is initially disabled."
},
{
name = "line",
tag = "graphicsPrimitives",
summary = "Draw lines.",
description = "Draws lines between points. Each point will be connected to the previous point in the list.",
key = "lovr.graphics.line",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "x1",
type = "number",
description = "The x coordinate of the first point."
},
{
name = "y1",
type = "number",
description = "The y coordinate of the first point."
},
{
name = "z1",
type = "number",
description = "The z coordinate of the first point."
},
{
name = "x2",
type = "number",
description = "The x coordinate of the second point."
},
{
name = "y2",
type = "number",
description = "The y coordinate of the second point."
},
{
name = "z2",
type = "number",
description = "The z coordinate of the second point."
},
{
name = "...",
type = "number",
description = "More points."
}
},
returns = {}
},
{
arguments = {
{
name = "points",
type = "table",
description = "A table of point positions, as described above."
}
},
returns = {}
}
}
},
{
name = "newAnimator",
tag = "graphicsObjects",
summary = "Create a new Animator.",
description = "Creates a new `Animator` by reading animations from a `Model`.",
key = "lovr.graphics.newAnimator",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "model",
type = "Model",
description = "The model to read animations from."
}
},
returns = {
{
name = "animator",
type = "Animator",
description = "The new Animator."
}
}
}
},
related = {
"Model:setAnimator"
},
notes = "You can attach an animator to a Model with `Model:setAnimator`."
},
{
name = "newCanvas",
tag = "graphicsObjects",
summary = "Create a new Canvas.",
description = "Creates a new Canvas. You can specify Textures to attach to it, or just specify a width and height and attach textures later using `Canvas:setTexture`.\n\nOnce created, you can render to the Canvas using `Canvas:renderTo`, or `lovr.graphics.setCanvas`.",
key = "lovr.graphics.newCanvas",
module = "lovr.graphics",
related = {
"lovr.graphics.setCanvas",
"lovr.graphics.getCanvas",
"Canvas:renderTo"
},
variants = {
{
description = "Create an empty Canvas with no Textures attached.",
arguments = {
{
name = "width",
type = "number",
description = "The width of the canvas, in pixels."
},
{
name = "height",
type = "number",
description = "The height of the canvas, in pixels."
},
{
name = "flags",
type = "table",
description = "Optional settings for the Canvas.",
table = {
{
name = "format",
type = "TextureFormat",
description = "The format of a Texture to create and attach to this Canvas, or false if no Texture should be created. This is ignored if Textures are already passed in.",
default = "'rgba'"
},
{
name = "depth",
type = "DepthFormat",
description = "A DepthFormat to use for the Canvas depth buffer, or false for no depth buffer.",
default = "d16"
},
{
name = "stereo",
type = "boolean",
description = "Whether the Canvas is stereo.",
default = "true"
},
{
name = "msaa",
type = "number",
description = "The number of MSAA samples to use for antialiasing.",
default = "0"
},
{
name = "mipmaps",
type = "boolean",
description = "Whether the Canvas will automatically generate mipmaps for its attached textures.",
default = "true"
}
},
default = "{}"
}
},
returns = {
{
name = "canvas",
type = "Canvas",
description = "The new Canvas."
}
}
},
{
description = "Create a Canvas with attached Textures.",
arguments = {
{
name = "...",
type = "Texture",
description = "One or more Textures to attach to the Canvas."
},
{
name = "flags",
type = "table",
description = "Optional settings for the Canvas.",
table = {
{
name = "format",
type = "TextureFormat",
description = "The format of a Texture to create and attach to this Canvas, or false if no Texture should be created. This is ignored if Textures are already passed in.",
default = "'rgba'"
},
{
name = "depth",
type = "DepthFormat",
description = "A DepthFormat to use for the Canvas depth buffer, or false for no depth buffer.",
default = "d16"
},
{
name = "stereo",
type = "boolean",
description = "Whether the Canvas is stereo.",
default = "true"
},
{
name = "msaa",
type = "number",
description = "The number of MSAA samples to use for antialiasing.",
default = "0"
},
{
name = "mipmaps",
type = "boolean",
description = "Whether the Canvas will automatically generate mipmaps for its attached textures.",
default = "true"
}
},
default = "{}"
}
},
returns = {
{
name = "canvas",
type = "Canvas",
description = "The new Canvas."
}
}
},
{
description = "Create a Canvas with attached Textures, using specific layers and mipmap levels from each one. Layers and mipmaps can be specified after each Texture as numbers, or a table of a Texture, layer, and mipmap can be used for each attachment.",
arguments = {
{
name = "attachments",
type = "table",
description = "A table of textures, layers, and mipmaps (in any combination) to attach."
},
{
name = "flags",
type = "table",
description = "Optional settings for the Canvas.",
table = {
{
name = "format",
type = "TextureFormat",
description = "The format of a Texture to create and attach to this Canvas, or false if no Texture should be created. This is ignored if Textures are already passed in.",
default = "'rgba'"
},
{
name = "depth",
type = "DepthFormat",
description = "A DepthFormat to use for the Canvas depth buffer, or false for no depth buffer.",
default = "d16"
},
{
name = "stereo",
type = "boolean",
description = "Whether the Canvas is stereo.",
default = "true"
},
{
name = "msaa",
type = "number",
description = "The number of MSAA samples to use for antialiasing.",
default = "0"
},
{
name = "mipmaps",
type = "boolean",
description = "Whether the Canvas will automatically generate mipmaps for its attached textures.",
default = "true"
}
},
default = "{}"
}
},
returns = {
{
name = "canvas",
type = "Canvas",
description = "The new Canvas."
}
}
}
}
},
{
name = "newComputeShader",
tag = "graphicsObjects",
summary = "Create a new compute Shader.",
description = "Creates a new compute Shader, used for running generic compute operations on the GPU.",
key = "lovr.graphics.newComputeShader",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "source",
type = "string",
description = "The code or filename of the compute shader."
}
},
returns = {
{
name = "shader",
type = "Shader",
description = "The new compute Shader."
}
}
}
},
related = {
"lovr.graphics.compute",
"lovr.graphics.newShader",
"lovr.graphics.setShader",
"lovr.graphics.getShader"
},
examples = {
{
code = "function lovr.load()\n computer = lovr.graphics.newComputeShader([[\n layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;\n\n void compute() {\n // compute things!\n }\n ]])\n\n -- Run the shader 4 times\n local width, height, depth = 4, 1, 1\n\n -- Dispatch the compute operation\n lovr.graphics.compute(computer, width, height, depth)\nend"
}
},
notes = "Compute shaders are not supported on all hardware, use `lovr.graphics.getSupported` to check if they're available on the current system.\n\nThe source code for a compute shader needs to implement the `void compute();` GLSL function. This function doesn't return anything, but the compute shader is able to write data out to `Texture`s or `ShaderBlock`s.\n\nThe GLSL version used for compute shaders is GLSL 430."
},
{
name = "newFont",
tag = "graphicsObjects",
summary = "Create a new Font.",
description = "Creates a new Font. It can be used to render text with `lovr.graphics.print`.\n\nCurrently, the only supported font format is TTF.",
key = "lovr.graphics.newFont",
module = "lovr.graphics",
notes = "Larger font sizes will lead to more detailed curves at the cost of performance.",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the font file."
},
{
name = "size",
type = "number",
description = "The size of the font, in pixels.",
default = "32"
}
},
returns = {
{
name = "font",
type = "Font",
description = "The new Font."
}
}
},
{
description = "Creates a new Font from the default font included with LÖVR (Cabin).",
arguments = {
{
name = "size",
type = "number",
description = "The size of the font, in pixels.",
default = "32"
}
},
returns = {
{
name = "font",
type = "Font",
description = "The new Font."
}
}
},
{
arguments = {
{
name = "rasterizer",
type = "Rasterizer",
description = "The existing Rasterizer object used to render the glyphs."
}
},
returns = {
{
name = "font",
type = "Font",
description = "The new Font."
}
}
}
}
},
{
name = "newMaterial",
tag = "graphicsObjects",
summary = "Create a new Material.",
description = "Creates a new Material. Materials are sets of colors, textures, and other parameters that affect the appearance of objects. They can be applied to `Model`s, `Mesh`es, and most graphics primitives accept a Material as an optional first argument.",
key = "lovr.graphics.newMaterial",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "material",
type = "Material",
description = "The new Material."
}
}
},
{
arguments = {
{
name = "texture",
type = "Texture",
description = "The diffuse texture."
},
{
name = "r",
type = "number",
description = "The red component of the diffuse color.",
default = "1"
},
{
name = "g",
type = "number",
description = "The green component of the diffuse color.",
default = "1"
},
{
name = "b",
type = "number",
description = "The blue component of the diffuse color.",
default = "1"
},
{
name = "a",
type = "number",
description = "The alpha component of the diffuse color.",
default = "1"
}
},
returns = {
{
name = "material",
type = "Material",
description = "The new Material."
}
}
},
{
arguments = {
{
name = "canvas",
type = "Canvas",
description = "A Canvas to use as the diffuse texture."
},
{
name = "r",
type = "number",
description = "The red component of the diffuse color.",
default = "1"
},
{
name = "g",
type = "number",
description = "The green component of the diffuse color.",
default = "1"
},
{
name = "b",
type = "number",
description = "The blue component of the diffuse color.",
default = "1"
},
{
name = "a",
type = "number",
description = "The alpha component of the diffuse color.",
default = "1"
}
},
returns = {
{
name = "material",
type = "Material",
description = "The new Material."
}
}
},
{
arguments = {
{
name = "r",
type = "number",
description = "The red component of the diffuse color.",
default = "1"
},
{
name = "g",
type = "number",
description = "The green component of the diffuse color.",
default = "1"
},
{
name = "b",
type = "number",
description = "The blue component of the diffuse color.",
default = "1"
},
{
name = "a",
type = "number",
description = "The alpha component of the diffuse color.",
default = "1"
}
},
returns = {
{
name = "material",
type = "Material",
description = "The new Material."
}
}
}
}
},
{
name = "newMesh",
tag = "graphicsObjects",
summary = "Create a new Mesh.",
description = "Creates a new Mesh. Meshes contain the data for an arbitrary set of vertices, and can be drawn. You must specify either the capacity for the Mesh or an initial set of vertex data. Optionally, a custom format table can be used to specify the set of vertex attributes the mesh will provide to the active shader. The draw mode and usage hint can also optionally be specified.",
key = "lovr.graphics.newMesh",
module = "lovr.graphics",
notes = "Once created, the size of the Mesh can't be changed.",
variants = {
{
arguments = {
{
name = "size",
type = "number",
description = "The maximum number of vertices the Mesh can store."
},
{
name = "mode",
type = "MeshDrawMode",
description = "How the Mesh will connect its vertices into triangles.",
default = "'fan'"
},
{
name = "usage",
type = "MeshUsage",
description = "An optimization hint indicating how often the data in the Mesh will be updated.",
default = "'dynamic'"
}
},
returns = {
{
name = "mesh",
type = "Mesh",
description = "The new Mesh."
}
}
},
{
arguments = {
{
name = "vertices",
type = "table",
description = "A table of vertices. Each vertex is a table containing the vertex data."
},
{
name = "mode",
type = "MeshDrawMode",
description = "How the Mesh will connect its vertices into triangles.",
default = "'fan'"
},
{
name = "usage",
type = "MeshUsage",
description = "An optimization hint indicating how often the data in the Mesh will be updated.",
default = "'dynamic'"
}
},
returns = {
{
name = "mesh",
type = "Mesh",
description = "The new Mesh."
}
}
},
{
description = "These variants accept a custom vertex format. For more info, see the `Mesh` page.",
arguments = {
{
name = "format",
type = "table",
description = "A table describing the attribute format for the vertices."
},
{
name = "size",
type = "number",
description = "The maximum number of vertices the Mesh can store."
},
{
name = "mode",
type = "MeshDrawMode",
description = "How the Mesh will connect its vertices into triangles.",
default = "'fan'"
},
{
name = "usage",
type = "MeshUsage",
description = "An optimization hint indicating how often the data in the Mesh will be updated.",
default = "'dynamic'"
}
},
returns = {
{
name = "mesh",
type = "Mesh",
description = "The new Mesh."
}
}
},
{
arguments = {
{
name = "format",
type = "table",
description = "A table describing the attribute format for the vertices."
},
{
name = "vertices",
type = "table",
description = "A table of vertices. Each vertex is a table containing the vertex data."
},
{
name = "mode",
type = "MeshDrawMode",
description = "How the Mesh will connect its vertices into triangles.",
default = "'fan'"
},
{
name = "usage",
type = "MeshUsage",
description = "An optimization hint indicating how often the data in the Mesh will be updated.",
default = "'dynamic'"
}
},
returns = {
{
name = "mesh",
type = "Mesh",
description = "The new Mesh."
}
}
}
}
},
{
name = "newModel",
tag = "graphicsObjects",
summary = "Create a new Model.",
description = "Creates a new Model from a file. The supported 3D file formats are `obj`, `fbx`, and `gltf`.\n\nThe following features are not supported yet: animations, materials, vertex colors.",
key = "lovr.graphics.newModel",
module = "lovr.graphics",
notes = "- Models loaded from glTF files do not currently import animations properly.\n- Diffuse and emissive textures will be loaded in the sRGB encoding, all other textures will be\n loaded as linear.",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the model to load."
},
{
name = "texture",
type = "string",
description = "The filename of the texture to apply to the model.",
default = "nil"
}
},
returns = {
{
name = "model",
type = "Model",
description = "The new Model."
}
}
},
{
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the model to load."
},
{
name = "material",
type = "Material",
description = "The material to apply to the model. If nil, the materials will be loaded from the model file.",
default = "nil"
}
},
returns = {
{
name = "model",
type = "Model",
description = "The new Model."
}
}
},
{
arguments = {
{
name = "modelData",
type = "ModelData",
description = "The ModelData holding the data for the Model."
},
{
name = "texture",
type = "string",
description = "The filename of the texture to apply to the model.",
default = "nil"
}
},
returns = {
{
name = "model",
type = "Model",
description = "The new Model."
}
}
},
{
arguments = {
{
name = "modelData",
type = "ModelData",
description = "The ModelData holding the data for the Model."
},
{
name = "material",
type = "Material",
description = "The material to apply to the model. If nil, the materials will be loaded from the model file.",
default = "nil"
}
},
returns = {
{
name = "model",
type = "Model",
description = "The new Model."
}
}
}
}
},
{
name = "newShader",
tag = "graphicsObjects",
summary = "Create a new Shader.",
description = "Creates a new Shader.",
key = "lovr.graphics.newShader",
module = "lovr.graphics",
related = {
"lovr.graphics.setShader",
"lovr.graphics.getShader"
},
variants = {
{
arguments = {
{
name = "vertex",
type = "string",
description = "The code or filename of the vertex shader. If nil, the default vertex shader is used."
},
{
name = "fragment",
type = "string",
description = "The code or filename of the fragment shader. If nil, the default fragment shader is used."
}
},
returns = {
{
name = "shader",
type = "Shader",
description = "The new Shader."
}
}
}
}
},
{
name = "newShaderBlock",
tag = "graphicsObjects",
summary = "Create a new ShaderBlock.",
description = "Creates a new ShaderBlock from a table of variable definitions with their names and types.",
key = "lovr.graphics.newShaderBlock",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "uniforms",
type = "table",
description = "A table where the keys are uniform names and the values are uniform types. Uniform arrays can be specified by supplying a table as the uniform's value containing the type and the array size."
},
{
name = "flags",
type = "table",
description = "Optional settings.",
default = "{}",
table = {
{
name = "usage",
type = "BufferUsage",
description = "How the data in the block will be updated.",
default = "dynamic"
},
{
name = "writable",
type = "boolean",
description = "Whether Shaders can write to the data in the block.",
default = "false"
}
}
}
},
returns = {
{
name = "shaderBlock",
type = "ShaderBlock",
description = "The new ShaderBlock."
}
}
}
},
related = {
"lovr.graphics.newShader",
"lovr.graphics.newComputeShader"
},
examples = {
{
description = "Create a ShaderBlock to hold a block of useful shader data.",
code = "function lovr.load()\n block = lovr.graphics.newShaderBlock({\n time = 'float',\n lightCount = 'int',\n lightPositions = { 'vec3', 16 },\n lightColors = { 'vec3', 16 },\n objectCount = 'int',\n objectTransforms = { 'mat4', 256 }\n })\n\n shader = lovr.graphics.newShader(\n block:getShaderCode('Block') .. -- Define the block in the shader\n [[\n vec4 position(mat4 projection, mat4 transform, vec4 vertex) {\n // ...use the object transforms from the block\n return projection * transform * vertex;\n }\n ]],\n\n block:getShaderCode('Block') ..\n [[\n vec4 color(vec4 gColor, sampler2D image, vec2 uv) {\n // ...use the lights from the block\n return gColor * texture(image, uv);\n }\n ]]\n )\n\n -- Bind the block to the shader\n shader:sendBlock('Block', block)\nend\n\n-- Update the data in the block every frame\nfunction lovr.update(dt)\n block:send('time', lovr.timer.getTime())\n block:send('lightCount', lightCount)\n block:send('lightPositions', { { x, y, z}, { x, y, z } })\n -- etc.\nend"
}
},
notes = "The writable flag can only be true if compute shaders are supported, see `lovr.graphics.getSupported`. Writable blocks may be slightly slower than non-writable blocks, but they can also be much, much larger. Non-writable blocks are usually limited to around 16 kilobytes in size, depending on hardware."
},
{
name = "newTexture",
tag = "graphicsObjects",
summary = "Create a new Texture.",
description = "Creates a new Texture from an image file.",
key = "lovr.graphics.newTexture",
module = "lovr.graphics",
notes = "The \"linear\" flag should be set to true for textures that don't contain color information, such as normal maps. It is ignored if gamma correct rendering is disabled. See `lovr.graphics.isGammaCorrect` for more info.",
variants = {
{
arguments = {
{
name = "filename",
type = "string",
description = "The filename of the image to load."
},
{
name = "flags",
type = "table",
description = "Optional settings for the texture.",
table = {
{
name = "linear",
type = "boolean",
description = "Whether the texture is in linear color space instead of sRGB.",
default = "false"
},
{
name = "mipmaps",
type = "boolean",
description = "Whether mipmaps will be generated for the texture.",
default = "true"
},
{
name = "type",
type = "TextureType",
description = "The type of Texture to load the images into. If nil, the type will be `2d` for a single image, `array` for a table of images with numeric keys, or `cube` for a table of images with string keys.",
default = "nil"
}
},
default = "{}"
}
},
returns = {
{
name = "texture",
type = "Texture",
description = "The new Texture."
}
}
},
{
description = "Create a Texture from a table of filenames, Blobs, or TextureData. For cube textures, the individual faces can be specified using the string keys \"right\", \"left\", \"top\", \"bottom\", \"back\", \"front\".",
arguments = {
{
name = "images",
type = "table",
description = ""
},
{
name = "flags",
type = "table",
description = "Optional settings for the texture.",
table = {
{
name = "linear",
type = "boolean",
description = "Whether the texture is in linear color space instead of sRGB.",
default = "false"
},
{
name = "mipmaps",
type = "boolean",
description = "Whether mipmaps will be generated for the texture.",
default = "true"
},
{
name = "type",
type = "TextureType",
description = "The type of Texture to load the images into. If nil, the type will be `2d` for a single image, `array` for a table of images with numeric keys, or `cube` for a table of images with string keys.",
default = "nil"
}
},
default = "{}"
}
},
returns = {
{
name = "texture",
type = "Texture",
description = "The new Texture."
}
}
},
{
description = "Creates a blank Texture with specified dimensions. This saves memory if you're planning on rendering to the Texture using a Canvas or a compute shader, but the contents of the Texture will be initialized to random data.",
arguments = {
{
name = "width",
type = "number",
description = "The width of the Texture."
},
{
name = "height",
type = "number",
description = "The height of the Texture."
},
{
name = "depth",
type = "number",
description = "The depth of the Texture."
},
{
name = "flags",
type = "table",
description = "Optional settings for the texture.",
table = {
{
name = "linear",
type = "boolean",
description = "Whether the texture is in linear color space instead of sRGB.",
default = "false"
},
{
name = "mipmaps",
type = "boolean",
description = "Whether mipmaps will be generated for the texture.",
default = "true"
},
{
name = "type",
type = "TextureType",
description = "The type of Texture to load the images into. If nil, the type will be `2d` for a single image, `array` for a table of images with numeric keys, or `cube` for a table of images with string keys.",
default = "nil"
}
},
default = "{}"
}
},
returns = {
{
name = "texture",
type = "Texture",
description = "The new Texture."
}
}
},
{
description = "Create a texture from a single Blob.",
arguments = {
{
name = "blob",
type = "Blob",
description = "The Blob containing encoded image data used to create the Texture."
},
{
name = "flags",
type = "table",
description = "Optional settings for the texture.",
table = {
{
name = "linear",
type = "boolean",
description = "Whether the texture is in linear color space instead of sRGB.",
default = "false"
},
{
name = "mipmaps",
type = "boolean",
description = "Whether mipmaps will be generated for the texture.",
default = "true"
},
{
name = "type",
type = "TextureType",
description = "The type of Texture to load the images into. If nil, the type will be `2d` for a single image, `array` for a table of images with numeric keys, or `cube` for a table of images with string keys.",
default = "nil"
}
},
default = "{}"
}
},
returns = {
{
name = "texture",
type = "Texture",
description = "The new Texture."
}
}
},
{
description = "Create a texture from a single TextureData.",
arguments = {
{
name = "textureData",
type = "TextureData",
description = "The TextureData to create the Texture from."
},
{
name = "flags",
type = "table",
description = "Optional settings for the texture.",
table = {
{
name = "linear",
type = "boolean",
description = "Whether the texture is in linear color space instead of sRGB.",
default = "false"
},
{
name = "mipmaps",
type = "boolean",
description = "Whether mipmaps will be generated for the texture.",
default = "true"
},
{
name = "type",
type = "TextureType",
description = "The type of Texture to load the images into. If nil, the type will be `2d` for a single image, `array` for a table of images with numeric keys, or `cube` for a table of images with string keys.",
default = "nil"
}
},
default = "{}"
}
},
returns = {
{
name = "texture",
type = "Texture",
description = "The new Texture."
}
}
}
}
},
{
name = "origin",
tag = "graphicsTransforms",
summary = "Reset the coordinate system.",
description = "Resets the transformation to the origin.",
key = "lovr.graphics.origin",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {}
}
},
notes = "This is called at the beginning of every frame to reset the coordinate space."
},
{
name = "plane",
tag = "graphicsPrimitives",
summary = "Draw a plane.",
description = "Draws a plane with a given position, size, and orientation.",
key = "lovr.graphics.plane",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "How to draw the plane."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the plane.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the plane.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the plane.",
default = "0"
},
{
name = "width",
type = "number",
description = "The width of the plane, in meters.",
default = "1"
},
{
name = "height",
type = "number",
description = "The height of the plane, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The number of radians to rotate around the rotation axis.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x component of the rotation axis.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y component of the rotation axis.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z component of the rotation axis.",
default = "0"
}
},
returns = {}
},
{
description = "Draw a plane with a custom material.",
arguments = {
{
name = "material",
type = "Material",
description = "The material to apply to the plane."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the plane.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the plane.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the plane.",
default = "0"
},
{
name = "width",
type = "number",
description = "The width of the plane, in meters.",
default = "1"
},
{
name = "height",
type = "number",
description = "The height of the plane, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The number of radians to rotate around the rotation axis.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x component of the rotation axis.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y component of the rotation axis.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z component of the rotation axis.",
default = "0"
}
},
returns = {}
}
}
},
{
name = "points",
tag = "graphicsPrimitives",
summary = "Draw one or more points.",
description = "Draws one or more points.",
key = "lovr.graphics.points",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x coordinate of the point."
},
{
name = "y",
type = "number",
description = "The y coordinate of the point."
},
{
name = "z",
type = "number",
description = "The z coordinate of the point."
},
{
name = "...",
type = "number",
description = "More points."
}
},
returns = {}
},
{
arguments = {
{
name = "points",
type = "table",
description = "A table of points, as described above."
}
},
returns = {}
}
}
},
{
name = "pop",
tag = "graphicsTransforms",
summary = "Pop the current transform off the stack.",
description = "Pops the current transform from the stack, returning to the transformation that was applied before `lovr.graphics.push` was called.",
key = "lovr.graphics.pop",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {}
}
},
related = {
"lovr.graphics.push"
},
notes = "An error is thrown if there isn't a transform to pop. This can happen if you forget to call push before calling pop, or if you have an unbalanced sequence of pushes and pops."
},
{
name = "present",
tag = "window",
summary = "Present a frame to the window.",
description = "Presents the results of pending drawing operations to the window. This is automatically called after `lovr.draw` by the default `lovr.run` function.",
key = "lovr.graphics.present",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "print",
tag = "graphicsPrimitives",
summary = "Render text.",
description = "Draws text in 3D space using the active font.",
key = "lovr.graphics.print",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "str",
type = "string",
description = "The text to render."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the text.",
default = 0
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the text.",
default = 0
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the text.",
default = 0
},
{
name = "scale",
type = "number",
description = "The scale of the text.",
default = 1
},
{
name = "angle",
type = "number",
description = "The number of radians to rotate the text around its rotation axis.",
default = 0
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation.",
default = 0
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation.",
default = 1
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation.",
default = 0
},
{
name = "wrap",
type = "number",
description = "The maximum width of each line, in meters (affected by `scale`). Set to 0 or nil for no wrapping.",
default = "0"
},
{
name = "halign",
type = "HorizontalAlign",
description = "The horizontal alignment.",
default = "'center'"
},
{
name = "valign",
type = "VerticalAlign",
description = "The vertical alignment.",
default = "'middle'"
}
},
returns = {}
}
},
related = {
"lovr.graphics.getFont",
"lovr.graphics.setFont",
"lovr.graphics.newFont",
"Font"
},
notes = "Unicode text is supported.\n\nUse `\\n` to add line breaks.\n\nLÖVR uses a fancy technique for font rendering called multichannel signed distance fields. This leads to crisp text in VR, but requires a special shader to use. LÖVR internally switches to the appropriate shader, but only when the default shader is already set. If you see strange font artifacts, make sure you switch back to the default shader by using `lovr.graphics.setShader()` before you draw text."
},
{
name = "push",
tag = "graphicsTransforms",
summary = "Push a copy of the current transform onto the stack.",
description = "Pushes a copy of the current transform onto the transformation stack. After changing the transform using `lovr.graphics.translate`, `lovr.graphics.rotate`, and `lovr.graphics.scale`, the original state can be restored using `lovr.graphics.pop`.",
key = "lovr.graphics.push",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {}
}
},
related = {
"lovr.graphics.pop"
},
notes = "An error is thrown if more than 64 matrices are pushed. This can happen accidentally if a push isn't followed by a corresponding pop."
},
{
name = "reset",
tag = "graphicsState",
summary = "Reset all graphics state.",
description = "Resets the graphics state. This includes the coordinate transformation, projection, shader, colors, scissor, and culling state.",
key = "lovr.graphics.reset",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "rotate",
tag = "graphicsTransforms",
summary = "Rotate the coordinate system.",
description = "Rotates the coordinate system around an axis.\n\nThe rotation will last until `lovr.draw` returns or the transformation is popped off the transformation stack.",
key = "lovr.graphics.rotate",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "angle",
type = "number",
description = "The amount to rotate the coordinate system by, in radians."
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation.",
default = "0"
}
},
returns = {}
}
},
related = {
"lovr.graphics.scale",
"lovr.graphics.translate",
"lovr.graphics.transform"
},
notes = "Order matters when scaling, translating, and rotating the coordinate system."
},
{
name = "scale",
tag = "graphicsTransforms",
summary = "Scale the coordinate system.",
description = "Scales the coordinate system in 3 dimensions. This will cause objects to appear bigger or smaller.\n\nThe scaling will last until `lovr.draw` returns or the transformation is popped off the transformation stack.",
key = "lovr.graphics.scale",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The amount to scale on the x axis."
},
{
name = "y",
type = "number",
description = "The amount to scale on the y axis.",
default = "x"
},
{
name = "z",
type = "number",
description = "The amount to scale on the z axis.",
default = "x"
}
},
returns = {}
}
},
related = {
"lovr.graphics.rotate",
"lovr.graphics.translate",
"lovr.graphics.transform"
},
notes = "Order matters when scaling, translating, and rotating the coordinate system."
},
{
name = "setBackgroundColor",
tag = "graphicsState",
summary = "Set the background color.",
description = "Sets the background color used to clear the screen. Color components are from 0.0 to 1.0.",
key = "lovr.graphics.setBackgroundColor",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "r",
type = "number",
description = "The red component of the background color."
},
{
name = "g",
type = "number",
description = "The green component of the background color."
},
{
name = "b",
type = "number",
description = "The blue component of the background color."
},
{
name = "a",
type = "number",
description = "The alpha component of the background color.",
default = "1.0"
}
},
returns = {}
}
},
notes = "The default background color is black."
},
{
name = "setBlendMode",
tag = "graphicsState",
summary = "Set the blend mode.",
description = "Sets the blend mode. The blend mode controls how each pixel's color is blended with the previous pixel's color when drawn.",
key = "lovr.graphics.setBlendMode",
module = "lovr.graphics",
related = {
"BlendMode",
"BlendAlphaMode"
},
variants = {
{
arguments = {
{
name = "blend",
type = "BlendMode",
description = "The blend mode."
},
{
name = "alphaBlend",
type = "BlendAlphaMode",
description = "The alpha blend mode."
}
},
returns = {}
}
}
},
{
name = "setCanvas",
tag = "graphicsState",
summary = "Set the active Canvas.",
description = "Sets or disables the active Canvas object. If there is an active Canvas, things will be rendered to the Textures attached to that Canvas instead of to the headset.",
key = "lovr.graphics.setCanvas",
module = "lovr.graphics",
related = {
"Canvas:renderTo",
"Canvas"
},
variants = {
{
arguments = {
{
name = "canvas",
type = "Canvas",
description = "The new active Canvas object, or `nil` to just render to the headset."
}
},
returns = {}
}
}
},
{
name = "setColor",
tag = "graphicsState",
summary = "Set the global color factor.",
description = "Sets the color used for drawing objects. Color components are from 0.0 to 1.0. Every pixel drawn will be multiplied (i.e. tinted) by this color. This is a global setting, so it will affect all subsequent drawing operations.",
key = "lovr.graphics.setColor",
module = "lovr.graphics",
notes = "The default color is white.",
variants = {
{
arguments = {
{
name = "r",
type = "number",
description = "The red component of the color."
},
{
name = "g",
type = "number",
description = "The green component of the color."
},
{
name = "b",
type = "number",
description = "The blue component of the color."
},
{
name = "a",
type = "number",
description = "The alpha component of the color.",
default = "1.0"
}
},
returns = {}
},
{
arguments = {
{
name = "color",
type = "table",
description = "A table containing the color components."
}
},
returns = {}
}
},
examples = {
{
description = "Draw a red cube.",
code = "function lovr.draw()\n lovr.graphics.setColor(1.0, 0, 0)\n lovr.graphics.cube('fill', 0, 1.7, -1, .5, lovr.timer.getTime())\nend"
}
}
},
{
name = "setCullingEnabled",
tag = "graphicsState",
summary = "Enable or disable backface culling.",
description = "Enables or disables culling. Culling is an optimization that avoids rendering the back face of polygons. This improves performance by reducing the number of polygons drawn, but requires that the vertices in triangles are specified in a consistent clockwise or counter clockwise order.",
key = "lovr.graphics.setCullingEnabled",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "isEnabled",
type = "boolean",
description = "Whether or not culling should be enabled."
}
},
returns = {}
}
},
notes = "Culling is disabled by default."
},
{
name = "setDefaultFilter",
tag = "graphicsState",
summary = "Set the default filter mode for Textures.",
description = "Sets the default filter mode for new Textures. This controls how textures are sampled when they are minified, magnified, or stretched.",
key = "lovr.graphics.setDefaultFilter",
module = "lovr.graphics",
related = {
"Texture:getFilter",
"Texture:setFilter"
},
variants = {
{
arguments = {
{
name = "mode",
type = "FilterMode",
description = "The filter mode."
},
{
name = "anisotropy",
type = "number",
description = "If the filtering mode is \"anisotropic\", returns the level of anisotropy. Otherwise, this will be nil."
}
},
returns = {}
}
}
},
{
name = "setDepthTest",
tag = "graphicsState",
summary = "Set or disable the depth test.",
description = "Sets the current depth test. The depth test controls how overlapping objects are rendered.",
key = "lovr.graphics.setDepthTest",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "compareMode",
type = "CompareMode",
description = "The new depth test. Use `nil` to disable the depth test.",
default = "nil"
},
{
name = "write",
type = "boolean",
description = "Whether pixels will have their z value updated when rendered to.",
default = "true"
}
},
returns = {}
}
},
notes = "The depth test is an advanced technique to control how 3D objects overlap each other when they are rendered. It works as follows:\n\n- Each pixel keeps track of its z value as well as its color.\n- If `write` is enabled when something is drawn, then any pixels that are drawn will have their\n z values updated.\n- Additionally, anything drawn will first compare the existing z value of a pixel with the new z\n value. The `compareMode` setting determines how this comparison is performed. If the\n comparison succeeds, the new pixel will overwrite the previous one, otherwise that pixel won't\n be rendered to.\n\nSmaller z values are closer to the camera.\n\nThe default compare mode is `lequal`, which usually gives good results for normal 3D rendering."
},
{
name = "setFont",
tag = "graphicsState",
summary = "Set the active font.",
description = "Sets the active font used to render text with `lovr.graphics.print`.",
key = "lovr.graphics.setFont",
module = "lovr.graphics",
related = {
"lovr.graphics.print"
},
variants = {
{
arguments = {
{
name = "font",
type = "Font",
description = "The font to use. If `nil`, the default font is set.",
default = "nil"
}
},
returns = {}
}
}
},
{
name = "setLineWidth",
tag = "graphicsState",
summary = "Set the line width.",
description = "Sets the width of lines rendered using `lovr.graphics.line`.",
key = "lovr.graphics.setLineWidth",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "width",
type = "number",
description = "The new line width, in pixels."
}
},
returns = {}
}
},
related = {
"lovr.graphics.line"
},
notes = "The default line width is `1.0`.\n\nDriver support for line widths is poor. The actual width of lines may be different from what is set here. In particular, some graphics drivers only support a line width of `1.0`."
},
{
name = "setPointSize",
tag = "graphicsState",
summary = "Set the point size.",
description = "Sets the width of drawn points, in pixels.",
key = "lovr.graphics.setPointSize",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "size",
type = "number",
description = "The new point size."
}
},
returns = {}
}
},
related = {
"lovr.graphics.points"
},
notes = "The default point size is `1.0`."
},
{
name = "setShader",
tag = "graphicsState",
summary = "Set or disable the active shader.",
description = "Sets or disables the Shader used for drawing.",
key = "lovr.graphics.setShader",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "shader",
type = "Shader",
description = "The shader to use."
}
},
returns = {}
},
{
description = "Revert back to the default shader.",
arguments = {},
returns = {}
}
}
},
{
name = "setStencilTest",
tag = "graphicsState",
summary = "Set the stencil test.",
description = "Sets the stencil test. The stencil test lets you mask out pixels that meet certain criteria, based on the contents of the stencil buffer. The stencil buffer can be modified using `lovr.graphics.stencil`. After rendering to the stencil buffer, the stencil test can be set to control how subsequent drawing functions are masked by the stencil buffer.",
key = "lovr.graphics.setStencilTest",
module = "lovr.graphics",
notes = "Stencil values are between 0 and 255.",
variants = {
{
arguments = {
{
name = "compareMode",
type = "CompareMode",
description = "The comparison method used to decide if a pixel should be visible, or nil if the stencil test is disabled."
},
{
name = "compareValue",
type = "number",
description = "The value to compare stencil values to."
}
},
returns = {}
},
{
description = "Disables the stencil test.",
arguments = {},
returns = {}
}
},
related = {
"lovr.graphics.stencil"
}
},
{
name = "setWinding",
tag = "graphicsState",
summary = "Set the winding direction.",
description = "Sets the polygon winding. The winding direction determines which face of a triangle is the front face and which is the back face. This lets the graphics engine cull the back faces of polygons, improving performance. The default is counterclockwise.",
key = "lovr.graphics.setWinding",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "winding",
type = "Winding",
description = "The new winding direction."
}
},
returns = {}
}
},
related = {
"lovr.graphics.setCullingEnabled",
"lovr.graphics.isCullingEnabled"
},
notes = "Culling is initially disabled and must be enabled using `lovr.graphics.setCullingEnabled`.\n\nThe default winding direction is counterclockwise."
},
{
name = "setWireframe",
tag = "graphicsState",
summary = "Enable or disable wireframe rendering.",
description = "Enables or disables wireframe rendering. This is meant to be used as a debugging tool.",
key = "lovr.graphics.setWireframe",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "wireframe",
type = "boolean",
description = "Whether or not wireframe rendering should be enabled."
}
},
returns = {}
}
},
notes = "Wireframe rendering is initially disabled."
},
{
name = "skybox",
tag = "graphicsPrimitives",
summary = "Render a skybox.",
description = "Render a skybox from a texture. Two common kinds of skybox textures are supported: A rectangular texture with an equirectangular projection can be used, or a \"cubemap\" texture created from 6 images.",
key = "lovr.graphics.skybox",
module = "lovr.graphics",
examples = {
{
code = "function lovr.load()\n skybox = lovr.graphics.newTexture({\n 'right.png',\n 'left.png',\n 'up.png',\n 'down.png',\n 'back.png',\n 'front.png'\n }, { type = 'cube' })\n\n -- or skybox = lovr.graphics.newTexture('equirectangular.png')\nend\n\nfunction lovr.draw()\n local angle, ax, ay, az = lovr.headset.getOrientation()\n lovr.graphics.skybox(skybox, -angle, ax, ay, az)\nend"
}
},
variants = {
{
arguments = {
{
name = "texture",
type = "Texture",
description = "The texture to use."
},
{
name = "angle",
type = "number",
description = "How much to rotate the skybox around its axis of rotation.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "canvas",
type = "Canvas",
description = "The canvas to use."
},
{
name = "angle",
type = "number",
description = "How much to rotate the skybox around its axis of rotation.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the axis of rotation.",
default = "0"
}
},
returns = {}
}
}
},
{
name = "sphere",
tag = "graphicsPrimitives",
summary = "Draw a sphere.",
description = "Draws a sphere.",
key = "lovr.graphics.sphere",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x coordinate of the center of the sphere.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the sphere.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the sphere.",
default = "0"
},
{
name = "size",
type = "number",
description = "The size of the sphere, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the sphere around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the sphere's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the sphere's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the sphere's axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "texture",
type = "Texture",
description = "The Texture to apply to the sphere."
},
{
name = "x",
type = "number",
description = "The x coordinate of the center of the sphere.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate of the center of the sphere.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate of the center of the sphere.",
default = "0"
},
{
name = "size",
type = "number",
description = "The size of the sphere, in meters.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The rotation of the sphere around its rotation axis, in radians.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x coordinate of the sphere's axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y coordinate of the sphere's axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z coordinate of the sphere's axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "transform",
type = "Transform",
description = "The sphere's transform."
}
},
returns = {}
},
{
arguments = {
{
name = "texture",
type = "Texture",
description = "The Texture to apply to the sphere."
},
{
name = "transform",
type = "Transform",
description = "The sphere's transform."
}
},
returns = {}
}
}
},
{
name = "stencil",
tag = "graphicsPrimitives",
summary = "Modify the stencil buffer.",
description = "Renders to the stencil buffer using a function.",
key = "lovr.graphics.stencil",
module = "lovr.graphics",
notes = "Stencil values are between 0 and 255.",
variants = {
{
arguments = {
{
name = "callback",
type = "function",
description = "The function that will be called to render to the stencil buffer.",
arguments = {},
returns = {}
},
{
name = "action",
type = "StencilAction",
description = "How to modify the stencil value of pixels that are rendered to.",
default = "'replace'"
},
{
name = "value",
type = "number",
description = "If `action` is \"replace\", this is the value that pixels are replaced with.",
default = "1"
},
{
name = "keep",
type = "boolean",
description = "If false, the stencil buffer will be cleared to zero before rendering.",
default = "false"
}
},
returns = {}
},
{
arguments = {
{
name = "callback",
type = "function",
description = "The function that will be called to render to the stencil buffer.",
arguments = {},
returns = {}
},
{
name = "action",
type = "StencilAction",
description = "How to modify the stencil value of pixels that are rendered to.",
default = "'replace'"
},
{
name = "value",
type = "number",
description = "If `action` is \"replace\", this is the value that pixels are replaced with.",
default = "1"
},
{
name = "initial",
type = "number",
description = "The value to clear the stencil buffer to before rendering.",
default = "0"
}
},
returns = {}
}
},
related = {
"lovr.graphics.getStencilTest",
"lovr.graphics.setStencilTest"
}
},
{
name = "transform",
tag = "graphicsTransforms",
summary = "Apply a general transform to the coordinate system.",
description = "Apply a transform to the coordinate system, changing its translation, rotation, and scale using a single function. A Transform object can also be used.\n\nThe transformation will last until `lovr.draw` returns or the transformation is popped off the transformation stack.",
key = "lovr.graphics.transform",
module = "lovr.graphics",
related = {
"lovr.graphics.rotate",
"lovr.graphics.scale",
"lovr.graphics.translate"
},
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x component of the translation.",
default = 0
},
{
name = "y",
type = "number",
description = "The y component of the translation.",
default = 0
},
{
name = "z",
type = "number",
description = "The z component of the translation.",
default = 0
},
{
name = "sx",
type = "number",
description = "The x scale factor.",
default = 1
},
{
name = "sy",
type = "number",
description = "The y scale factor.",
default = 1
},
{
name = "sz",
type = "number",
description = "The z scale factor.",
default = 1
},
{
name = "angle",
type = "number",
description = "The number of radians to rotate around the rotation axis.",
default = 0
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation.",
default = 0
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation.",
default = 1
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation.",
default = 0
}
},
returns = {}
},
{
description = "Modify the coordinate system using a Transform object.",
arguments = {
{
name = "transform",
type = "Transform",
description = "The Transform to apply to the coordinate system."
}
},
returns = {}
}
}
},
{
name = "translate",
tag = "graphicsTransforms",
summary = "Translate the coordinate system.",
description = "Translates the coordinate system in three dimensions. All graphics operations that use coordinates will behave as if they are offset by the translation value.\n\nThe translation will last until `lovr.draw` returns or the transformation is popped off the transformation stack.",
key = "lovr.graphics.translate",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The amount to translate on the x axis."
},
{
name = "y",
type = "number",
description = "The amount to translate on the y axis."
},
{
name = "z",
type = "number",
description = "The amount to translate on the z axis."
}
},
returns = {}
}
},
related = {
"lovr.graphics.rotate",
"lovr.graphics.scale",
"lovr.graphics.transform"
},
notes = "Order matters when scaling, translating, and rotating the coordinate system."
},
{
name = "triangle",
tag = "graphicsPrimitives",
summary = "Draw a triangle.",
description = "Draws a triangle from three points.",
key = "lovr.graphics.triangle",
module = "lovr.graphics",
notes = "Unlike some of the other primitives, exactly 3 points are required here.",
variants = {
{
arguments = {
{
name = "mode",
type = "DrawMode",
description = "How to draw the triangle."
},
{
name = "x1",
type = "number",
description = "The x coordinate of the first point."
},
{
name = "y1",
type = "number",
description = "The y coordinate of the first point."
},
{
name = "z1",
type = "number",
description = "The z coordinate of the first point."
},
{
name = "x2",
type = "number",
description = "The x coordinate of the second point."
},
{
name = "y2",
type = "number",
description = "The y coordinate of the second point."
},
{
name = "z2",
type = "number",
description = "The z coordinate of the second point."
},
{
name = "x3",
type = "number",
description = "The x coordinate of the third point."
},
{
name = "y3",
type = "number",
description = "The y coordinate of the third point."
},
{
name = "z3",
type = "number",
description = "The z coordinate of the third point."
}
},
returns = {}
},
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply."
},
{
name = "x1",
type = "number",
description = "The x coordinate of the first point."
},
{
name = "y1",
type = "number",
description = "The y coordinate of the first point."
},
{
name = "z1",
type = "number",
description = "The z coordinate of the first point."
},
{
name = "x2",
type = "number",
description = "The x coordinate of the second point."
},
{
name = "y2",
type = "number",
description = "The y coordinate of the second point."
},
{
name = "z2",
type = "number",
description = "The z coordinate of the second point."
},
{
name = "x3",
type = "number",
description = "The x coordinate of the third point."
},
{
name = "y3",
type = "number",
description = "The y coordinate of the third point."
},
{
name = "z3",
type = "number",
description = "The z coordinate of the third point."
}
},
returns = {}
}
}
}
},
objects = {
{
name = "Animator",
summary = "An object that plays and mixes animations.",
description = "An animator is an object that controls the playback of skeletal animations. Animators can be attached to models using `Model:setAnimator`. Once attached, the Model will render using the animator's pose instead of the default pose. Don't forget to update the animator in `lovr.update` using `Animator:update`!",
key = "Animator",
module = "lovr.graphics",
examples = {
{
code = "function lovr.load()\n model = lovr.graphics.newModel('model.fbx')\n animator = lovr.graphics.newAnimator(model)\n animator:play(animator:getAnimationNames()[1])\n model:setAnimator(animator)\n\n shader = lovr.graphics.newShader([[\n vec4 vertex(mat4 projection, mat4 transform, vec4 vertex) {\n return projection * transform * lovrPoseMatrix * vertex;\n }\n ]], nil)\nend\n\nfunction lovr.update(dt)\n animator:update(dt)\nend\n\nfunction lovr.draw()\n lovr.graphics.setShader(shader)\n model:draw()\nend"
}
},
constructors = {
"lovr.graphics.newAnimator"
},
methods = {
{
name = "getAlpha",
summary = "Get the alpha (weight) of an animation.",
description = "Returns the current alpha factor of an animation.",
key = "Animator:getAlpha",
module = "lovr.graphics",
related = {
"Animator:getPriority",
"Animator:setPriority"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation."
}
},
returns = {
{
name = "alpha",
type = "number",
description = "The alpha of the animation."
}
}
}
},
notes = "The alpha is a number between 0 and 1 indicating how the animation's pose is blended with other animations. An alpha of 1 means the animation's pose will completely overwrite the existing pose, whereas an alpha of .5 would blend half of the animation's pose with half of the existing pose. This, combined with the animation's priority, allows for fine grained control over how multiple playing animations get blended together."
},
{
name = "getAnimationCount",
summary = "Get the number of animations the Animator can play.",
description = "Returns the number of animations the Animator can play.",
key = "Animator:getAnimationCount",
module = "lovr.graphics",
related = {
"Animator:getAnimationNames"
},
variants = {
{
arguments = {},
returns = {
{
name = "count",
type = "number",
description = "The number of animations."
}
}
}
}
},
{
name = "getAnimationNames",
summary = "Get a table containing all animation names.",
description = "Returns a table containing the names of all animations supported by this Animator.",
key = "Animator:getAnimationNames",
module = "lovr.graphics",
related = {
"Animator:getAnimationCount"
},
variants = {
{
arguments = {},
returns = {
{
name = "names",
type = "table",
description = "The list of animation names as strings."
}
}
},
{
arguments = {
{
name = "t",
type = "table",
description = "A table to fill with the animation names."
}
},
returns = {}
}
}
},
{
name = "getDuration",
summary = "Get the duration of an animation.",
description = "Returns the duration of an animation.",
key = "Animator:getDuration",
module = "lovr.graphics",
related = {
"Animator:seek",
"Animator:tell"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation."
}
},
returns = {
{
name = "duration",
type = "number",
description = "The duration of the animation at its normal speed, in seconds."
}
}
}
}
},
{
name = "getPriority",
summary = "Get the priority of an animation, used for mixing.",
description = "Returns the priority of an animation.",
key = "Animator:getPriority",
module = "lovr.graphics",
related = {
"Animator:getAlpha",
"Animator:setAlpha"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation."
}
},
returns = {
{
name = "priority",
type = "number",
description = "The priority of the animation."
}
}
}
},
notes = "The priority controls the order that multiple playing animations get blended together. Animations with a lower priority will get applied first, and animations with higher priority will get layered on top afterwards. If two or more animations have the same priority, they could get applied in any order. All animations start with a priority of 1.\n\nYou can use priority and alpha to control how different animations blend together. For instance, if you have a character with \"throw\" and \"walk\" animations and both of them key the bones in the arm, you could have the character walk and throw at the same time by giving the \"throw\" animation a higher priority and playing it over the walk animation."
},
{
name = "getSpeed",
summary = "Get the speed of an animation.",
description = "Returns the speed factor for an animation or the Animator's global speed factor.",
key = "Animator:getSpeed",
module = "lovr.graphics",
variants = {
{
description = "Get the speed of a specific animation.",
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation."
}
},
returns = {
{
name = "speed",
type = "number",
description = "The current speed multiplier."
}
}
},
{
description = "Get the global speed multiplier for the Animator.",
arguments = {},
returns = {
{
name = "speed",
type = "number",
description = "The current speed multiplier."
}
}
}
}
},
{
name = "isLooping",
summary = "Check if an animation is looping.",
description = "Returns whether an animation is looping.",
key = "Animator:isLooping",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "animation",
type = "string",
description = "The name of the animation."
}
},
returns = {
{
name = "looping",
type = "boolean",
description = "Whether or not the animation is looping."
}
}
}
}
},
{
name = "isPlaying",
summary = "Check if an animation is playing.",
description = "Returns whether an animation is currently playing.",
key = "Animator:isPlaying",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "animation",
type = "string",
description = "The name of the animation."
}
},
returns = {
{
name = "playing",
type = "boolean",
description = "Whether or not the animation is playing."
}
}
}
}
},
{
name = "pause",
summary = "Pause an animation.",
description = "Pauses an animation. This will stop the animation without resetting its time.",
key = "Animator:pause",
module = "lovr.graphics",
related = {
"Animator:play",
"Animator:stop",
"Animator:resume",
"Animator:isPlaying",
"Animator:getAnimationNames"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The animation to pause."
}
},
returns = {}
}
}
},
{
name = "play",
summary = "Start playing an animation.",
description = "Plays an animation. If the animation is already playing, it will start over at the beginning.",
key = "Animator:play",
module = "lovr.graphics",
related = {
"Animator:stop",
"Animator:pause",
"Animator:resume",
"Animator:isPlaying",
"Animator:getAnimationNames"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation to play."
}
},
returns = {}
}
}
},
{
name = "reset",
summary = "Stop all animations.",
description = "Resets the Animator to its initial state. All animations will be stopped, their speed will be reset to `1.0`, their looping state will be reset, and the Animator's global speed will be reset to `1.0`.",
key = "Animator:reset",
module = "lovr.graphics",
related = {},
variants = {
{
arguments = {},
returns = {}
}
}
},
{
name = "resume",
summary = "Resume a paused animation.",
description = "Resumes an animation. This will play an animation without starting it over at the beginning.",
key = "Animator:resume",
module = "lovr.graphics",
related = {
"Animator:pause",
"Animator:play",
"Animator:stop",
"Animator:isPlaying",
"Animator:getAnimationNames"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The animation to resume."
}
},
returns = {}
}
}
},
{
name = "seek",
summary = "Seek to a specific time in an animation.",
description = "Seeks to a specific time in an animation.",
key = "Animator:seek",
module = "lovr.graphics",
related = {
"Animator:tell",
"Animator:getDuration"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation to seek."
},
{
name = "time",
type = "number",
description = "The time to seek to, in seconds."
}
},
returns = {}
}
},
notes = "If the time is greater than the duration of the animation, the animation will stop if it isn't currently looping. Negative time values are supported for animations (regardless of looping state) and will seek backwards from the animation's end time.\n\nSeeking an animation does not stop or play the animation."
},
{
name = "setAlpha",
summary = "Set the alpha (weight) of an animation.",
description = "Sets the current alpha factor of an animation.",
key = "Animator:setAlpha",
module = "lovr.graphics",
related = {
"Animator:getPriority",
"Animator:setPriority"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation."
},
{
name = "alpha",
type = "number",
description = "The alpha of the animation."
}
},
returns = {}
}
},
notes = "The alpha is a number between 0 and 1 indicating how the animation's pose is blended with other animations. An alpha of 1 means the animation's pose will completely overwrite the existing pose, whereas an alpha of .5 would blend half of the animation's pose with half of the existing pose. This, combined with the animation's priority, allows for fine grained control over how multiple playing animations get blended together."
},
{
name = "setLooping",
summary = "Set whether an animation should loop.",
description = "Sets whether an animation loops.",
key = "Animator:setLooping",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "animation",
type = "string",
description = "The name of the animation."
},
{
name = "loop",
type = "boolean",
description = "Whether the animation should loop."
}
},
returns = {}
}
}
},
{
name = "setPriority",
summary = "Set the priority of an animation, used for mixing.",
description = "Sets the priority of an animation.",
key = "Animator:setPriority",
module = "lovr.graphics",
related = {
"Animator:getAlpha",
"Animator:setAlpha"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation."
},
{
name = "priority",
type = "number",
description = "The new priority for the animation."
}
},
returns = {}
}
},
notes = "The priority controls the order that multiple playing animations get blended together. Animations with a lower priority will get applied first, and animations with higher priority will get layered on top afterwards. If two or more animations have the same priority, they could get applied in any order. All animations start with a priority of 1.\n\nYou can use priority and alpha to control how different animations blend together. For instance, if you have a character with \"throw\" and \"walk\" animations and both of them key the bones in the arm, you could have the character walk and throw at the same time by giving the \"throw\" animation a higher priority and playing it over the walk animation."
},
{
name = "setSpeed",
summary = "Set the speed of an animation.",
description = "Sets the speed factor for an animation or the Animator's global speed factor.",
key = "Animator:setSpeed",
module = "lovr.graphics",
variants = {
{
description = "Set the speed of a specific animation.",
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation."
},
{
name = "speed",
type = "number",
description = "The new speed multiplier."
}
},
returns = {}
},
{
description = "Set the global speed multiplier for the Animator.",
arguments = {
{
name = "speed",
type = "number",
description = "The new speed multiplier."
}
},
returns = {}
}
}
},
{
name = "stop",
summary = "Stop an animation.",
description = "Stops an animation.",
key = "Animator:stop",
module = "lovr.graphics",
related = {
"Animator:play",
"Animator:reset",
"Animator:pause",
"Animator:resume",
"Animator:isPlaying",
"Animator:getAnimationNames"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The animation to stop."
}
},
returns = {}
}
}
},
{
name = "tell",
summary = "Get the current time of an animation.",
description = "Returns the current playback time of an animation.",
key = "Animator:tell",
module = "lovr.graphics",
related = {
"Animator:seek",
"Animator:getDuration"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the animation."
}
},
returns = {
{
name = "time",
type = "number",
description = "The current time the animation is at, in seconds."
}
}
}
},
notes = "This will always be between 0 and the animation's duration."
},
{
name = "update",
summary = "Advance the Animator's clock.",
description = "Updates the Animator's clock, advancing all playing animations by the time step.",
key = "Animator:update",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "dt",
type = "number",
description = "The amount of time to advance."
}
},
returns = {}
}
}
}
},
notes = "Animations require that you multiply vertices by a special pose matrix in your vertex shader:\n\n vec4 vertex(mat4 projection, mat4 transform, vec4 vertex) {\n return projection * transform * lovrPoseMatrix * vertex;\n }"
},
{
name = "Canvas",
summary = "An offscreen render target.",
description = "A Canvas is also known as a framebuffer or render-to-texture. It allows you to render to a texture instead of directly to the screen. This lets you postprocess or transform the results later before finally rendering them to the screen.\n\nAfter creating a Canvas, you can attach Textures to it using `Canvas:setTexture`.",
key = "Canvas",
module = "lovr.graphics",
examples = {
{
description = "Apply a postprocessing effect (wave) using a Canvas and a fragment shader.",
code = "function lovr.load()\n lovr.graphics.setBackgroundColor(.1, .1, .1)\n canvas = lovr.graphics.newCanvas(lovr.headset.getDisplayDimensions())\n\n wave = lovr.graphics.newShader([[\n vec4 position(mat4 projection, mat4 transform, vec4 vertex) {\n return vertex;\n }\n ]], [[\n uniform float time;\n vec4 color(vec4 graphicsColor, sampler2D image, vec2 uv) {\n uv.x += sin(uv.y * 10 + time * 4) * .01;\n uv.y += cos(uv.x * 10 + time * 4) * .01;\n return graphicsColor * lovrDiffuseColor * vertexColor * texture(image, uv);\n }\n ]])\nend\n\nfunction lovr.update(dt)\n wave:send('time', lovr.timer.getTime())\nend\n\nfunction lovr.draw(eye)\n -- Render the scene to the canvas instead of the headset.\n canvas:renderTo(function()\n lovr.graphics.clear()\n local size = 5\n for i = 1, size do\n for j = 1, size do\n for k = 1, size do\n lovr.graphics.setColor(i / size, j / size, k / size)\n local x, y, z = i - size / 2, j - size / 2, k - size / 2\n lovr.graphics.cube('fill', x, y, z, .5)\n end\n end\n end\n end)\n\n -- Render the canvas to the headset using a shader.\n lovr.graphics.setColor(1, 1, 1)\n lovr.graphics.setShader(wave)\n lovr.graphics.plane(canvas)\n lovr.graphics.setShader()\nend"
}
},
constructors = {
"lovr.graphics.newCanvas"
},
methods = {
{
name = "getDepthFormat",
summary = "Get the format of the Canvas depth buffer.",
description = "Returns the format of the Canvas depth buffer.",
key = "Canvas:getDepthFormat",
module = "lovr.graphics",
related = {
"lovr.graphics.newCanvas",
"DepthFormat"
},
variants = {
{
arguments = {},
returns = {
{
name = "format",
type = "DepthFormat",
description = "The format of the Canvas depth buffer."
}
}
}
}
},
{
name = "getDimensions",
summary = "Get the dimensions of the Canvas.",
description = "Returns the dimensions of the Canvas, its Textures, and its depth buffer.",
key = "Canvas:getDimensions",
module = "lovr.graphics",
related = {
"Canvas:getWidth",
"Canvas:getHeight"
},
variants = {
{
arguments = {},
returns = {
{
name = "width",
type = "number",
description = "The width of the Canvas, in pixels."
},
{
name = "height",
type = "number",
description = "The height of the Canvas, in pixels."
}
}
}
},
notes = "The dimensions of a Canvas can not be changed after it is created."
},
{
name = "getFormat",
summary = "Get the format of the Canvas texture.",
description = "Returns the internal storage format used for the Canvas.",
key = "Canvas:getFormat",
module = "lovr.graphics",
related = {
"TextureFormat",
"lovr.graphics.newCanvas"
},
variants = {
{
arguments = {},
returns = {
{
name = "format",
type = "TextureFormat",
description = "The texture format used by the Canvas."
}
}
}
}
},
{
name = "getHeight",
summary = "Get the height of the Canvas.",
description = "Returns the height of the Canvas, its Textures, and its depth buffer.",
key = "Canvas:getHeight",
module = "lovr.graphics",
related = {
"Canvas:getWidth",
"Canvas:getDimensions"
},
variants = {
{
arguments = {},
returns = {
{
name = "height",
type = "number",
description = "The height of the Canvas, in pixels."
}
}
}
},
notes = "The height of a Canvas can not be changed after it is created."
},
{
name = "getMSAA",
summary = "Get the number of MSAA samples used by the Canvas.",
description = "Returns the number of multisample antialiasing samples to use when rendering to the Canvas. Increasing this number will make the contents of the Canvas appear more smooth at the cost of performance. It is common to use powers of 2 for this value.",
key = "Canvas:getMSAA",
module = "lovr.graphics",
related = {
"lovr.graphics.newCanvas",
"lovr.graphics.newTexture"
},
variants = {
{
arguments = {},
returns = {
{
name = "samples",
type = "number",
description = "The number of MSAA samples."
}
}
}
},
notes = "All textures attached to the Canvas must be created with this MSAA value."
},
{
name = "getTexture",
summary = "Get the Textures attached to the Canvas.",
description = "Returns the set of Textures currently attached to the Canvas.",
key = "Canvas:getTexture",
module = "lovr.graphics",
notes = "Up to 4 Textures can be attached at once.",
variants = {
{
arguments = {},
returns = {
{
name = "...",
type = "Texture",
description = "One or more Textures attached to the Canvas."
}
}
}
}
},
{
name = "getWidth",
summary = "Get the width of the Canvas.",
description = "Returns the width of the Canvas, its Textures, and its depth buffer.",
key = "Canvas:getWidth",
module = "lovr.graphics",
related = {
"Canvas:getHeight",
"Canvas:getDimensions"
},
variants = {
{
arguments = {},
returns = {
{
name = "width",
type = "number",
description = "The width of the Canvas, in pixels."
}
}
}
},
notes = "The width of a Canvas can not be changed after it is created."
},
{
name = "isStereo",
summary = "Check if the Canvas is stereo.",
description = "Returns whether the Canvas was created with the `stereo` flag. Drawing something to a stereo Canvas will draw it to two viewports in the left and right half of the Canvas, using transform information from two different eyes.",
key = "Canvas:isStereo",
module = "lovr.graphics",
related = {
"lovr.graphics.newCanvas",
"lovr.graphics.fill"
},
variants = {
{
arguments = {},
returns = {
{
name = "stereo",
type = "boolean",
description = "Whether the Canvas is stereo."
}
}
}
}
},
{
name = "newTextureData",
summary = "Create a new TextureData from a Canvas texture.",
description = "Returns a new TextureData containing the contents of a Texture attached to the Canvas.",
key = "Canvas:newTextureData",
module = "lovr.graphics",
related = {
"lovr.data.newTextureData",
"TextureData"
},
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the Texture to read from.",
default = "1"
}
},
returns = {
{
name = "textureData",
type = "TextureData",
description = "The new TextureData."
}
}
}
}
},
{
name = "renderTo",
summary = "Render to the Canvas using a function.",
description = "Renders to the Canvas using a function. All graphics functions inside the callback will affect the Canvas contents instead of directly rendering to the headset. This can be used in `lovr.update`.",
key = "Canvas:renderTo",
module = "lovr.graphics",
notes = "Make sure you clear the contents of the canvas before rendering by using `lovr.graphics.clear`. Otherwise there might be data in the canvas left over from a previous frame.\n\nAlso note that the transform stack is not modified by this function. If you plan on modifying the transform stack inside your callback it may be a good idea to use `lovr.graphics.push` and `lovr.graphics.pop` so you can revert to the previous transform afterwards.",
variants = {
{
arguments = {
{
name = "callback",
type = "function",
description = "The function to use to render to the Canvas.",
arguments = {
{
name = "...",
type = "*"
}
},
returns = {}
},
{
name = "...",
type = "*",
description = "Additional arguments to pass to the callback."
}
},
returns = {}
}
}
},
{
name = "setTexture",
summary = "Attach one or more Textures to the Canvas.",
description = "Attaches one or more Textures to the Canvas. When rendering to the Canvas, everything will be drawn to all attached Textures. You can attach different layers of an array, cubemap, or volume texture, and also attach different mipmap levels of Textures.",
key = "Canvas:setTexture",
module = "lovr.graphics",
notes = "There are some restrictions on how textures can be attached:\n\n- Up to 4 textures can be attached at once.\n- Textures must have the same dimensions and multisample settings as the Canvas.\n\nTo specify layers and mipmaps to attach, specify them after the Texture. You can also optionally wrap them in a table.",
variants = {
{
arguments = {
{
name = "...",
type = "*",
description = "One or more Textures to attach to the Canvas."
}
},
returns = {}
}
},
examples = {
{
description = "Various ways to attach textures to a Canvas.",
code = "canvas:setTexture(textureA)\ncanvas:setTexture(textureA, textureB) -- Attach two textures\ncanvas:setTexture(textureA, layer, mipmap) -- Attach a specific layer and mipmap\ncanvas:setTexture(textureA, layer, textureB, layer) -- Attach specific layers\ncanvas:setTexture({ textureA, layer, mipmap }, textureB, { textureC, layer }) -- Tables\ncanvas:setTexture({ { textureA, layer, mipmap }, textureB, { textureC, layer } })"
}
}
}
},
notes = "Up to four textures can be attached to a Canvas and anything rendered to the Canvas will be broadcast to all attached Textures. If you want to do render different things to different textures, add a `#define MULTICANVAS` line to the top of your fragment shader and implement the `void colors` function instead of the usual `vec4 color` function. You can then assign different output colors to `lovrCanvas[0]`, `lovrCanvas[1]`, etc. instead of returning a single color."
},
{
name = "Font",
summary = "A loaded font used to render text.",
description = "A Font is an object created from a TTF file. It can be used to render text with `lovr.graphics.print`.",
key = "Font",
module = "lovr.graphics",
methods = {
{
name = "getAscent",
summary = "Get the ascent of the Font.",
description = "Returns the maximum distance that any glyph will extend above the Font's baseline. Units are generally in meters, see `Font:getPixelDensity`.",
key = "Font:getAscent",
module = "lovr.graphics",
related = {
"Font:getDescent",
"Rasterizer:getAscent"
},
variants = {
{
arguments = {},
returns = {
{
name = "ascent",
type = "number",
description = "The ascent of the Font."
}
}
}
}
},
{
name = "getBaseline",
summary = "Get the baseline of the Font.",
description = "Returns the baseline of the Font. This is where the characters \"rest on\", relative to the y coordinate of the drawn text. Units are generally in meters, see `Font:setPixelDensity`.",
key = "Font:getBaseline",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "baseline",
type = "number",
description = "The baseline of the Font."
}
}
}
}
},
{
name = "getDescent",
summary = "Get the descent of the Font.",
description = "Returns the maximum distance that any glyph will extend below the Font's baseline. Units are generally in meters, see `Font:getPixelDensity` for more information. Note that due to the coordinate system for fonts, this is a negative value.",
key = "Font:getDescent",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "descent",
type = "number",
description = "The descent of the Font."
}
}
}
}
},
{
name = "getHeight",
summary = "Get the height of a line of text.",
description = "Returns the height of a line of text, in meters. Units are in meters, see `Font:setPixelDensity`.",
key = "Font:getHeight",
module = "lovr.graphics",
related = {
"Rasterizer:getHeight"
},
variants = {
{
arguments = {},
returns = {
{
name = "height",
type = "number",
description = "The height of a rendered line of text."
}
}
}
}
},
{
name = "getLineHeight",
summary = "Get the line height of the Font.",
description = "Returns the current line height of the Font. The default is 1.0.",
key = "Font:getLineHeight",
module = "lovr.graphics",
related = {
"Rasterizer:getLineHeight"
},
variants = {
{
arguments = {},
returns = {
{
name = "lineHeight",
type = "number",
description = "The line height."
}
}
}
}
},
{
name = "getPixelDensity",
summary = "Get the pixel density of the Font.",
description = "Returns the current pixel density for the Font. The default is 1.0. Normally, this is in pixels per meter. When rendering to a 2D texture, the units are pixels.",
key = "Font:getPixelDensity",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "pixelDensity",
type = "number",
description = "The current pixel density."
}
}
}
}
},
{
name = "getWidth",
summary = "Get the width of a line of text.",
description = "Returns the width of a string when rendered using the font, with an optional wrap. To get the correct units returned, make sure the pixel density is set with `Font:setPixelDensity`.",
key = "Font:getWidth",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "text",
type = "string",
description = "The text to get the width of."
},
{
name = "wrap",
type = "number",
description = "The width at which to wrap lines, or 0 for no wrap.",
default = "0"
}
},
returns = {
{
name = "width",
type = "number",
description = "The maximum width of any line in the text."
}
}
}
}
},
{
name = "setLineHeight",
summary = "Set the line height of the Font.",
description = "Sets the line height of the Font, which controls how far lines apart lines are vertically separated. This value is a ratio and the default is 1.0.",
key = "Font:setLineHeight",
module = "lovr.graphics",
related = {
"Rasterizer:getLineHeight"
},
variants = {
{
arguments = {
{
name = "lineHeight",
type = "number",
description = "The new line height."
}
},
returns = {}
}
}
},
{
name = "setPixelDensity",
summary = "Set the pixel density of the Font.",
description = "Sets the pixel density for the Font. Normally, this is in pixels per meter. When rendering to a 2D texture, the units are pixels.",
key = "Font:setPixelDensity",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "pixelDensity",
type = "number",
description = "The new pixel density."
}
},
returns = {}
}
}
}
},
constructors = {
"lovr.graphics.newFont"
}
},
{
name = "Material",
summary = "An object that controls texturing and shading.",
description = "A Material is an object used to control how objects appear, through coloring, texturing, and shading. The Material itself holds sets of colors, textures, and other parameters that are made available to Shaders.",
key = "Material",
module = "lovr.graphics",
methods = {
{
name = "getColor",
summary = "Get a color property of the Material.",
description = "Returns a color property for a Material. Different types of colors are supported for different lighting parameters. Colors default to white and are gamma corrected as necessary, see `lovr.graphics.isGammaCorrect` for more info on that.",
key = "Material:getColor",
module = "lovr.graphics",
related = {
"MaterialColor",
"lovr.graphics.setColor"
},
variants = {
{
arguments = {
{
name = "colorType",
type = "MaterialColor",
description = "The type of color to get.",
default = "'diffuse'"
}
},
returns = {
{
name = "r",
type = "number",
description = "The red component of the color."
},
{
name = "g",
type = "number",
description = "The green component of the color."
},
{
name = "b",
type = "number",
description = "The blue component of the color."
},
{
name = "a",
type = "number",
description = "The alpha component of the color."
}
}
}
}
},
{
name = "getScalar",
summary = "Get a scalar property of the Material.",
description = "Returns a numeric property of a Material. Scalar properties default to 1.0.",
key = "Material:getScalar",
module = "lovr.graphics",
related = {
"MaterialScalar"
},
variants = {
{
arguments = {
{
name = "scalarType",
type = "MaterialScalar",
description = "The type of property to get."
}
},
returns = {
{
name = "x",
type = "number",
description = "The value of the property."
}
}
}
}
},
{
name = "getTexture",
summary = "Get a texture for the Material.",
description = "Returns a texture for a Material. Different types of textures are supported for different lighting parameters. If unset, textures default to a blank white texture.",
key = "Material:getTexture",
module = "lovr.graphics",
related = {
"MaterialTexture"
},
variants = {
{
arguments = {
{
name = "textureType",
type = "MaterialTexture",
description = "The type of texture to get.",
default = "'diffuse'"
}
},
returns = {
{
name = "texture",
type = "Texture",
description = "The texture that is set, or `nil` if no texture is set."
}
}
}
}
},
{
name = "getTransform",
summary = "Get the transformation applied to texture coordinates.",
description = "Returns the transformation applied to texture coordinates of the Material.",
key = "Material:getTransform",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "ox",
type = "number",
description = "The texture coordinate x offset."
},
{
name = "oy",
type = "number",
description = "The texture coordinate y offset."
},
{
name = "sx",
type = "number",
description = "The texture coordinate x scale."
},
{
name = "sy",
type = "number",
description = "The texture coordinate y scale."
},
{
name = "angle",
type = "number",
description = "The texture coordinate rotation, in radians."
}
}
}
}
},
{
name = "setColor",
summary = "Set a color property of the Material.",
description = "Sets a color property for a Material. Different types of colors are supported for different lighting parameters. Color channels should be from 0.0 to 1.0. Colors default to white and are gamma corrected as necessary, see `lovr.graphics.isGammaCorrect` for more info on that.",
key = "Material:setColor",
module = "lovr.graphics",
related = {
"MaterialColor",
"lovr.graphics.setColor"
},
variants = {
{
arguments = {
{
name = "colorType",
type = "MaterialColor",
description = "The type of color to get.",
default = "'diffuse'"
},
{
name = "r",
type = "number",
description = "The red component of the color."
},
{
name = "g",
type = "number",
description = "The green component of the color."
},
{
name = "b",
type = "number",
description = "The blue component of the color."
},
{
name = "a",
type = "number",
description = "The alpha component of the color.",
default = "1.0"
}
},
returns = {}
},
{
arguments = {
{
name = "r",
type = "number",
description = "The red component of the color."
},
{
name = "g",
type = "number",
description = "The green component of the color."
},
{
name = "b",
type = "number",
description = "The blue component of the color."
},
{
name = "a",
type = "number",
description = "The alpha component of the color.",
default = "1.0"
}
},
returns = {}
}
}
},
{
name = "setScalar",
summary = "Set a scalar property of the Material.",
description = "Sets a numeric property of a Material. Scalar properties default to 1.0.",
key = "Material:setScalar",
module = "lovr.graphics",
related = {
"MaterialScalar"
},
variants = {
{
arguments = {
{
name = "scalarType",
type = "MaterialScalar",
description = "The type of property to get."
},
{
name = "x",
type = "number",
description = "The value of the property."
}
},
returns = {}
}
}
},
{
name = "setTexture",
summary = "Set a texture for the Material.",
description = "Sets a texture for a Material. Different types of textures are supported for different lighting parameters. If set to `nil`, textures default to a blank white texture.",
key = "Material:setTexture",
module = "lovr.graphics",
related = {
"MaterialTexture",
"lovr.graphics.newTexture"
},
variants = {
{
arguments = {
{
name = "textureType",
type = "MaterialTexture",
description = "The type of texture to get.",
default = "'diffuse'"
},
{
name = "texture",
type = "Texture",
description = "The texture to apply, or `nil` to use the default."
}
},
returns = {}
},
{
arguments = {
{
name = "texture",
type = "Texture",
description = "The texture to apply, or `nil` to use the default."
}
},
returns = {}
},
{
arguments = {
{
name = "textureType",
type = "MaterialTexture",
description = "The type of texture to get.",
default = "'diffuse'"
},
{
name = "canvas",
type = "Canvas",
description = "A Canvas. The first Texture attached to the Canvas will be used."
}
},
returns = {}
},
{
arguments = {
{
name = "canvas",
type = "Canvas",
description = "A Canvas. The first Texture attached to the Canvas will be used."
}
},
returns = {}
}
}
},
{
name = "setTransform",
summary = "Set the transformation applied to texture coordinates.",
description = "Sets the transformation applied to texture coordinates of the Material. This lets you offset, scale, or rotate textures as they are applied to geometry.",
key = "Material:setTransform",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "ox",
type = "number",
description = "The texture coordinate x offset."
},
{
name = "oy",
type = "number",
description = "The texture coordinate y offset."
},
{
name = "sx",
type = "number",
description = "The texture coordinate x scale."
},
{
name = "sy",
type = "number",
description = "The texture coordinate y scale."
},
{
name = "angle",
type = "number",
description = "The texture coordinate rotation, in radians."
}
},
returns = {}
}
}
}
},
constructors = {
"lovr.graphics.newMaterial"
}
},
{
name = "Mesh",
summary = "A drawable list of vertices.",
description = "A Mesh is a low-level graphics object that stores and renders a list of vertices.\n\nMeshes are really flexible since you can pack pretty much whatever you want in them. This makes them great for rendering arbitrary geometry, but it also makes them kinda difficult to use since you have to place each vertex yourself.\n\nIt's possible to batch geometry with Meshes too. Instead of drawing a shape 100 times, it's much faster to pack 100 copies of the shape into a Mesh and draw the Mesh once.\n\nMeshes are also a good choice if you have a mesh that changes its shape over time.",
key = "Mesh",
module = "lovr.graphics",
constructors = {
"lovr.graphics.newMesh"
},
notes = "Each vertex in a Mesh can hold several pieces of data. For example, you might want a vertex to keep track of its position, color, and a weight. Each one of these pieces of information is called a vertex **attribute**. A vertex attribute must have a name, a type, and a size. Here's what the \"position\" attribute would look like as a Lua table:\n\n { 'vPosition', 'float', 3 } -- 3 floats for x, y, and z\n\nEvery vertex in a Mesh must have the same set of attributes. We call this set of attributes the **format** of the Mesh, and it's specified as a simple table of attributes. For example, we could represent the format described above as:\n\n {\n { 'vPosition', 'float', 3 },\n { 'vColor', 'byte', 4 },\n { 'vWeight', 'int', 1 }\n }\n\nWhen creating a Mesh, you can give it any format you want, or use the default. The default Mesh format looks like this:\n\n {\n { 'lovrPosition', 'float', 3 },\n { 'lovrNormal', 'float', 3 },\n { 'lovrTexCoord', 'float', 2 }\n { 'lovrVertexColor', 'byte', 4 }\n }\n\nGreat, so why do we go through the trouble of naming everything in our vertex and saying what type and size it is? The cool part is that we can access this data in a Shader. We can write a vertex Shader that has `in` variables for every vertex attribute in our Mesh:\n\n in vec3 vPosition;\n in vec4 vColor;\n in int vWeight;\n\n vec4 position(mat4 projection, mat4 transform, vec4 vertex) {\n // Here we can access the vPosition, vColor, and vWeight of each vertex in the Mesh!\n }\n\nSpecifying custom vertex data is really powerful and is often used for lighting, animation, and more!",
methods = {
{
name = "attachAttributes",
summary = "Attach attributes from another Mesh onto this one.",
description = "Attaches attributes from another Mesh onto this one. This can be used to share vertex data across multiple meshes without duplicating the data, and can also be used for instanced rendering by using the `divisor` parameter.",
key = "Mesh:attachAttributes",
module = "lovr.graphics",
related = {
"Mesh:detachAttributes",
"Mesh:drawInstanced"
},
variants = {
{
description = "Attach all attributes from the other mesh.",
arguments = {
{
name = "mesh",
type = "Mesh",
description = "The Mesh to attach attributes from."
},
{
name = "divisor",
type = "number",
description = "The attribute divisor for all attached attributes.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "mesh",
type = "Mesh",
description = "The Mesh to attach attributes from."
},
{
name = "divisor",
type = "number",
description = "The attribute divisor for all attached attributes.",
default = "0"
},
{
name = "...",
type = "string",
description = "The names of attributes to attach from the other Mesh."
}
},
returns = {}
},
{
arguments = {
{
name = "mesh",
type = "Mesh",
description = "The Mesh to attach attributes from."
},
{
name = "divisor",
type = "number",
description = "The attribute divisor for all attached attributes.",
default = "0"
},
{
name = "attributes",
type = "table",
description = "A table of attribute names to attach from the other Mesh."
}
},
returns = {}
}
},
notes = "The attribute divisor is a number used to control how the attribute data relates to instancing. If 0, then the attribute data is considered \"per vertex\", and each vertex will get the next element of the attribute's data. If the divisor 1 or more, then the attribute data is considered \"per instance\", and every N instances will get the next element of the attribute data.\n\nTo prevent cycles, it is not possible to attach attributes onto a Mesh that already has attributes attached to a different Mesh."
},
{
name = "detachAttributes",
summary = "Detach attributes that were attached from a different Mesh.",
description = "Detaches attributes that were attached using `Mesh:attachAttributes`.",
key = "Mesh:detachAttributes",
module = "lovr.graphics",
related = {
"Mesh:attachAttributes"
},
variants = {
{
description = "Detaches all attributes from the other mesh, by name.",
arguments = {
{
name = "mesh",
type = "Mesh",
description = "A Mesh. The names of all of the attributes from this Mesh will be detached."
}
},
returns = {}
},
{
arguments = {
{
name = "mesh",
type = "Mesh",
description = "A Mesh. The names of all of the attributes from this Mesh will be detached."
},
{
name = "...",
type = "string",
description = "The names of attributes to detach."
}
},
returns = {}
},
{
arguments = {
{
name = "mesh",
type = "Mesh",
description = "A Mesh. The names of all of the attributes from this Mesh will be detached."
},
{
name = "attributes",
type = "table",
description = "A table of attribute names to detach."
}
},
returns = {}
}
}
},
{
name = "draw",
summary = "Draw the Mesh.",
description = "Draws the contents of the Mesh.",
key = "Mesh:draw",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x coordinate to draw the Mesh at.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate to draw the Mesh at.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate to draw the Mesh at.",
default = "0"
},
{
name = "scale",
type = "number",
description = "The scale to draw the Mesh at.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The angle to rotate the Mesh around its axis of rotation.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "transform",
type = "Transform",
description = "The transform to apply before drawing."
}
},
returns = {}
}
}
},
{
name = "drawInstanced",
summary = "Draw multiple copies of the Mesh in an optimized way.",
description = "Draw a Mesh multiple times. This is much faster than calling `Mesh:draw` more than once.",
key = "Mesh:drawInstanced",
module = "lovr.graphics",
notes = "By default, the Meshes will all be drawn on top of each other. To get the drawn copies to appear in different places, you can use the `gl_InstanceID` variable in a `Shader`. The first instance will pass 0 as the instance ID, the second instance will pass 1 as the instance ID, etc. You can use an array of mat4 variables and access the array using the supplied instance ID to specify a list of positions to draw the instances at, or use custom logic to position each instance.",
variants = {
{
arguments = {
{
name = "instances",
type = "number",
description = "The number of copies of the mesh to draw.",
default = "1"
},
{
name = "x",
type = "number",
description = "The x coordinate to draw the Mesh at.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate to draw the Mesh at.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate to draw the Mesh at.",
default = "0"
},
{
name = "scale",
type = "number",
description = "The scale to draw the Mesh at.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The angle to rotate the Mesh around its axis of rotation.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "instances",
type = "number",
description = "The number of copies of the mesh to draw.",
default = "1"
},
{
name = "transform",
type = "Transform",
description = "The transform to apply before drawing."
}
},
returns = {}
}
}
},
{
name = "getDrawMode",
summary = "Get the draw mode of the Mesh.",
description = "Get the draw mode of the Mesh, which controls how the vertices are connected together.",
key = "Mesh:getDrawMode",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "mode",
type = "MeshDrawMode",
description = "The draw mode of the Mesh."
}
}
}
}
},
{
name = "getDrawRange",
summary = "Get the draw range of the Mesh.",
description = "Retrieve the current draw range for the Mesh. The draw range is a subset of the vertices of the Mesh that will be drawn.",
key = "Mesh:getDrawRange",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "start",
type = "number",
description = "The index of the first vertex that will be drawn, or nil if no draw range is set."
},
{
name = "count",
type = "number",
description = "The number of vertices that will be drawn, or nil if no draw range is set."
}
}
}
}
},
{
name = "getMaterial",
summary = "Get the Material applied to the Mesh.",
description = "Get the Material applied to the Mesh.",
key = "Mesh:getMaterial",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "material",
type = "Material",
description = "The current material applied to the Mesh."
}
}
}
}
},
{
name = "getVertex",
summary = "Get a single vertex in the Mesh.",
description = "Gets the data for a single vertex in the Mesh. The set of data returned depends on the Mesh's vertex format. The default vertex format consists of 8 floating point numbers: the vertex position, the vertex normal, and the texture coordinates.",
key = "Mesh:getVertex",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to retrieve."
}
},
returns = {
{
name = "...",
type = "number",
description = "All attributes of the vertex."
}
}
}
}
},
{
name = "getVertexAttribute",
summary = "Get an attribute of a single vertex in the Mesh.",
description = "Get the components of a specific attribute of a single vertex in the Mesh.",
key = "Mesh:getVertexAttribute",
module = "lovr.graphics",
notes = "Meshes without a custom format have the vertex position as their first attribute, the normal vector as the second attribute, and the texture coordinate as the third attribute.",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to retrieve the attribute of."
},
{
name = "attribute",
type = "number",
description = "The index of the attribute to retrieve the components of."
}
},
returns = {
{
name = "...",
type = "number",
description = "The components of the vertex attribute."
}
}
}
}
},
{
name = "getVertexCount",
summary = "Get the number of vertices the Mesh can hold.",
description = "Returns the maximum number of vertices the Mesh can hold.",
key = "Mesh:getVertexCount",
module = "lovr.graphics",
notes = "The size can only be set when creating the Mesh, and cannot be changed afterwards.",
variants = {
{
arguments = {},
returns = {
{
name = "size",
type = "number",
description = "The number of vertices the Mesh can hold."
}
}
}
}
},
{
name = "getVertexFormat",
summary = "Get the vertex format of the Mesh.",
description = "Get the format table of the Mesh's vertices. The format table describes the set of data that each vertex contains.",
key = "Mesh:getVertexFormat",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "format",
type = "table",
description = "The table of vertex attributes. Each attribute is a table containing the name of the attribute, the data type, and the number of components."
}
}
}
}
},
{
name = "getVertexMap",
summary = "Get the current vertex map of the Mesh.",
description = "Returns the current vertex map for the Mesh. The vertex map is a list of indices in the Mesh, allowing the reordering or reuse of vertices.",
key = "Mesh:getVertexMap",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {}
},
{
arguments = {
{
name = "t",
type = "table",
description = "The table to fill with the vertex map."
}
},
returns = {}
},
{
arguments = {
{
name = "blob",
type = "Blob",
description = "The Blob to fill with the vertex map data."
}
},
returns = {}
}
}
},
{
name = "isAttributeEnabled",
summary = "Check if a vertex attribute is enabled.",
description = "Returns whether or not a vertex attribute is enabled. Disabled attributes won't be sent to shaders.",
key = "Mesh:isAttributeEnabled",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "attribute",
type = "string",
description = "The name of the attribute."
}
},
returns = {
{
name = "enabled",
type = "boolean",
description = "Whether or not the attribute is enabled when drawing the Mesh."
}
}
}
}
},
{
name = "setAttributeEnabled",
summary = "Enable or disable a vertex attribute.",
description = "Sets whether a vertex attribute is enabled. Disabled attributes won't be sent to shaders.",
key = "Mesh:setAttributeEnabled",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "attribute",
type = "string",
description = "The name of the attribute."
},
{
name = "enabled",
type = "boolean",
description = "Whether or not the attribute is enabled when drawing the Mesh."
}
},
returns = {}
}
}
},
{
name = "setDrawMode",
summary = "Change the draw mode of the Mesh.",
description = "Set a new draw mode for the Mesh.",
key = "Mesh:setDrawMode",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "mode",
type = "MeshDrawMode",
description = "The new draw mode for the Mesh."
}
},
returns = {}
}
}
},
{
name = "setDrawRange",
summary = "Set the draw range of the Mesh.",
description = "Set the draw range for the Mesh. The draw range is a subset of the vertices of the Mesh that will be drawn.",
key = "Mesh:setDrawRange",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "start",
type = "number",
description = "The first vertex that will be drawn."
},
{
name = "count",
type = "number",
description = "The number of vertices that will be drawn."
}
},
returns = {}
}
}
},
{
name = "setMaterial",
summary = "Apply a Material to the Mesh.",
description = "Applies a Material to the Mesh. This will cause it to use the Material's properties whenever it is rendered.",
key = "Mesh:setMaterial",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "material",
type = "Material",
description = "The Material to apply."
}
},
returns = {}
}
}
},
{
name = "setVertex",
summary = "Update a single vertex in the Mesh.",
description = "Update a single vertex in the Mesh.",
key = "Mesh:setVertex",
module = "lovr.graphics",
notes = "Any unspecified components will be set to 0 for float and int attributes, or 255 for byte attributes.",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to set."
},
{
name = "...",
type = "number",
description = "The attributes of the vertex."
}
},
returns = {}
},
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to set."
},
{
name = "vertexData",
type = "table",
description = "A table containing the attributes of the vertex."
}
},
returns = {}
}
},
examples = {
{
description = "Set the position of a vertex:",
code = "function lovr.load()\n mesh = lovr.graphics.newMesh({\n { -1, 1, 0, 0, 0, 1, 0, 0 },\n { 1, 1, 0, 0, 0, 1, 1, 0 },\n { -1, -1, 0, 0, 0, 1, 0, 1 },\n { 1, -1, 0, 0, 0, 1, 1, 1 }\n }, 'strip')\n\n mesh:setVertex(2, { 7, 7, 7 })\n print(mesh:getVertex(2)) -- 7, 7, 7, 0, 0, 0, 0, 0\nend"
}
}
},
{
name = "setVertexAttribute",
summary = "Update a specific attribute of a single vertex in the Mesh.",
description = "Set the components of a specific attribute of a vertex in the Mesh.",
key = "Mesh:setVertexAttribute",
module = "lovr.graphics",
notes = "Meshes without a custom format have the vertex position as their first attribute, the normal vector as the second attribute, and the texture coordinate as the third attribute.",
variants = {
{
arguments = {
{
name = "index",
type = "number",
description = "The index of the vertex to update."
},
{
name = "attribute",
type = "number",
description = "The index of the attribute to update."
},
{
name = "...",
type = "number",
description = "Thew new components for the attribute."
}
},
returns = {}
}
}
},
{
name = "setVertexMap",
summary = "Set the vertex map of the Mesh.",
description = "Sets the vertex map. The vertex map is a list of indices in the Mesh, allowing the reordering or reuse of vertices.\n\nOften, a vertex map is used to improve performance, since it usually requires less data to specify the index of a vertex than it does to specify all of the data for a vertex.",
key = "Mesh:setVertexMap",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "map",
type = "table",
description = "The new vertex map. Each element of the table is an index of a vertex."
}
},
returns = {}
},
{
description = "This variant is much faster than the previous one, but is harder to use.",
arguments = {
{
name = "blob",
type = "Blob",
description = "A Blob to use to update vertex data."
},
{
name = "size",
type = "number",
description = "The size of each element of the Blob, in bytes. Must be 2 or 4.",
default = "4"
}
},
returns = {}
}
}
},
{
name = "setVertices",
summary = "Update multiple vertices in the Mesh.",
description = "Update multiple vertices in the Mesh.",
key = "Mesh:setVertices",
module = "lovr.graphics",
notes = "The start index plus the number of vertices in the table should not exceed the maximum size of the Mesh.\n\nTo use a VertexData, the Mesh and the VertexData must have the same format.",
variants = {
{
arguments = {
{
name = "vertices",
type = "table",
description = "The new set of vertices."
},
{
name = "start",
type = "number",
description = "The index of the vertex to start replacing at.",
default = "1"
},
{
name = "count",
type = "number",
description = "The number of vertices to replace. If nil, all vertices in the table or VertexData will be used.",
default = "nil"
}
},
returns = {}
},
{
arguments = {
{
name = "vertexData",
type = "VertexData",
description = "The VertexData object to use the vertices from."
},
{
name = "start",
type = "number",
description = "The index of the vertex to start replacing at.",
default = "1"
},
{
name = "count",
type = "number",
description = "The number of vertices to replace. If nil, all vertices in the table or VertexData will be used.",
default = "nil"
}
},
returns = {}
}
}
}
},
examples = {
{
description = "Draw a circle using a Mesh.",
code = "function lovr.load()\n local x, y, z = 0, 1, -2\n local radius = .3\n local points = 40\n\n -- A table to hold the Mesh data\n local vertices = {}\n\n for i = 0, points do\n local angle = i / points * 2 * math.pi\n local vx = x + math.cos(angle)\n local vy = y + math.sin(angle)\n table.insert(vertices, { vx, vy, z })\n end\n\n mesh = lovr.graphics.newMesh(vertices, 'fan')\nend\n\nfunction lovr.draw()\n mesh:draw()\nend"
}
}
},
{
name = "Model",
summary = "An asset imported from a 3D model file.",
description = "A Model is a drawable object loaded from a 3D file format. The supported 3D file formats are `obj`, `fbx`, and `gltf`.",
key = "Model",
module = "lovr.graphics",
examples = {
{
code = "local model\n\nfunction lovr.load()\n model = lovr.graphics.newModel('assets/model.fbx', 'assets/texture.png')\nend\n\nfunction lovr.draw()\n model:draw(0, 1, -1, 1, lovr.timer.getTime())\nend"
}
},
constructors = {
"lovr.graphics.newModel",
"Controller:newModel"
},
methods = {
{
name = "draw",
summary = "Draw the Model.",
description = "Draw the Model.",
key = "Model:draw",
module = "lovr.graphics",
variants = {
{
arguments = {
{
name = "x",
type = "number",
description = "The x coordinate to draw the Model at.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate to draw the Model at.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate to draw the Model at.",
default = "0"
},
{
name = "scale",
type = "number",
description = "The scale to draw the Model at.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The angle to rotate the Model around its axis of rotation.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "transform",
type = "Transform",
description = "The transform to apply before drawing."
}
},
returns = {}
}
}
},
{
name = "drawInstanced",
summary = "Draw multiple copies of a Model in an optimized way.",
description = "Draws a model multiple times. This is much faster than drawing `Model:draw` more than once.",
key = "Model:drawInstanced",
module = "lovr.graphics",
notes = "By default, the Models will all be drawn on top of each other. To get the drawn copies to appear in different places, you can use the `gl_InstanceID` variable in a `Shader`. The first instance will pass 0 as the instance ID, the second instance will pass 1 as the instance ID, etc. You can use an array of mat4 variables and access the array using the supplied instance ID to specify a list of positions to draw the instances at.",
variants = {
{
arguments = {
{
name = "instances",
type = "number",
description = "The number of copies to draw.",
default = "1"
},
{
name = "x",
type = "number",
description = "The x coordinate to draw the Model at.",
default = "0"
},
{
name = "y",
type = "number",
description = "The y coordinate to draw the Model at.",
default = "0"
},
{
name = "z",
type = "number",
description = "The z coordinate to draw the Model at.",
default = "0"
},
{
name = "scale",
type = "number",
description = "The scale to draw the Model at.",
default = "1"
},
{
name = "angle",
type = "number",
description = "The angle to rotate the Model around its axis of rotation.",
default = "0"
},
{
name = "ax",
type = "number",
description = "The x component of the axis of rotation.",
default = "0"
},
{
name = "ay",
type = "number",
description = "The y component of the axis of rotation.",
default = "1"
},
{
name = "az",
type = "number",
description = "The z component of the axis of rotation.",
default = "0"
}
},
returns = {}
},
{
arguments = {
{
name = "instances",
type = "number",
description = "The number of copies to draw.",
default = "1"
},
{
name = "transform",
type = "Transform",
description = "The transform to apply before drawing."
}
},
returns = {}
}
}
},
{
name = "getAABB",
summary = "Get the Model's axis aligned bounding box.",
description = "Returns a bounding box that encloses the vertices of the Model.",
key = "Model:getAABB",
module = "lovr.graphics",
related = {
"Collider:getAABB"
},
variants = {
{
arguments = {},
returns = {
{
name = "minx",
type = "number",
description = "The minimum x coordinate of the box."
},
{
name = "maxx",
type = "number",
description = "The maximum x coordinate of the box."
},
{
name = "miny",
type = "number",
description = "The minimum y coordinate of the box."
},
{
name = "maxy",
type = "number",
description = "The maximum y coordinate of the box."
},
{
name = "minz",
type = "number",
description = "The minimum z coordinate of the box."
},
{
name = "maxz",
type = "number",
description = "The maximum z coordinate of the box."
}
}
}
},
notes = "Note that currently this function returns the bounding box for the default animation pose, so it won't update based on the current Animator pose."
},
{
name = "getAnimator",
summary = "Get the Animator attached to the Model.",
description = "Returns the `Animator` attached to the Model. When attached, the animator will alter the pose of the bones of the model based on the set of playing animations.",
key = "Model:getAnimator",
module = "lovr.graphics",
related = {
"lovr.graphics.newAnimator"
},
variants = {
{
arguments = {},
returns = {
{
name = "animator",
type = "Animator",
description = "The Animator attached to the Model, or `nil` if none is set."
}
}
}
}
},
{
name = "getMaterial",
summary = "Get the Material applied to the Model.",
description = "Returns the Material applied to the Model.",
key = "Model:getMaterial",
module = "lovr.graphics",
variants = {
{
arguments = {},
returns = {
{
name = "material",
type = "Material",
description = "The current material applied to the Model."
}
}
}
}
},
{
name = "getMesh",
summary = "Get the Model's underlying Mesh object.",
description = "Returns the underlying `Mesh` object for the Model.",
key = "Model:getMesh",
module = "lovr.graphics",
related = {
"Mesh"
},
variants = {
{
arguments = {},
returns = {
{
name = "mesh",
type = "Mesh",
description = "The Mesh object for the model, containing all of the raw vertex data."
}
}
}
}
},
{
name = "setAnimator",
summary = "Attach an Animator to the Model.",
description = "Attaches an `Animator` to the Model. When attached, the animator will alter the pose of the bones of the model based on the set of playing animations.",
key = "Model:setAnimator",
module = "lovr.graphics",
related = {
"lovr.graphics.newAnimator"
},
variants = {
{
arguments = {
{
name = "animator",
type = "Animator",
description = "The Animator to attach."
}
},
returns = {}
}
}
},
{
name = "setMaterial",
summary = "Apply a Material to the Model.",
description = "Applies a Material to the Model.",
key = "Model:setMaterial",
module = "lovr.graphics",
notes = "A model's Material will be used when drawing every part of the model. It will override any materials included in the model file. It isn't currently possible to apply multiple materials to different pieces of the Model.",
variants = {
{
arguments = {
{
name = "material",
type = "Material",
description = "The material to apply to the Model."
}
},
returns = {}
}
}
}
}
},
{
name = "Shader",
summary = "A GLSL program used for low-level control over rendering.",
description = "Shaders are GLSL programs that transform the way vertices and pixels show up on the screen. They can be used for lighting, postprocessing, particles, animation, and much more. You can use `lovr.graphics.setShader` to change the active Shader.",
key = "Shader",
module = "lovr.graphics",
examples = {
{
description = "Set a simple shader that colors pixels based on vertex normals.",
code = "function lovr.load()\n lovr.graphics.setShader(lovr.graphics.newShader([[\n out vec3 vNormal; // This gets passed to the fragment shader\n\n vec4 position(mat4 projection, mat4 transform, vec4 vertex) {\n vNormal = lovrNormal;\n return projection * transform * vertex;\n }\n ]], [[\n in vec3 vNormal; // This gets passed from the vertex shader\n\n vec4 color(vec4 graphicsColor, sampler2D image, vec2 uv) {\n return vec4(vNormal * .5 + .5, 1.0);\n }\n ]]))\n\n model = lovr.graphics.newModel('model.fbx')\nend\n\nfunction lovr.draw()\n model:draw(x, y, z, 1)\nend"
}
},
related = {
"lovr.graphics.newComputeShader",
"lovr.graphics.setShader",
"lovr.graphics.getShader"
},
constructors = {
"lovr.graphics.newShader",
"lovr.graphics.newComputeShader"
},
methods = {
{
name = "getType",
summary = "Get the type of the Shader.",
description = "Returns the type of the Shader, which will be \"graphics\" or \"compute\".\n\nGraphics shaders are created with `lovr.graphics.newShader` and can be used for rendering with `lovr.graphics.setShader`. Compute shaders are created with `lovr.graphics.newComputeShader` and can be run using `lovr.graphics.compute`.",
key = "Shader:getType",
module = "lovr.graphics",
related = {
"ShaderType"
},
variants = {
{
arguments = {},
returns = {
{
name = "type",
type = "ShaderType",
description = "The type of the Shader."
}
}
}
}
},
{
name = "hasUniform",
summary = "Check if a Shader has a uniform variable.",
description = "Returns whether a Shader has a particular uniform variable.",
key = "Shader:hasUniform",
module = "lovr.graphics",
notes = "If a uniform variable is defined but unused in the shader, the shader compiler will optimize it out and the uniform will not report itself as present.",
variants = {
{
arguments = {
{
name = "uniform",
type = "string",
description = "The name of the uniform variable."
}
},
returns = {
{
name = "present",
type = "boolean",
description = "Whether the shader has the specified uniform."
}
}
}
}
},
{
name = "send",
summary = "Update a uniform variable in the Shader.",
description = "Updates a uniform variable in the Shader.",
key = "Shader:send",
module = "lovr.graphics",
related = {
"ShaderBlock:sendBlock",
"Shader:sendBlock"
},
notes = "The shader does not need to be active to update its uniforms. However, the types must match up. Uniform variables declared as `float`s must be sent a single number, whereas uniforms declared as `vec4`s must be sent a table containing 4 numbers, etc. Note that uniforms declared as mat4s can be sent a `Transform` object.\n\nAn error is thrown if the uniform does not exist or is not used in the shader.\n\n`Blob`s can be used to pass arbitrary binary data to Shader variables.",
variants = {
{
arguments = {
{
name = "uniform",
type = "string",
description = "The name of the uniform to update."
},
{
name = "value",
type = "*",
description = "The new value of the uniform."
}
},
returns = {}
}
},
examples = {
{
description = "Updating a `vec3` uniform:",
code = "function lovr.load()\n shader = lovr.graphics.newShader [[\n uniform vec3 offset;\n vec4 position(mat4 projection, mat4 transform, vec4 vertex) {\n vertex.xyz += offset;\n return projection * transform * vertex;\n }\n ]]\n\n shader:send('offset', { .3, .7, 0 })\nend"
}
}
},
{
name = "sendBlock",
summary = "Send a ShaderBlock to a Shader.",
description = "Sends a ShaderBlock to a Shader. After the block is sent, you can update the data in the block without needing to resend the block. The block can be sent to multiple shaders and they will all see the same data from the block.",
key = "Shader:sendBlock",
module = "lovr.graphics",
related = {
"Shader:send",
"ShaderBlock:send",
"ShaderBlock:getShaderCode",
"UniformAccess",
"ShaderBlock"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the block to send to."
},
{
name = "block",
type = "ShaderBlock",
description = "The ShaderBlock to associate with the specified block."
},
{
name = "access",
type = "UniformAccess",
description = "How the Shader will use this block (used as an optimization hint).",
default = "readwrite"
}
},
returns = {}
}
},
notes = "The Shader does not need to be active to send it a block.\n\nMake sure the ShaderBlock's variables line up with the block variables declared in the shader code, otherwise you'll get garbage data in the block. An easy way to do this is to use `ShaderBlock:getShaderCode` to get a GLSL snippet that is compatible with the block."
},
{
name = "sendImage",
summary = "Send a Texture to a Shader for writing.",
description = "Sends a Texture to a Shader for writing. This is meant to be used with compute shaders and only works with uniforms declared as `image2D`, `imageCube`, `image2DArray`, and `image3D`. The normal `Shader:send` function accepts Textures and should be used most of the time.",
key = "Shader:sendImage",
module = "lovr.graphics",
related = {
"Shader:send",
"ShaderBlock:send",
"ShaderBlock:getShaderCode",
"UniformAccess",
"ShaderBlock"
},
variants = {
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the image uniform."
},
{
name = "slice",
type = "number",
description = "The slice of a cube, array, or volume texture to use, or `nil` for all slices.",
default = "nil"
},
{
name = "mipmap",
type = "number",
description = "The mipmap of the texture to use.",
default = "1"
},
{
name = "access",
type = "UniformAccess",
description = "Whether the image will be read from, written to, or both.",
default = "readwrite"
}
},
returns = {}
},
{
arguments = {
{
name = "name",
type = "string",
description = "The name of the image uniform."
},
{
name = "index",
type = "number",
description = "The array index to set."
},
{
name = "slice",
type = "number",
description = "The slice of a cube, array, or volume texture to use, or `nil` for all slices.",
default = "nil"
},
{
name = "mipmap",
type = "number",
description = "The mipmap of the texture to use.",
default = "1"
},
{
name = "access",
type = "UniformAccess",
description = "Whether the image will be read from, written to, or both.",
default = "readwrite"
}
},
returns = {}
}
}
}
},
notes = "The GLSL version used is 430 on systems that support compute shaders and 150 otherwise. The version used for WebGL is 300 es.\n\nThe default vertex shader:\n\n vec4 position(mat4 projection, mat4 transform, vec4 vertex) {\n return projection * transform * vertex;\n }\n\nThe default fragment shader:\n\n vec4 color(vec4 graphicsColor, sampler2D image, vec2 uv) {\n return graphicsColor * lovrDiffuseColor * vertexColor * texture(image, uv);\n }\n\nAdditionally, the following headers are prepended to the shader source, giving you convenient access to a default set of uniform variables and vertex attributes.\n\nVertex shader header:\n\n in vec3 lovrPosition;\n in vec3 lovrNormal;\n in vec2 lovrTexCoord;\n in vec4 lovrVertexColor;\n in vec3 lovrTangent;\n in ivec4 lovrBones;\n in vec4 lovrBoneWeights;\n out vec2 texCoord;\n out vec4 vertexColor;\n uniform mat4 lovrModel;\n uniform mat4 lovrView;\n uniform mat4 lovrProjection;\n uniform mat4 lovrTransform; // Model-View matrix\n uniform mat4 lovrNormalMatrix;\n uniform float lovrPointSize;\n uniform mat4 lovrPose[48];\n uniform int lovrViewportCount;\n uniform int lovrViewportIndex;\n const mat4 lovrPoseMatrix; // Bone-weighted pose\n const int lovrInstanceID; // Current instance ID\n\nFragment shader header:\n\n in vec2 texCoord;\n in vec4 vertexColor;\n in vec4 gl_FragCoord;\n out vec4 lovrFragColor;\n uniform float lovrMetalness;\n uniform float lovrRoughness;\n uniform vec4 lovrColor;\n uniform vec4 lovrDiffuseColor;\n uniform vec4 lovrEmissiveColor;\n uniform sampler2D lovrDiffuseTexture;\n uniform sampler2D lovrEmissiveTexture;\n uniform sampler2D lovrMetalnessTexture;\n uniform sampler2D lovrRoughnessTexture;\n uniform sampler2D lovrOcclusionTexture;\n uniform sampler2D lovrNormalTexture;\n uniform samplerCube lovrEnvironmentTexture;\n uniform int lovrViewportCount;\n uniform int lovrViewportIndex;\n\n### Compute Shaders\n\nCompute shaders can be created with `lovr.graphics.newComputeShader` and run with `lovr.graphics.compute`. Currently, compute shaders are written with raw GLSL. There is no default compute shader, instead the `void compute();` function must be implemented.\n\nYou can use the `layout` qualifier to specify a local work group size:\n\n layout(local_size_x = X, local_size_y = Y, local_size_z = Z) in;\n\nAnd the following built in variables can be used:\n\n in uvec3 gl_NumWorkGroups; // The size passed to lovr.graphics.compute\n in uvec3 gl_WorkGroupSize; // The local work group size\n in uvec3 gl_WorkGroupID; // The current global work group\n in uvec3 gl_LocalInvocationID; // The current local work group\n in uvec3 gl_GlobalInvocationID; // A unique ID combining the global and local IDs\n in uint gl_LocalInvocationIndex; // A 1D index of the LocalInvocationID\n\nCompute shaders don't return anything but they can write data to `Texture`s or `ShaderBlock`s. To bind a texture in a way that can be written to a compute shader, declare the uniforms with a type of `image2D`, `imageCube`, etc. instead of the usual `sampler2D` or `samplerCube`. Once a texture is bound to an image uniform, you can use the `imageLoad` and `imageStore` GLSL functions to read and write pixels in the image. Variables in `ShaderBlock`s can be written to using assignment syntax.\n\nLÖVR handles synchronization of textures and shader blocks so there is no need to use manual memory barriers to synchronize writes to resources from compute shaders."
},
{
name = "ShaderBlock",
summary = "A big ol' block of data that can be sent to a Shader.",
description = "ShaderBlocks are objects that can hold large amounts of data and can be sent to Shaders. It is common to use \"uniform\" variables to send data to shaders, but uniforms are usually limited to a few kilobytes in size. ShaderBlocks are useful for a few reasons:\n\n- They can hold a lot more data.\n- Shaders can modify the data in them, which is really useful for compute shaders.\n- Setting the data in a ShaderBlock updates the data for all Shaders using the block, so you\n don't need to go around setting the same uniforms in lots of different shaders.\n\nOn systems that support compute shaders, ShaderBlocks can optionally be \"writable\". A writable ShaderBlock is a little bit slower than a non-writable one, but shaders can modify its contents and it can be much, much larger than a non-writable ShaderBlock.",
key = "ShaderBlock",
module = "lovr.graphics",
constructors = {
"lovr.graphics.newShaderBlock"
},
notes = "- A Shader can use up to 8 ShaderBlocks.\n- ShaderBlocks can not contain textures.\n- Some systems have bugs with `vec3` variables in ShaderBlocks. If you run into strange bugs,\n try switching to a `vec4` for the variable.",
methods = {
{
name = "getOffset",
summary = "Get the byte offset of a variable in the ShaderBlock.",
description = "Returns the byte offset of a variable in a ShaderBlock. This is useful if you want to manually send binary data to the ShaderBlock using a `Blob` in `ShaderBlock:send`.",
key = "ShaderBlock:getOffset",
module = "lovr.graphics",
related = {
"ShaderBlock:getSize",
"lovr.graphics.newShaderBlock"
},
variants = {
{
arguments = {
{
name = "field",
type = "string",
description = "The name of the variable to get the offset of."
}
},
returns = {
{
name = "offset",
type = "number",
description = "The byte offset of the variable."
}
}
}
}
},
{
name = "getShaderCode",
summary = "Get a GLSL string that defines the ShaderBlock in a Shader.",
description = "Before a ShaderBlock can be used in a Shader, the Shader has to have the block's variables defined in its source code. This can be a tedious process, so you can call this function to return a GLSL string that contains this definition. Roughly, it will look something like this:\n\n uniform