From dda6b1860cf9e2efbc6b06bad4a6174481c7e5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 1 Nov 2021 21:00:14 +0800 Subject: update lovr --- meta/3rd/lovr/library/lovr.audio.lua | 207 ++++++ meta/3rd/lovr/library/lovr.data.lua | 295 ++++++++ meta/3rd/lovr/library/lovr.graphics.lua | 750 ++++++++++++++++++++ meta/3rd/lovr/library/lovr.lua | 13 + meta/3rd/lovr/library/lovr.math.lua | 644 +++++++++++++++++ meta/3rd/lovr/library/lovr.physics.lua | 1142 +++++++++++++++++++++++++++++++ meta/3rd/lovr/library/lovr.thread.lua | 72 ++ 7 files changed, 3123 insertions(+) (limited to 'meta/3rd/lovr') diff --git a/meta/3rd/lovr/library/lovr.audio.lua b/meta/3rd/lovr/library/lovr.audio.lua index 269e5726..d8b1bd9d 100644 --- a/meta/3rd/lovr/library/lovr.audio.lua +++ b/meta/3rd/lovr/library/lovr.audio.lua @@ -175,6 +175,213 @@ function lovr.audio.start(type) end ---@return boolean stopped # Whether the device was successfully stopped. function lovr.audio.stop(type) end +--- +---A Source is an object representing a single sound. Currently ogg, wav, and mp3 formats are supported. +--- +---When a Source is playing, it will send audio to the speakers. Sources do not play automatically when they are created. Instead, the `play`, `pause`, and `stop` functions can be used to control when they should play. +--- +---`Source:seek` and `Source:tell` can be used to control the playback position of the Source. A Source can be set to loop when it reaches the end using `Source:setLooping`. +--- +---@class lovr.Source +local Source = {} + +--- +---Creates a copy of the Source, referencing the same `Sound` object and inheriting all of the settings of this Source. However, it will be created in the stopped state and will be rewound to the beginning. +--- +---@return lovr.Source source # A genetically identical copy of the Source. +function Source:clone() end + +--- +---Returns the directivity settings for the Source. +--- +---The directivity is controlled by two parameters: the weight and the power. +--- +---The weight is a number between 0 and 1 controlling the general "shape" of the sound emitted. 0.0 results in a completely omnidirectional sound that can be heard from all directions. 1.0 results in a full dipole shape that can be heard only from the front and back. 0.5 results in a cardioid shape that can only be heard from one direction. Numbers in between will smoothly transition between these. +--- +---The power is a number that controls how "focused" or sharp the shape is. Lower power values can be heard from a wider set of angles. It is an exponent, so it can get arbitrarily large. Note that a power of zero will still result in an omnidirectional source, regardless of the weight. +--- +---@return number weight # The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid. +---@return number power # The dipole power, controlling how focused the directivity shape is. +function Source:getDirectivity() end + +--- +---Returns the duration of the Source. +--- +---@param unit? lovr.TimeUnit # The unit to return. +---@return number duration # The duration of the Source. +function Source:getDuration(unit) end + +--- +---Returns the orientation of the Source, in angle/axis representation. +--- +---@return number angle # The number of radians the Source is rotated around its axis of rotation. +---@return number ax # The x component of the axis of rotation. +---@return number ay # The y component of the axis of rotation. +---@return number az # The z component of the axis of rotation. +function Source:getOrientation() end + +--- +---Returns the position and orientation of the Source. +--- +---@return number x # The x position of the Source, in meters. +---@return number y # The y position of the Source, in meters. +---@return number z # The z position of the Source, in meters. +---@return number angle # The number of radians the Source is rotated around its axis of rotation. +---@return number ax # The x component of the axis of rotation. +---@return number ay # The y component of the axis of rotation. +---@return number az # The z component of the axis of rotation. +function Source:getPose() end + +--- +---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. +--- +---@return number x # The x coordinate. +---@return number y # The y coordinate. +---@return number z # The z coordinate. +function Source:getPosition() end + +--- +---Returns the radius of the Source, in meters. +--- +---This does not control falloff or attenuation. It is only used for smoothing out occlusion. If a Source doesn't have a radius, then when it becomes occluded by a wall its volume will instantly drop. Giving the Source a radius that approximates its emitter's size will result in a smooth transition between audible and occluded, improving realism. +--- +---@return number radius # The radius of the Source, in meters. +function Source:getRadius() end + +--- +---Returns the `Sound` object backing the Source. Multiple Sources can share one Sound, allowing its data to only be loaded once. An easy way to do this sharing is by using `Source:clone`. +--- +---@return lovr.Sound sound # The Sound object. +function Source:getSound() end + +--- +---Returns the current volume factor for the Source. +--- +---@param units? lovr.VolumeUnit # The units to return (linear or db). +---@return number volume # The volume of the Source. +function Source:getVolume(units) end + +--- +---Returns whether a given `Effect` is enabled for the Source. +--- +---@param effect lovr.Effect # The effect. +---@return boolean enabled # Whether the effect is enabled. +function Source:isEffectEnabled(effect) end + +--- +---Returns whether or not the Source will loop when it finishes. +--- +---@return boolean looping # Whether or not the Source is looping. +function Source:isLooping() end + +--- +---Returns whether or not the Source is playing. +--- +---@return boolean playing # Whether the Source is playing. +function Source:isPlaying() end + +--- +---Pauses the source. It can be resumed with `Source:resume` or `Source:play`. If a paused source is rewound, it will remain paused. +--- +function Source:pause() end + +--- +---Plays the Source. This doesn't do anything if the Source is already playing. +--- +---@return boolean success # Whether the Source successfully started playing. +function Source:play() end + +--- +---Seeks the Source to the specified position. +--- +---@param position number # The position to seek to. +---@param unit? lovr.TimeUnit # The units for the seek position. +function Source:seek(position, unit) end + +--- +---Sets the directivity settings for the Source. +--- +---The directivity is controlled by two parameters: the weight and the power. +--- +---The weight is a number between 0 and 1 controlling the general "shape" of the sound emitted. 0.0 results in a completely omnidirectional sound that can be heard from all directions. 1.0 results in a full dipole shape that can be heard only from the front and back. 0.5 results in a cardioid shape that can only be heard from one direction. Numbers in between will smoothly transition between these. +--- +---The power is a number that controls how "focused" or sharp the shape is. Lower power values can be heard from a wider set of angles. It is an exponent, so it can get arbitrarily large. Note that a power of zero will still result in an omnidirectional source, regardless of the weight. +--- +---@param weight number # The dipole weight. 0.0 is omnidirectional, 1.0 is a dipole, 0.5 is cardioid. +---@param power number # The dipole power, controlling how focused the directivity shape is. +function Source:setDirectivity(weight, power) end + +--- +---Enables or disables an effect on the Source. +--- +---@param effect lovr.Effect # The effect. +---@param enable boolean # Whether the effect should be enabled. +function Source:setEffectEnabled(effect, enable) end + +--- +---Sets whether or not the Source loops. +--- +---@param loop boolean # Whether or not the Source will loop. +function Source:setLooping(loop) end + +--- +---Sets the orientation of the Source in angle/axis representation. +--- +---@param angle number # The number of radians the Source should be rotated around its rotation axis. +---@param ax number # The x component of the axis of rotation. +---@param ay number # The y component of the axis of rotation. +---@param az number # The z component of the axis of rotation. +function Source:setOrientation(angle, ax, ay, az) end + +--- +---Sets the position and orientation of the Source. +--- +---@param x number # The x position of the Source, in meters. +---@param y number # The y position of the Source, in meters. +---@param z number # The z position of the Source, in meters. +---@param angle number # The number of radians the Source is rotated around its axis of rotation. +---@param ax number # The x component of the axis of rotation. +---@param ay number # The y component of the axis of rotation. +---@param az number # The z component of the axis of rotation. +function Source:setPose(x, y, z, angle, ax, ay, az) end + +--- +---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. +--- +---Only mono sources can be positioned. Setting the position of a stereo Source will cause an error. +--- +---@param x number # The x coordinate. +---@param y number # The y coordinate. +---@param z number # The z coordinate. +function Source:setPosition(x, y, z) end + +--- +---Sets the radius of the Source, in meters. +--- +---This does not control falloff or attenuation. It is only used for smoothing out occlusion. If a Source doesn't have a radius, then when it becomes occluded by a wall its volume will instantly drop. Giving the Source a radius that approximates its emitter's size will result in a smooth transition between audible and occluded, improving realism. +--- +---@param radius number # The new radius of the Source, in meters. +function Source:setRadius(radius) end + +--- +---Sets the current volume factor for the Source. +--- +---@param volume number # The new volume. +---@param units? lovr.VolumeUnit # The units of the value. +function Source:setVolume(volume, units) end + +--- +---Stops the source, also rewinding it to the beginning. +--- +function Source:stop() end + +--- +---Returns the current playback position of the Source. +--- +---@param unit? lovr.TimeUnit # The unit to return. +---@return number position # The current playback position. +function Source:tell(unit) end + --- ---Different types of audio material presets, for use with `lovr.audio.setGeometry`. --- diff --git a/meta/3rd/lovr/library/lovr.data.lua b/meta/3rd/lovr/library/lovr.data.lua index a3e75bea..e4ccdbf0 100644 --- a/meta/3rd/lovr/library/lovr.data.lua +++ b/meta/3rd/lovr/library/lovr.data.lua @@ -61,6 +61,301 @@ function lovr.data.newRasterizer(size) end ---@return lovr.Sound sound # Sounds good. function lovr.data.newSound(frames, format, channels, sampleRate, contents) end +--- +---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: +--- +---- You need to work with low level binary data, potentially using the LuaJIT FFI for increased +--- performance. +---- You are working with data that isn't stored as a file, such as programmatically generated data +--- or a string from a network request. +---- You want to load data from a file once and then use it to create many different objects. +--- +---A Blob's size cannot be changed once it is created. +--- +---@class lovr.Blob +local Blob = {} + +--- +---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. +--- +---@return string name # The name of the Blob. +function Blob:getName() end + +--- +---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! +--- +---@return userdata pointer # A pointer to the data. +function Blob:getPointer() end + +--- +---Returns the size of the Blob's contents, in bytes. +--- +---@return number bytes # The size of the Blob, in bytes. +function Blob:getSize() end + +--- +---Returns a binary string containing the Blob's data. +--- +---@return string data # The Blob's data. +function Blob:getString() end + +--- +---An Image stores raw 2D pixel info for `Texture`s. It has a width, height, and format. The Image 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`, `dds`, `ktx`, and `astc`. +--- +---Usually you can just use Textures, but Image can be useful if you want to manipulate individual pixels, load Textures in a background thread, or use the FFI to efficiently access the raw image data. +--- +---@class lovr.Image +local Image = {} + +--- +---Encodes the Image to an uncompressed png. This intended mainly for debugging. +--- +---@return lovr.Blob blob # A new Blob containing the PNG image data. +function Image:encode() end + +--- +---Returns a Blob containing the raw bytes of the Image. +--- +---@return lovr.Blob blob # The Blob instance containing the bytes for the `Image`. +function Image:getBlob() end + +--- +---Returns the dimensions of the Image, in pixels. +--- +---@return number width # The width of the Image, in pixels. +---@return number height # The height of the Image, in pixels. +function Image:getDimensions() end + +--- +---Returns the format of the Image. +--- +---@return lovr.TextureFormat format # The format of the pixels in the Image. +function Image:getFormat() end + +--- +---Returns the height of the Image, in pixels. +--- +---@return number height # The height of the Image, in pixels. +function Image:getHeight() end + +--- +---Returns the value of a pixel of the Image. +--- +---@param x number # The x coordinate of the pixel to get (0-indexed). +---@param y number # The y coordinate of the pixel to get (0-indexed). +---@return number r # The red component of the pixel, from 0.0 to 1.0. +---@return number g # The green component of the pixel, from 0.0 to 1.0. +---@return number b # The blue component of the pixel, from 0.0 to 1.0. +---@return number a # The alpha component of the pixel, from 0.0 to 1.0. +function Image:getPixel(x, y) end + +--- +---Returns the width of the Image, in pixels. +--- +---@return number width # The width of the Image, in pixels. +function Image:getWidth() end + +--- +---Copies a rectangle of pixels from one Image to this one. +--- +---@param source lovr.Image # The Image to copy pixels from. +---@param x? number # The x coordinate to paste to (0-indexed). +---@param y? number # The y coordinate to paste to (0-indexed). +---@param fromX? number # The x coordinate in the source to paste from (0-indexed). +---@param fromY? number # The y coordinate in the source to paste from (0-indexed). +---@param width? number # The width of the region to copy. +---@param height? number # The height of the region to copy. +function Image:paste(source, x, y, fromX, fromY, width, height) end + +--- +---Sets the value of a pixel of the Image. +--- +---@param x number # The x coordinate of the pixel to set (0-indexed). +---@param y number # The y coordinate of the pixel to set (0-indexed). +---@param r number # The red component of the pixel, from 0.0 to 1.0. +---@param g number # The green component of the pixel, from 0.0 to 1.0. +---@param b number # The blue component of the pixel, from 0.0 to 1.0. +---@param a? number # The alpha component of the pixel, from 0.0 to 1.0. +function Image:setPixel(x, y, r, g, b, a) end + +--- +---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 vertex data it contains, contains, the `Image` and `Material` properties, and any included animations. +--- +---The current supported formats are OBJ, glTF, and STL. +--- +---Usually 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. +--- +---@class lovr.ModelData +local ModelData = {} + +--- +---A Rasterizer is an object that parses a TTF file, decoding and rendering glyphs from it. +--- +---Usually you can just use `Font` objects. +--- +---@class lovr.Rasterizer +local Rasterizer = {} + +--- +---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. +--- +---@return number advance # The advance of the font, in pixels. +function Rasterizer:getAdvance() end + +--- +---Returns the ascent metric of the font, in pixels. The ascent represents how far any glyph of the font ascends above the baseline. +--- +---@return number ascent # The ascent of the font, in pixels. +function Rasterizer:getAscent() end + +--- +---Returns the descent metric of the font, in pixels. The descent represents how far any glyph of the font descends below the baseline. +--- +---@return number descent # The descent of the font, in pixels. +function Rasterizer:getDescent() end + +--- +---Returns the number of glyphs stored in the font file. +--- +---@return number count # The number of glyphs stored in the font file. +function Rasterizer:getGlyphCount() end + +--- +---Returns the height metric of the font, in pixels. +--- +---@return number height # The height of the font, in pixels. +function Rasterizer:getHeight() end + +--- +---Returns the line height metric of the font, in pixels. This is how far apart lines are. +--- +---@return number height # The line height of the font, in pixels. +function Rasterizer:getLineHeight() end + +--- +---Check if the Rasterizer can rasterize a set of glyphs. +--- +---@return boolean hasGlyphs # true if the Rasterizer can rasterize all of the supplied characters, false otherwise. +function Rasterizer:hasGlyphs() end + +--- +---A Sound stores the data for a sound. The supported sound formats are OGG, WAV, and MP3. Sounds cannot be played directly. Instead, there are `Source` objects in `lovr.audio` that are used for audio playback. All Source objects are backed by one of these Sounds, and multiple Sources can share a single Sound to reduce memory usage. +--- +---Metadata +------ +--- +---Sounds hold a fixed number of frames. Each frame contains one audio sample for each channel. The `SampleFormat` of the Sound is the data type used for each sample (floating point, integer, etc.). The Sound has a `ChannelLayout`, representing the number of audio channels and how they map to speakers (mono, stereo, etc.). The sample rate of the Sound indicates how many frames should be played per second. The duration of the sound (in seconds) is the number of frames divided by the sample rate. +--- +---Compression +------ +--- +---Sounds can be compressed. Compressed sounds are stored compressed in memory and are decoded as they are played. This uses a lot less memory but increases CPU usage during playback. OGG and MP3 are compressed audio formats. When creating a sound from a compressed format, there is an option to immediately decode it, storing it uncompressed in memory. It can be a good idea to decode short sound effects, since they won't use very much memory even when uncompressed and it will improve CPU usage. Compressed sounds can not be written to using `Sound:setFrames`. +--- +---Streams +------ +--- +---Sounds can be created as a stream by passing `'stream'` as their contents when creating them. Audio frames can be written to the end of the stream, and read from the beginning. This works well for situations where data is being generated in real time or streamed in from some other data source. +--- +---Sources can be backed by a stream and they'll just play whatever audio is pushed to the stream. The audio module also lets you use a stream as a "sink" for an audio device. For playback devices, this works like loopback, so the mixed audio from all playing Sources will get written to the stream. For capture devices, all the microphone input will get written to the stream. Conversion between sample formats, channel layouts, and sample rates will happen automatically. +--- +---Keep in mind that streams can still only hold a fixed number of frames. If too much data is written before it is read, older frames will start to get overwritten. Similary, it's possible to read too much data without writing fast enough. +--- +---Ambisonics +------ +--- +---Ambisonic sounds can be imported from WAVs, but can not yet be played. Sounds with a `ChannelLayout` of `ambisonic` are stored as first-order full-sphere ambisonics using the AmbiX format (ACN channel ordering and SN3D channel normalization). The AMB format is supported for import and will automatically get converted to AmbiX. See `lovr.data.newSound` for more info. +--- +---@class lovr.Sound +local Sound = {} + +--- +---Returns a Blob containing the raw bytes of the Sound. +--- +---@return lovr.Blob blob # The Blob instance containing the bytes for the `Sound`. +function Sound:getBlob() end + +--- +---Returns the number of channels in the Sound. Mono sounds have 1 channel, stereo sounds have 2 channels, and ambisonic sounds have 4 channels. +--- +---@return number channels # The number of channels in the sound. +function Sound:getChannelCount() end + +--- +---Returns the channel layout of the Sound. +--- +---@return lovr.ChannelLayout channels # The channel layout. +function Sound:getChannelLayout() end + +--- +---Returns the duration of the Sound, in seconds. +--- +---@return number duration # The duration of the Sound, in seconds. +function Sound:getDuration() end + +--- +---Returns the sample format of the Sound. +--- +---@return lovr.SampleFormat format # The data type of each sample. +function Sound:getFormat() end + +--- +---Returns the number of frames in the Sound. A frame stores one sample for each channel. +--- +---@return number frames # The number of frames in the Sound. +function Sound:getFrameCount() end + +--- +---Reads frames from the Sound into a table, Blob, or another Sound. +--- +---@overload fun(t: table, count: number, srcOffset: number, dstOffset: number):table, number +---@overload fun(blob: lovr.Blob, count: number, srcOffset: number, dstOffset: number):number +---@overload fun(sound: lovr.Sound, count: number, srcOffset: number, dstOffset: number):number +---@param count? number # The number of frames to read. If nil, reads as many frames as possible. + +Compressed sounds will automatically be decoded. + +Reading from a stream will ignore the source offset and read the oldest frames. +---@param srcOffset? number # A frame offset to apply to the sound when reading frames. +---@return table t # A table containing audio frames. +---@return number count # The number of frames read. +function Sound:getFrames(count, srcOffset) end + +--- +---Returns the total number of samples in the Sound. +--- +---@return number samples # The total number of samples in the Sound. +function Sound:getSampleCount() end + +--- +---Returns the sample rate of the Sound, in Hz. This is the number of frames that are played every second. It's usually a high number like 48000. +--- +---@return number frequency # The number of frames per second in the Sound. +function Sound:getSampleRate() end + +--- +---Returns whether the Sound is compressed. Compressed sounds are loaded from compressed audio formats like MP3 and OGG. They use a lot less memory but require some extra CPU work during playback. Compressed sounds can not be modified using `Sound:setFrames`. +--- +---@return boolean compressed # Whether the Sound is compressed. +function Sound:isCompressed() end + +--- +---Returns whether the Sound is a stream. +--- +---@return boolean stream # Whether the Sound is a stream. +function Sound:isStream() end + +--- +---Writes frames to the Sound. +--- +---@overload fun(blob: lovr.Blob, count: number, dstOffset: number, srcOffset: number):number +---@overload fun(sound: lovr.Sound, count: number, dstOffset: number, srcOffset: number):number +---@param t table # A table containing frames to write. +---@param count? number # How many frames to write. If nil, writes as many as possible. +---@param dstOffset? number # A frame offset to apply when writing the frames. +---@param srcOffset? number # A frame, byte, or index offset to apply when reading frames from the source. +---@return number count # The number of frames written. +function Sound:setFrames(t, count, dstOffset, srcOffset) end + --- ---Sounds can have different numbers of channels, and those channels can map to various speaker layouts. --- diff --git a/meta/3rd/lovr/library/lovr.graphics.lua b/meta/3rd/lovr/library/lovr.graphics.lua index 930c01f5..34aa2876 100644 --- a/meta/3rd/lovr/library/lovr.graphics.lua +++ b/meta/3rd/lovr/library/lovr.graphics.lua @@ -755,6 +755,756 @@ function lovr.graphics.transform(x, y, z, sx, sy, sz, angle, ax, ay, az) end ---@param z? number # The amount to translate on the z axis. function lovr.graphics.translate(x, y, z) end +--- +---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. +--- +---After creating a Canvas, you can attach Textures to it using `Canvas:setTexture`. +--- +---@class lovr.Canvas +local Canvas = {} + +--- +---Returns the depth buffer used by the Canvas as a Texture. If the Canvas was not created with a readable depth buffer (the `depth.readable` flag in `lovr.graphics.newCanvas`), then this function will return `nil`. +--- +---@return lovr.Texture texture # The depth Texture of the Canvas. +function Canvas:getDepthTexture() end + +--- +---Returns the dimensions of the Canvas, its Textures, and its depth buffer. +--- +---@return number width # The width of the Canvas, in pixels. +---@return number height # The height of the Canvas, in pixels. +function Canvas:getDimensions() end + +--- +---Returns the height of the Canvas, its Textures, and its depth buffer. +--- +---@return number height # The height of the Canvas, in pixels. +function Canvas:getHeight() end + +--- +---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. +--- +---@return number samples # The number of MSAA samples. +function Canvas:getMSAA() end + +--- +---Returns the set of Textures currently attached to the Canvas. +--- +function Canvas:getTexture() end + +--- +---Returns the width of the Canvas, its Textures, and its depth buffer. +--- +---@return number width # The width of the Canvas, in pixels. +function Canvas:getWidth() end + +--- +---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. +--- +---@return boolean stereo # Whether the Canvas is stereo. +function Canvas:isStereo() end + +--- +---Returns a new Image containing the contents of a Texture attached to the Canvas. +--- +---@param index? number # The index of the Texture to read from. +---@return lovr.Image image # The new Image. +function Canvas:newImage(index) end + +--- +---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`. +--- +---@param callback function # The function to use to render to the Canvas. +function Canvas:renderTo(callback) end + +--- +---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. +--- +function Canvas:setTexture() end + +--- +---A Font is an object created from a TTF file. It can be used to render text with `lovr.graphics.print`. +--- +---@class lovr.Font +local Font = {} + +--- +---Returns the maximum distance that any glyph will extend above the Font's baseline. Units are generally in meters, see `Font:getPixelDensity`. +--- +---@return number ascent # The ascent of the Font. +function Font:getAscent() end + +--- +---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`. +--- +---@return number baseline # The baseline of the Font. +function Font:getBaseline() end + +--- +---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. +--- +---@return number descent # The descent of the Font. +function Font:getDescent() end + +--- +---Returns the height of a line of text. Units are in meters, see `Font:setPixelDensity`. +--- +---@return number height # The height of a rendered line of text. +function Font:getHeight() end + +--- +---Returns the current line height multiplier of the Font. The default is 1.0. +--- +---@return number lineHeight # The line height. +function Font:getLineHeight() end + +--- +---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. +--- +---@return number pixelDensity # The current pixel density. +function Font:getPixelDensity() end + +--- +---Returns the underlying `Rasterizer` object for a Font. +--- +---@return lovr.Rasterizer rasterizer # The rasterizer. +function Font:getRasterizer() end + +--- +---Returns the width and line count of a string when rendered using the font, taking into account an optional wrap limit. +--- +---@param text string # The text to get the width of. +---@param wrap? number # The width at which to wrap lines, or 0 for no wrap. +---@return number width # The maximum width of any line in the text. +---@return number lines # The number of lines in the wrapped text. +function Font:getWidth(text, wrap) end + +--- +---Returns whether the Font has a set of glyphs. Any combination of strings and numbers (corresponding to character codes) can be specified. This function will return true if the Font is able to render *all* of the glyphs. +--- +---@return boolean has # Whether the Font has the glyphs. +function Font:hasGlyphs() end + +--- +---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. +--- +---@param lineHeight number # The new line height. +function Font:setLineHeight(lineHeight) end + +--- +---Sets the pixel density for the Font. Normally, this is in pixels per meter. When rendering to a 2D texture, the units are pixels. +--- +---@overload fun() +---@param pixelDensity number # The new pixel density. +function Font:setPixelDensity(pixelDensity) end + +--- +---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. +--- +---@class lovr.Material +local Material = {} + +--- +---Returns a color property for a Material. Different types of colors are supported for different lighting parameters. Colors default to `(1.0, 1.0, 1.0, 1.0)` and are gamma corrected. +--- +---@param colorType? lovr.MaterialColor # The type of color to get. +---@return number r # The red component of the color. +---@return number g # The green component of the color. +---@return number b # The blue component of the color. +---@return number a # The alpha component of the color. +function Material:getColor(colorType) end + +--- +---Returns a numeric property of a Material. Scalar properties default to 1.0. +--- +---@param scalarType lovr.MaterialScalar # The type of property to get. +---@return number x # The value of the property. +function Material:getScalar(scalarType) end + +--- +---Returns a texture for a Material. Several predefined `MaterialTexture`s are supported. Any texture that is `nil` will use a single white pixel as a fallback. +--- +---@param textureType? lovr.MaterialTexture # The type of texture to get. +---@return lovr.Texture texture # The texture that is set, or `nil` if no texture is set. +function Material:getTexture(textureType) end + +--- +---Returns the transformation applied to texture coordinates of the Material. +--- +---@return number ox # The texture coordinate x offset. +---@return number oy # The texture coordinate y offset. +---@return number sx # The texture coordinate x scale. +---@return number sy # The texture coordinate y scale. +---@return number angle # The texture coordinate rotation, in radians. +function Material:getTransform() end + +--- +---Sets a color property for a Material. Different types of colors are supported for different lighting parameters. Colors default to `(1.0, 1.0, 1.0, 1.0)` and are gamma corrected. +--- +---@overload fun(r: number, g: number, b: number, a: number) +---@overload fun(colorType: lovr.MaterialColor, hex: number, a: number) +---@overload fun(hex: number, a: number) +---@param colorType? lovr.MaterialColor # The type of color to set. +---@param r number # The red component of the color. +---@param g number # The green component of the color. +---@param b number # The blue component of the color. +---@param a? number # The alpha component of the color. +function Material:setColor(colorType, r, g, b, a) end + +--- +---Sets a numeric property of a Material. Scalar properties default to 1.0. +--- +---@param scalarType lovr.MaterialScalar # The type of property to set. +---@param x number # The value of the property. +function Material:setScalar(scalarType, x) end + +--- +---Sets a texture for a Material. Several predefined `MaterialTexture`s are supported. Any texture that is `nil` will use a single white pixel as a fallback. +--- +---@overload fun(texture: lovr.Texture) +---@param textureType? lovr.MaterialTexture # The type of texture to set. +---@param texture lovr.Texture # The texture to apply, or `nil` to use the default. +function Material:setTexture(textureType, texture) end + +--- +---Sets the transformation applied to texture coordinates of the Material. This lets you offset, scale, or rotate textures as they are applied to geometry. +--- +---@param ox number # The texture coordinate x offset. +---@param oy number # The texture coordinate y offset. +---@param sx number # The texture coordinate x scale. +---@param sy number # The texture coordinate y scale. +---@param angle number # The texture coordinate rotation, in radians. +function Material:setTransform(ox, oy, sx, sy, angle) end + +--- +---A Mesh is a low-level graphics object that stores and renders a list of vertices. +--- +---Meshes 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. +--- +---It'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. Even storing just one copy in the Mesh and drawing that 100 times is usually faster. +--- +---Meshes are also a good choice if you have an object that changes its shape over time. +--- +---@class lovr.Mesh +local Mesh = {} + +--- +---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. +--- +---@overload fun(mesh: lovr.Mesh, divisor: number, ...) +---@overload fun(mesh: lovr.Mesh, divisor: number, attributes: table) +---@param mesh lovr.Mesh # The Mesh to attach attributes from. +---@param divisor? number # The attribute divisor for all attached attributes. +function Mesh:attachAttributes(mesh, divisor) end + +--- +---Detaches attributes that were attached using `Mesh:attachAttributes`. +--- +---@overload fun(mesh: lovr.Mesh, ...) +---@overload fun(mesh: lovr.Mesh, attributes: table) +---@param mesh lovr.Mesh # A Mesh. The names of all of the attributes from this Mesh will be detached. +function Mesh:detachAttributes(mesh) end + +--- +---Draws the contents of the Mesh. +--- +---@overload fun(transform: lovr.mat4, instances: number) +---@param x? number # The x coordinate to draw the Mesh at. +---@param y? number # The y coordinate to draw the Mesh at. +---@param z? number # The z coordinate to draw the Mesh at. +---@param scale? number # The scale to draw the Mesh at. +---@param angle? number # The angle to rotate the Mesh around the axis of rotation, in radians. +---@param ax? number # The x component of the axis of rotation. +---@param ay? number # The y component of the axis of rotation. +---@param az? number # The z component of the axis of rotation. +---@param instances? number # The number of copies of the Mesh to draw. +function Mesh:draw(x, y, z, scale, angle, ax, ay, az, instances) end + +--- +---Get the draw mode of the Mesh, which controls how the vertices are connected together. +--- +---@return lovr.DrawMode mode # The draw mode of the Mesh. +function Mesh:getDrawMode() end + +--- +---Retrieve the current draw range for the Mesh. The draw range is a subset of the vertices of the Mesh that will be drawn. +--- +---@return number start # The index of the first vertex that will be drawn, or nil if no draw range is set. +---@return number count # The number of vertices that will be drawn, or nil if no draw range is set. +function Mesh:getDrawRange() end + +--- +---Get the Material applied to the Mesh. +--- +---@return lovr.Material material # The current material applied to the Mesh. +function Mesh:getMaterial() end + +--- +---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. +--- +---@param index number # The index of the vertex to retrieve. +function Mesh:getVertex(index) end + +--- +---Returns the components of a specific attribute of a single vertex in the Mesh. +--- +---@param index number # The index of the vertex to retrieve the attribute of. +---@param attribute number # The index of the attribute to retrieve the components of. +function Mesh:getVertexAttribute(index, attribute) end + +--- +---Returns the maximum number of vertices the Mesh can hold. +--- +---@return number size # The number of vertices the Mesh can hold. +function Mesh:getVertexCount() end + +--- +---Get the format table of the Mesh's vertices. The format table describes the set of data that each vertex contains. +--- +---@return table format # The table of vertex attributes. Each attribute is a table containing the name of the attribute, the `AttributeType`, and the number of components. +function Mesh:getVertexFormat() end + +--- +---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. +--- +---@overload fun(t: table):table +---@overload fun(blob: lovr.Blob) +---@return table map # The list of indices in the vertex map, or `nil` if no vertex map is set. +function Mesh:getVertexMap() end + +--- +---Returns whether or not a vertex attribute is enabled. Disabled attributes won't be sent to shaders. +--- +---@param attribute string # The name of the attribute. +---@return boolean enabled # Whether or not the attribute is enabled when drawing the Mesh. +function Mesh:isAttributeEnabled(attribute) end + +--- +---Sets whether a vertex attribute is enabled. Disabled attributes won't be sent to shaders. +--- +---@param attribute string # The name of the attribute. +---@param enabled boolean # Whether or not the attribute is enabled when drawing the Mesh. +function Mesh:setAttributeEnabled(attribute, enabled) end + +--- +---Set a new draw mode for the Mesh. +--- +---@param mode lovr.DrawMode # The new draw mode for the Mesh. +function Mesh:setDrawMode(mode) end + +--- +---Set the draw range for the Mesh. The draw range is a subset of the vertices of the Mesh that will be drawn. +--- +---@overload fun() +---@param start number # The first vertex that will be drawn. +---@param count number # The number of vertices that will be drawn. +function Mesh:setDrawRange(start, count) end + +--- +---Applies a Material to the Mesh. This will cause it to use the Material's properties whenever it is rendered. +--- +---@param material lovr.Material # The Material to apply. +function Mesh:setMaterial(material) end + +--- +---Update a single vertex in the Mesh. +--- +---@param index number # The index of the vertex to set. +function Mesh:setVertex(index) end + +--- +---Set the components of a specific attribute of a vertex in the Mesh. +--- +---@param index number # The index of the vertex to update. +---@param attribute number # The index of the attribute to update. +function Mesh:setVertexAttribute(index, attribute) end + +--- +---Sets the vertex map. The vertex map is a list of indices in the Mesh, allowing the reordering or reuse of vertices. +--- +---Often, 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. +--- +---@overload fun(blob: lovr.Blob, size: number) +---@param map table # The new vertex map. Each element of the table is an index of a vertex. +function Mesh:setVertexMap(map) end + +--- +---Updates multiple vertices in the Mesh. +--- +---@overload fun(blob: lovr.Blob, start: number, count: number) +---@param vertices table # The new set of vertices. +---@param start? number # The index of the vertex to start replacing at. +---@param count? number # The number of vertices to replace. If nil, all vertices will be used. +function Mesh:setVertices(vertices, start, count) end + +--- +---A Model is a drawable object loaded from a 3D file format. The supported 3D file formats are OBJ, glTF, and STL. +--- +---@class lovr.Model +local Model = {} + +--- +---Applies an animation to the current pose of the Model. +--- +---The animation is evaluated at the specified timestamp, and mixed with the current pose of the Model using the alpha value. An alpha value of 1.0 will completely override the pose of the Model with the animation's pose. +--- +---@overload fun(index: number, time: number, alpha: number) +---@param name string # The name of an animation. +---@param time number # The timestamp to evaluate the keyframes at, in seconds. +---@param alpha? number # How much of the animation to mix in, from 0 to 1. +function Model:animate(name, time, alpha) end + +--- +---Draw the Model. +--- +---@overload fun(transform: lovr.mat4, instances: number) +---@param x? number # The x coordinate to draw the Model at. +---@param y? number # The y coordinate to draw the Model at. +---@param z? number # The z coordinate to draw the Model at. +---@param scale? number # The scale to draw the Model at. +---@param angle? number # The angle to rotate the Model around the axis of rotation, in radians. +---@param ax? number # The x component of the axis of rotation. +---@param ay? number # The y component of the axis of rotation. +---@param az? number # The z component of the axis of rotation. +---@param instances? number # The number of copies of the Model to draw. +function Model:draw(x, y, z, scale, angle, ax, ay, az, instances) end + +--- +---Returns a bounding box that encloses the vertices of the Model. +--- +---@return number minx # The minimum x coordinate of the box. +---@return number maxx # The maximum x coordinate of the box. +---@return number miny # The minimum y coordinate of the box. +---@return number maxy # The maximum y coordinate of the box. +---@return number minz # The minimum z coordinate of the box. +---@return number maxz # The maximum z coordinate of the box. +function Model:getAABB() end + +--- +---Returns the number of animations in the Model. +--- +---@return number count # The number of animations in the Model. +function Model:getAnimationCount() end + +--- +---Returns the duration of an animation in the Model, in seconds. +--- +function Model:getAnimationDuration() end + +--- +---Returns the name of one of the animations in the Model. +--- +---@param index number # The index of the animation to get the name of. +---@return string name # The name of the animation. +function Model:getAnimationName(index) end + +--- +---Returns a Material loaded from the Model, by name or index. +--- +---This includes `Texture` objects and other properties like colors, metalness/roughness, and more. +--- +---@overload fun(index: number):lovr.Material +---@param name string # The name of the Material to return. +---@return lovr.Material material # The material. +function Model:getMaterial(name) end + +--- +---Returns the number of materials in the Model. +--- +---@return number count # The number of materials in the Model. +function Model:getMaterialCount() end + +--- +---Returns the name of one of the materials in the Model. +--- +---@param index number # The index of the material to get the name of. +---@return string name # The name of the material. +function Model:getMaterialName(index) end + +--- +---Returns the number of nodes (bones) in the Model. +--- +---@return number count # The number of nodes in the Model. +function Model:getNodeCount() end + +--- +---Returns the name of one of the nodes (bones) in the Model. +--- +---@param index number # The index of the node to get the name of. +---@return string name # The name of the node. +function Model:getNodeName(index) end + +--- +---Returns the pose of a single node in the Model in a given `CoordinateSpace`. +--- +---@overload fun(index: number, space: lovr.CoordinateSpace):number, number, number, number, number, number, number +---@param name string # The name of the node. +---@param space? lovr.CoordinateSpace # Whether the pose should be returned relative to the node's parent or relative to the root node of the Model. +---@return number x # The x position of the node. +---@return number y # The y position of the node. +---@return number z # The z position of the node. +---@return number angle # The number of radians the node is rotated around its rotational axis. +---@return number ax # The x component of the axis of rotation. +---@return number ay # The y component of the axis of rotation. +---@return number az # The z component of the axis of rotation. +function Model:getNodePose(name, space) end + +--- +---Returns 2 tables containing mesh data for the Model. +--- +---The first table is a list of vertex positions and contains 3 numbers for the x, y, and z coordinate of each vertex. The second table is a list of triangles and contains 1-based indices into the first table representing the first, second, and third vertices that make up each triangle. +--- +---The vertex positions will be affected by node transforms. +--- +---@return table vertices # A flat table of numbers containing vertex positions. +---@return table indices # A flat table of numbers containing triangle vertex indices. +function Model:getTriangles() end + +--- +---Returns whether the Model has any nodes associated with animated joints. This can be used to approximately determine whether an animated shader needs to be used with an arbitrary Model. +--- +---@return boolean skeletal # Whether the Model has any nodes that use skeletal animation. +function Model:hasJoints() end + +--- +---Applies a pose to a single node of the Model. The input pose is assumed to be relative to the pose of the node's parent. This is useful for applying inverse kinematics (IK) to a chain of bones in a skeleton. +--- +---The alpha parameter can be used to mix between the node's current pose and the input pose. +--- +---@overload fun(index: number, x: number, y: number, z: number, angle: number, ax: number, ay: number, az: number, alpha: number) +---@overload fun() +---@param name string # The name of the node. +---@param x number # The x position. +---@param y number # The y position. +---@param z number # The z position. +---@param angle number # The angle of rotation around the axis, in radians. +---@param ax number # The x component of the rotation axis. +---@param ay number # The y component of the rotation axis. +---@param az number # The z component of the rotation axis. +---@param alpha? number # How much of the pose to mix in, from 0 to 1. +function Model:pose(name, x, y, z, angle, ax, ay, az, alpha) end + +--- +---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. +--- +---@class lovr.Shader +local Shader = {} + +--- +---Returns the type of the Shader, which will be "graphics" or "compute". +--- +---Graphics 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`. +--- +---@return lovr.ShaderType type # The type of the Shader. +function Shader:getType() end + +--- +---Returns whether a Shader has a block. +--- +---A block is added to the Shader code at creation time using `ShaderBlock:getShaderCode`. The block name (not the namespace) is used to link up the ShaderBlock object to the Shader. This function can be used to check if a Shader was created with a block using the given name. +--- +---@param block string # The name of the block. +---@return boolean present # Whether the shader has the specified block. +function Shader:hasBlock(block) end + +--- +---Returns whether a Shader has a particular uniform variable. +--- +---@param uniform string # The name of the uniform variable. +---@return boolean present # Whether the shader has the specified uniform. +function Shader:hasUniform(uniform) end + +--- +---Updates a uniform variable in the Shader. +--- +---@param uniform string # The name of the uniform to update. +---@param value lovr.* # The new value of the uniform. +---@return boolean success # Whether the uniform exists and was updated. +function Shader:send(uniform, value) end + +--- +---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. +--- +---@param name string # The name of the block to send to. +---@param block lovr.ShaderBlock # The ShaderBlock to associate with the specified block. +---@param access? lovr.UniformAccess # How the Shader will use this block (used as an optimization hint). +function Shader:sendBlock(name, block, access) end + +--- +---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. +--- +---@overload fun(name: string, index: number, texture: lovr.Texture, slice: number, mipmap: number, access: lovr.UniformAccess) +---@param name string # The name of the image uniform. +---@param texture lovr.Texture # The Texture to assign. +---@param slice? number # The slice of a cube, array, or volume texture to use, or `nil` for all slices. +---@param mipmap? number # The mipmap of the texture to use. +---@param access? lovr.UniformAccess # Whether the image will be read from, written to, or both. +function Shader:sendImage(name, texture, slice, mipmap, access) end + +--- +---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: +--- +---- They can hold a lot more data. +---- Shaders can modify the data in them, which is really useful for compute shaders. +---- Setting the data in a ShaderBlock updates the data for all Shaders using the block, so you +--- don't need to go around setting the same uniforms in lots of different shaders. +--- +---On 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. +--- +---@class lovr.ShaderBlock +local ShaderBlock = {} + +--- +---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`. +--- +---@param field string # The name of the variable to get the offset of. +---@return number offset # The byte offset of the variable. +function ShaderBlock:getOffset(field) end + +--- +---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: +--- +--- layout(std140) uniform