lovr.graphics
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.
Drawing
Simple functions for drawing simple shapes.
lovr.graphics.arc | Draw an arc. |
lovr.graphics.box | Draw a box. |
lovr.graphics.circle | Draw a 2D circle. |
lovr.graphics.compute | Run a compute shader. |
lovr.graphics.cube | Draw a cube. |
lovr.graphics.cylinder | Draw a cylinder. |
lovr.graphics.discard | Discard the current pixel values. |
lovr.graphics.fill | Fill the screen with a texture. |
lovr.graphics.flush | Flush any pending batched draw calls. |
lovr.graphics.line | Draw lines. |
lovr.graphics.plane | Draw a plane. |
lovr.graphics.points | Draw one or more points. |
lovr.graphics.print | Render text. |
lovr.graphics.skybox | Render a skybox. |
lovr.graphics.sphere | Draw a sphere. |
lovr.graphics.stencil | Modify the stencil buffer. |
lovr.graphics.triangle | Draw triangles. |
Objects
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!
lovr.graphics.newCanvas | Create a new Canvas. |
lovr.graphics.newComputeShader | Create a new compute Shader. |
lovr.graphics.newFont | Create a new Font. |
lovr.graphics.newMaterial | Create a new Material. |
lovr.graphics.newMesh | Create a new Mesh. |
lovr.graphics.newModel | Create a new Model. |
lovr.graphics.newShader | Create a new Shader. |
lovr.graphics.newShaderBlock | Create a new ShaderBlock. |
lovr.graphics.newTexture | Create a new Texture. |
Transforms
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!
lovr.graphics.origin | Reset the coordinate system. |
lovr.graphics.pop | Pop the current transform off the stack. |
lovr.graphics.push | Push a copy of the current transform onto the stack. |
lovr.graphics.rotate | Rotate the coordinate system. |
lovr.graphics.scale | Scale the coordinate system. |
lovr.graphics.transform | Apply a general transform to the coordinate system. |
lovr.graphics.translate | Translate the coordinate system. |
State
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.
lovr.graphics.getAlphaSampling | Get whether alpha sampling is enabled. |
lovr.graphics.setAlphaSampling | Enable or disable alpha sampling. |
lovr.graphics.getBackgroundColor | Get the background color. |
lovr.graphics.setBackgroundColor | Set the background color. |
lovr.graphics.getBlendMode | Get the blend mode. |
lovr.graphics.setBlendMode | Set the blend mode. |
lovr.graphics.getCanvas | Get the active Canvas. |
lovr.graphics.setCanvas | Set the active Canvas. |
lovr.graphics.getColor | Get the global color factor. |
lovr.graphics.setColor | Set the global color factor. |
lovr.graphics.getColorMask | Get whether each color channel is enabled. |
lovr.graphics.setColorMask | Enable or disable color channels. |
lovr.graphics.isCullingEnabled | Get whether backface culling is enabled. |
lovr.graphics.setCullingEnabled | Enable or disable backface culling. |
lovr.graphics.getDefaultFilter | Get the default filter mode for Textures. |
lovr.graphics.setDefaultFilter | Set the default filter mode for Textures. |
lovr.graphics.getDepthTest | Get the depth test mode. |
lovr.graphics.setDepthTest | Set or disable the depth test. |
lovr.graphics.getFont | Get the active font. |
lovr.graphics.setFont | Set the active font. |
lovr.graphics.getLineWidth | Get the line width. |
lovr.graphics.setLineWidth | Set the line width. |
lovr.graphics.getPointSize | Get the point size. |
lovr.graphics.setPointSize | Set the point size. |
lovr.graphics.getProjection | Get the field of view. |
lovr.graphics.setProjection | Set the field of view. |
lovr.graphics.reset | Reset all graphics state. |
lovr.graphics.getShader | Get the active shader. |
lovr.graphics.setShader | Set or disable the active shader. |
lovr.graphics.getStats | Get renderer stats for the current frame. |
lovr.graphics.getStencilTest | Get the current stencil test. |
lovr.graphics.setStencilTest | Set the stencil test. |
lovr.graphics.getViewPose | Get the camera pose. |
lovr.graphics.setViewPose | Set the camera pose. |
lovr.graphics.getWinding | Get the winding direction. |
lovr.graphics.setWinding | Set the winding direction. |
lovr.graphics.isWireframe | Get whether wireframe mode is enabled. |
lovr.graphics.setWireframe | Enable or disable wireframe rendering. |
Window
Get info about the desktop window or operate on the underlying graphics context.
lovr.graphics.clear | Clear the screen. |
lovr.graphics.createWindow | Creates the window. |
lovr.graphics.getDimensions | Get the dimensions of the window. |
lovr.graphics.getFeatures | Check if certain features are supported. |
lovr.graphics.hasWindow | Check if the window is created. |
lovr.graphics.getHeight | Get the height of the window. |
lovr.graphics.getLimits | Get capabilities of the graphics card. |
lovr.graphics.getPixelDensity | Get the pixel density of the window. |
lovr.graphics.present | Present a frame to the window. |
lovr.graphics.tick | Start a timer on the GPU. |
lovr.graphics.tock | Stop a timer on the GPU. |
lovr.graphics.getWidth | Get the width of the window. |