/** * Copyright (c) 2025 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "dusk.h" #include "display/color.h" #define CAMERA_COUNT_MAX 4 typedef enum { CAMERA_PROJECTION_TYPE_PERSPECTIVE, CAMERA_PROJECTION_TYPE_PERSPECTIVE_FLIPPED, CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC } cameraprojectiontype_t; typedef enum { CAMERA_VIEW_TYPE_MATRIX, CAMERA_VIEW_TYPE_LOOKAT, CAMERA_VIEW_TYPE_2D, CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT } cameraviewtype_t; typedef struct { cameraprojectiontype_t projType; cameraviewtype_t viewType; union { mat4 view; struct { float_t position[3]; float_t target[3]; float_t up[3]; } lookat; struct { float_t offset[3]; float_t target[3]; float_t up[3]; float_t pixelsPerUnit; } lookatPixelPerfect; struct { float_t position[2]; float_t zoom; } _2d; }; union { struct { float_t fov; } perspective; struct { float_t left; float_t right; float_t top; float_t bottom; } orthographic; }; float_t nearClip; float_t farClip; } camera_t; /** * Initializes a camera to default values. This calls cameraInitPerspective. */ void cameraInit(camera_t *camera); /** * Initializes a camera for perspective projection. */ void cameraInitPerspective(camera_t *camera); /** * Initializes a camera for orthographic projection. */ void cameraInitOrthographic(camera_t *camera); /** * Pushes the camera's view matrix onto the matrix stack. * * @param id The ID of the camera entity to use. */ void cameraPushMatrix(camera_t* camera); /** * Pops the camera's view matrix off the matrix stack. */ void cameraPopMatrix(void);