twn_draw.c: draw_camera_2d()!

This commit is contained in:
veclavtalica
2025-02-05 00:54:38 +03:00
parent d9d7072c86
commit d9df3f9b04
6 changed files with 63 additions and 3 deletions

View File

@ -161,8 +161,15 @@ static void finally_use_2d_pipeline(void) {
glOrtho(0, (double)ctx.base_render_width, (double)ctx.base_render_height, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
/* TODO: 2d camera */
glLoadIdentity();
/* rotate against center of the viewport */
Vec2 const center_offset = { ctx.game.resolution.x / 2, ctx.game.resolution.y / 2 };
glTranslatef(center_offset.x, center_offset.y, 0);
glRotatef(camera_2d_rotation, 0, 0, 1);
glScalef(camera_2d_zoom, camera_2d_zoom, 1);
glTranslatef(-center_offset.x, -center_offset.y, 0);
/* apply the rest */
glTranslatef(-camera_2d_position.x, -camera_2d_position.y, 0);
texture_mode_last_used = -1;
pipeline_last_used = PIPELINE_2D;