Module l3d
LÖVE3D.
Utilities for working in 3D with LÖVE.
Functions
import (use_monkeypatching, automatic_transforms) | Load OpenGL functions for use by LÖVE3D. |
clear (color, depth) | Clear color/depth buffers. |
reset () | Reset LOVE3D state. |
set_depth_write (mask) | Set depth writing. |
set_depth_test (method) | Set depth test method. |
set_front_face (facing) | Set front face winding. |
set_culling (method) | Set culling method. |
new_shader_raw (gl_version, vc, pc) | Create a shader without LOVE's preprocessing. |
update_shader (shader) | Update the active shader. |
push (which) | Push the current matrix to the stack. |
pop () | Pop the current matrix off the stack. |
translate (x, y, z) | Translate the current matrix. |
rotate (r, axis) | Translate the current matrix. |
scale (x, y, z) | Scale the current matrix. |
origin () | Reset the current matrix. |
get_matrix () | Return the current matrix. |
update_matrix (matrix_type, m) | Send matrix to the active shader. |
new_triangles (t, offset, mesh, usage) | Create a buffer from a list of vertices (cpml.vec3's). |
new_canvas (width, height, format, msaa, gen_depth) | Create a canvas with a depth buffer. |
bind_shadow_map (map) | Bind a shadow map. |
bind_shadow_texture (map, shader) | Bind shadow map to a texture sampler. |
new_shadow_map (w, h) | Create a new shadow map. |
patch (automatic_transforms) | Patch functions into the LOVE API. |
love.graphics.clearDepth () | See l3d.clear. |
love.graphics.setDepthTest () | See l3d.setdepthtest. |
love.graphics.setDepthWrite () | See l3d.setdepthwrite. |
love.graphics.setCulling () | See l3d.set_culling. |
love.graphics.setFrontFace () | See l3d.setfrontface. |
love.graphics.reset () | See l3d.reset. |
love.graphics.origin () | See l3d.origin. |
love.graphics.pop () | See l3d.pop. |
love.graphics.push () | See l3d.push. |
love.graphics.rotate (r, axis) | See l3d.rotate. |
love.graphics.scale (x, y, z) | See l3d.scale. |
love.graphics.translate (x, y, z) | See l3d.translate. |
love.graphics.getMatrix () | See l3d.get_matrix. |
love.graphics.updateMatrix (matrix_type, m) | See l3d.update_matrix. |
love.graphics.setShader (shader) | See l3d.update_shader. |
love.graphics.newCanvas () | See l3d.new_canvas. |
Functions
- import (use_monkeypatching, automatic_transforms)
-
Load OpenGL functions for use by LÖVE3D.
Loads extra functions that LÖVE does not provide and optionally adds/updates
functions in love.graphics for 3D.
This must be called before anything else.
Parameters:
- use_monkeypatching patch the LOVE API with LOVE3D functions
- automatic_transforms attempt to automatically upload transformation matrices
- clear (color, depth)
-
Clear color/depth buffers.
Must pass false (not nil!) to disable clearing. Defaults to depth only.
Parameters:
- color clear color buffer (bool)
- depth clear depth buffer (bool)
- reset ()
- Reset LOVE3D state. Disables depth testing, enables depth writing, disables culling and resets front face.
- set_depth_write (mask)
-
Set depth writing.
Enable or disable writing to the depth buffer.
Parameters:
- mask
- set_depth_test (method)
-
Set depth test method.
Can be "greater", "equal", "less" or unspecified to disable depth testing.
Usually you want to use "less".
Parameters:
- method
- set_front_face (facing)
-
Set front face winding.
Can be "cw", "ccw" or unspecified to reset to ccw.
Parameters:
- facing
- set_culling (method)
-
Set culling method.
Can be "front", "back" or unspecified to reset to none.
Parameters:
- method
- new_shader_raw (gl_version, vc, pc)
-
Create a shader without LOVE's preprocessing.
Useful if you need different shader outputs or a later GLSL version.
The shader is still preprocessed for things such as VERTEX and PIXEL, but
you will have to write your own main() function, attributes, etc.
Warning: This will very likely do bad things for your shader compatibility.
Parameters:
- gl_version
- vc vertex shader code or filename
- pc pixel shader code or filename
Returns:
-
shader
- update_shader (shader)
-
Update the active shader.
Used internally by patched API, update it yourself otherwise.
This is important for l3d.push/pop and update_matrix.
Parameters:
- shader
- push (which)
-
Push the current matrix to the stack.
Parameters:
- which
- pop ()
- Pop the current matrix off the stack.
- translate (x, y, z)
-
Translate the current matrix.
Parameters:
- x vec3 or x translation
- y y translation
- z z translation (or 1)
- rotate (r, axis)
-
Translate the current matrix.
Parameters:
- r rotation angle in radians
- axis axis to rotate about. Z if unspecified.
- scale (x, y, z)
-
Scale the current matrix.
Parameters:
- x vec3 or x scale
- y y scale
- z z scale (or 1)
- origin ()
- Reset the current matrix.
- get_matrix ()
-
Return the current matrix.
Returns:
-
mat4
- update_matrix (matrix_type, m)
-
Send matrix to the active shader.
Convenience function.
Valid matrix types are currently "transform" and "projection". A "view" type will likely be added in the future for convenience.
Parameters:
- matrix_type
- m
- new_triangles (t, offset, mesh, usage)
-
Create a buffer from a list of vertices (cpml.vec3's).
Offset will offset every vertex by the specified amount, useful for preventing z-fighting.
Optional mesh argument will update the mesh instead of creating a new one.
Specify usage as "dynamic" if you intend to update it frequently.
Parameters:
- t vertex data
- offset
- mesh used when updating
- usage
- new_canvas (width, height, format, msaa, gen_depth)
-
Create a canvas with a depth buffer.
Parameters:
- width
- height
- format
- msaa
- gen_depth
- bind_shadow_map (map)
-
Bind a shadow map.
Sets up drawing to a shadow map texture created with l3d.newshadowmap.
Parameters:
- map
- bind_shadow_texture (map, shader)
-
Bind shadow map to a texture sampler.
Parameters:
- map
- shader
- new_shadow_map (w, h)
-
Create a new shadow map.
Creates a depth texture and framebuffer to draw to.
Parameters:
- w shadow map width
- h shadow map height
Returns:
-
shadow_map
- patch (automatic_transforms)
-
Patch functions into the LOVE API.
Automatically called by l3d.import(true).
This isn't good practice (which is why you must explicitly call it), but patching various love functions to maintain state here makes things a lot more pleasant to use.
Do not call this function if you've already called import(true).
Parameters:
- automatic_transforms
- love.graphics.clearDepth ()
- See l3d.clear.
- love.graphics.setDepthTest ()
- See l3d.setdepthtest.
- love.graphics.setDepthWrite ()
- See l3d.setdepthwrite.
- love.graphics.setCulling ()
- See l3d.set_culling.
- love.graphics.setFrontFace ()
- See l3d.setfrontface.
- love.graphics.reset ()
- See l3d.reset.
- love.graphics.origin ()
- See l3d.origin.
- love.graphics.pop ()
- See l3d.pop.
- love.graphics.push ()
- See l3d.push.
- love.graphics.rotate (r, axis)
-
See l3d.rotate.
Parameters:
- r
- axis
- love.graphics.scale (x, y, z)
-
See l3d.scale.
Parameters:
- x
- y
- z
- love.graphics.translate (x, y, z)
-
See l3d.translate.
Parameters:
- x
- y
- z
- love.graphics.getMatrix ()
- See l3d.get_matrix.
- love.graphics.updateMatrix (matrix_type, m)
-
See l3d.update_matrix.
Parameters:
- matrix_type
- m
- love.graphics.setShader (shader)
-
See l3d.update_shader.
Parameters:
- shader
- love.graphics.newCanvas ()
- See l3d.new_canvas.