From 260f05025631031b7cc4904805d5017feaf53eda Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Thu, 30 Jan 2020 21:11:12 +0100 Subject: initial commit --- src/camera.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/camera.c (limited to 'src/camera.c') 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 -- cgit v1.2.3-70-g09d2