Pre-multiply V and P matrices
This commit is contained in:
1 parent
e7f4f4b51d
commit
2cf4f6832d
5 files changed
+21
-25
No files matched your search
@@ -12,7 +12,7 @@
|
||||
|
||||
#define DT (1'000'000 / 60) // Assume 60 Hz for now
|
||||
|
||||
#define LIL_GUY_COUNT 2
|
||||
#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
|
||||
static void
|
||||
key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||
@@ -59,11 +59,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
const vec3_t cam = { 0, 4, -8 };
|
||||
const vec3_t tgt = { 0, 0, 0 };
|
||||
const vp_t vp = {
|
||||
.view = mat4_lookat(cam, tgt, (vec3_t) { 0, 1, 0 }),
|
||||
.proj = mat4_perspective((float)W / H, PI / 8, 0.1, 100.0),
|
||||
};
|
||||
mat4_t transforms[] = {
|
||||
const mat4_t view = mat4_lookat(cam, tgt, (vec3_t) { 0, 1, 0 });
|
||||
const mat4_t proj = mat4_perspective((float)W / H, PI / 8, 0.1, 100.0);
|
||||
const mat4_t vp = mat4_mul(proj, view);
|
||||
mat4_t transforms[NELEMS(gpu_models)] = {
|
||||
mat4_mul(
|
||||
MAT4_TRANSLATE(1, 0, 0),
|
||||
(mat4_t) {
|
||||
@@ -96,9 +95,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
animation_update(&anim, &model, DT);
|
||||
|
||||
const mat4_t *bone_matrices[]
|
||||
= { anim.bone_matrices, anim.bone_matrices };
|
||||
gpu_render(&gpu, vp, 2, gpu_models, bone_matrices, transforms);
|
||||
const mat4_t *bone_matrices[NELEMS(gpu_models)] = {
|
||||
anim.bone_matrices,
|
||||
anim.bone_matrices,
|
||||
};
|
||||
gpu_render(
|
||||
&gpu, vp, NELEMS(gpu_models), gpu_models, bone_matrices,
|
||||
transforms);
|
||||
}
|
||||
|
||||
// Clean up
|
||||
|
||||
Reference in new issue
Block a user