Created
November 15, 2016 03:14
-
-
Save warmwaffles/eb9e70c2718a50c4fb119861cb493e0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct mat4f | |
gfx_camera_get_combined(struct gfx_camera* camera) | |
{ | |
assert(camera); | |
struct mat4f ortho; | |
struct mat4f translation; | |
struct mat4f zoom; | |
float vw = camera->viewport.width; | |
float vh = camera->viewport.height; | |
float x = camera->position.x; | |
float y = camera->position.y; | |
float z = camera->position.z; | |
ortho = mat4f_ortho( | |
-vw / 2, | |
vw / 2, | |
-vh / 2, | |
vh / 2, | |
camera->near, | |
camera->far | |
); | |
translation = mat4f_translation(-x, -y, -z); | |
zoom = mat4f_zoom(camera->zoom, camera->zoom, camera->zoom); | |
return mat4f_mul(ortho, mat4f_mul(zoom, translation)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment