Added translations.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package renderer
|
||||
|
||||
import "core:math/linalg"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
|
||||
@@ -81,8 +82,23 @@ render_frame :: proc(renderer: ^Renderer) {
|
||||
|
||||
for i in 0..<pass.draw_command_count {
|
||||
command := &pass.draw_commands[i]
|
||||
|
||||
transform := linalg.identity(linalg.Matrix4x4f32)
|
||||
|
||||
activate_material(&command.material)
|
||||
scale := linalg.matrix4_scale(command.scale)
|
||||
rotation := linalg.matrix4_rotate(0, [3]f32 { 0, 0, 1 })
|
||||
translation := linalg.matrix4_translate(command.position)
|
||||
|
||||
// Scale.
|
||||
transform *= scale
|
||||
|
||||
// Rotate.
|
||||
transform *= rotation
|
||||
|
||||
// Translate.
|
||||
transform *= translation
|
||||
|
||||
activate_material(&command.material, transform)
|
||||
|
||||
draw_mesh(&command.mesh)
|
||||
}
|
||||
@@ -107,11 +123,11 @@ destroy :: proc(renderer: ^Renderer) {
|
||||
free(renderer)
|
||||
}
|
||||
|
||||
@(private) activate_material :: proc(material: ^Material) {
|
||||
@(private) activate_material :: proc(material: ^Material, transform: linalg.Matrix4x4f32) {
|
||||
assert(material != nil)
|
||||
|
||||
when RENDER_BACKEND_OPENGL {
|
||||
opengl_activate_material(material)
|
||||
opengl_activate_material(material, transform)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user