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.arcDraw an arc.
lovr.graphics.boxDraw a box.
lovr.graphics.circleDraw a 2D circle.
lovr.graphics.computeRun a compute shader.
lovr.graphics.cubeDraw a cube.
lovr.graphics.cylinderDraw a cylinder.
lovr.graphics.fillFill the screen with a texture.
lovr.graphics.lineDraw lines.
lovr.graphics.planeDraw a plane.
lovr.graphics.pointsDraw one or more points.
lovr.graphics.printRender text.
lovr.graphics.skyboxRender a skybox.
lovr.graphics.sphereDraw a sphere.
lovr.graphics.stencilModify the stencil buffer.
lovr.graphics.triangleDraw a triangle.

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.newAnimatorCreate a new Animator.
lovr.graphics.newCanvasCreate a new Canvas.
lovr.graphics.newComputeShaderCreate a new compute Shader.
lovr.graphics.newFontCreate a new Font.
lovr.graphics.newMaterialCreate a new Material.
lovr.graphics.newMeshCreate a new Mesh.
lovr.graphics.newModelCreate a new Model.
lovr.graphics.newShaderCreate a new Shader.
lovr.graphics.newShaderBlockCreate a new ShaderBlock.
lovr.graphics.newTextureCreate 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.originReset the coordinate system.
lovr.graphics.popPop the current transform off the stack.
lovr.graphics.pushPush a copy of the current transform onto the stack.
lovr.graphics.rotateRotate the coordinate system.
lovr.graphics.scaleScale the coordinate system.
lovr.graphics.transformApply a general transform to the coordinate system.
lovr.graphics.translateTranslate 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.getBackgroundColorGet the background color.
lovr.graphics.setBackgroundColorSet the background color.
lovr.graphics.getBlendModeGet the blend mode.
lovr.graphics.setBlendModeSet the blend mode.
lovr.graphics.getCanvasGet the active Canvas.
lovr.graphics.setCanvasSet the active Canvas.
lovr.graphics.getColorGet the global color factor.
lovr.graphics.setColorSet the global color factor.
lovr.graphics.isCullingEnabledGet whether backface culling is enabled.
lovr.graphics.setCullingEnabledEnable or disable backface culling.
lovr.graphics.getDefaultFilterGet the default filter mode for Textures.
lovr.graphics.setDefaultFilterSet the default filter mode for Textures.
lovr.graphics.getDepthTestGet the depth test mode.
lovr.graphics.setDepthTestSet or disable the depth test.
lovr.graphics.getFontGet the active font.
lovr.graphics.setFontSet the active font.
lovr.graphics.isGammaCorrectGet whether wireframe mode is enabled.
lovr.graphics.getLineWidthGet the line width.
lovr.graphics.setLineWidthSet the line width.
lovr.graphics.getPointSizeGet the point size.
lovr.graphics.setPointSizeSet the point size.
lovr.graphics.resetReset all graphics state.
lovr.graphics.getShaderGet the active shader.
lovr.graphics.setShaderSet or disable the active shader.
lovr.graphics.getStatsGet renderer stats for the current frame.
lovr.graphics.getStencilTestGet the current stencil test.
lovr.graphics.setStencilTestSet the stencil test.
lovr.graphics.getWindingGet the winding direction.
lovr.graphics.setWindingSet the winding direction.
lovr.graphics.isWireframeGet whether wireframe mode is enabled.
lovr.graphics.setWireframeEnable or disable wireframe rendering.

Window

Get info about the desktop window or operate on the underlying graphics context.

lovr.graphics.clearClear the screen.
lovr.graphics.createWindowCreates the window.
lovr.graphics.getDimensionsGet the dimensions of the window.
lovr.graphics.getHeightGet the height of the window.
lovr.graphics.presentPresent a frame to the window.
lovr.graphics.getSupportedCheck if certain features are supported.
lovr.graphics.getSystemLimitsGet capabilities of the graphics card.
lovr.graphics.getWidthGet the width of the window.