ECS POC
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* 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"
|
||||
#include "display/camera/cameraplatform.h"
|
||||
|
||||
#ifndef cameraPushMatrixPlatform
|
||||
#error "cameraPushMatrixPlatform must be defined"
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum {
|
||||
CAMERA_VIEW_TYPE_MATRIX,
|
||||
CAMERA_VIEW_TYPE_LOOKAT,
|
||||
CAMERA_VIEW_TYPE_2D,
|
||||
CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT
|
||||
} cameraviewtype_t;
|
||||
|
||||
typedef struct camera_s {
|
||||
union {
|
||||
mat4 view;
|
||||
|
||||
struct {
|
||||
vec3 position;
|
||||
vec3 target;
|
||||
vec3 up;
|
||||
} lookat;
|
||||
|
||||
struct {
|
||||
vec3 offset;
|
||||
vec3 target;
|
||||
vec3 up;
|
||||
float_t pixelsPerUnit;
|
||||
} lookatPixelPerfect;
|
||||
|
||||
struct {
|
||||
vec2 position;
|
||||
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;
|
||||
|
||||
cameraprojectiontype_t projType;
|
||||
cameraviewtype_t viewType;
|
||||
} 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);
|
||||
|
||||
/**
|
||||
* Gets the projection matrix for a camera.
|
||||
*
|
||||
* @param camera Camera to get the projection matrix for
|
||||
* @param dest Matrix to store the projection matrix in
|
||||
*/
|
||||
void cameraGetProjectionMatrix(camera_t *camera, mat4 dest);
|
||||
|
||||
/**
|
||||
* Gets the view matrix for a camera.
|
||||
*
|
||||
* @param camera Camera to get the view matrix for
|
||||
* @param dest Matrix to store the view matrix in
|
||||
*/
|
||||
void cameraGetViewMatrix(camera_t *camera, mat4 dest);
|
||||
Reference in New Issue
Block a user