summaryrefslogtreecommitdiff
path: root/src/camera.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik.ramaekers@protonmail.com>2020-01-30 21:11:12 +0100
committerAldrik Ramaekers <aldrik.ramaekers@protonmail.com>2020-01-30 21:11:12 +0100
commit260f05025631031b7cc4904805d5017feaf53eda (patch)
treed5a723bb7bbbc9f8b598712723fe3d8290c0a54c /src/camera.c
initial commit
Diffstat (limited to 'src/camera.c')
-rw-r--r--src/camera.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/camera.c b/src/camera.c
new file mode 100644
index 0000000..5bde9f9
--- /dev/null
+++ b/src/camera.c
@@ -0,0 +1,22 @@
+/*
+* BSD 2-Clause “Simplified” License
+* Copyright (c) 2019, Aldrik Ramaekers, aldrik.ramaekers@protonmail.com
+* All rights reserved.
+*/
+
+void camera_apply_transformations(platform_window *window, camera *camera)
+{
+ s32 x = (window->width/2)+(camera->x);
+ s32 y = (window->height/2)+(camera->y);
+ glTranslatef(x, y, 0.0f);
+ glRotatef(camera->rotation, 0.0f, 0.0f, 1.0f);
+ glTranslatef(-x, -y, 0.0f);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ glOrtho(camera->x, window->width+camera->x,
+ window->height+camera->y, camera->y, -100, 100);
+
+ glMatrixMode(GL_MODELVIEW);
+} \ No newline at end of file