Nimbin[12]?Games / Entropie / entropie/src/render/camera.h

Entropie git · main

Entropie festival game; first steps

sdl c game entropie cmake · first commit 2026-10-10 · last commit 2026-11-02 (18 hours ago) · synced 10 hours ago

C 88.5% Markdown 9.1% GLSL 2.3%
git clone https://git.christianimmanuel.de/games/Entropie.gitwget https://git.christianimmanuel.de/games/Entropie/archive/Entropie.tar.gz
entropie/src/render/camera.h 879 B · 33 lines raw
#ifndef RENDER_CAMERA_H
#define RENDER_CAMERA_H

/* First-person camera (yaw/pitch in degrees). */

#include "math/linalg.h"

typedef struct {
    Vec3  position;
    Vec3  front;
    Vec3  right;
    Vec3  up;
    float yaw;
    float pitch;
    float fov;
    float near_z;
    float far_z;
    float sway_yaw;    /* degrees added to the view only (drunk wobble) */
    float sway_pitch;
    float roll;        /* degrees, tilts the view around its direction */
    Mat4  view;
    Mat4  projection;
} Camera;

void Camera_init(Camera *cam, Vec3 position, float yaw, float pitch, float fov);

/* Adds yaw/pitch (pitch clamped to +-89 degrees) and updates direction vectors. */
void Camera_rotate(Camera *cam, float yaw_delta, float pitch_delta);

/* Rebuilds view and projection matrices. */
void Camera_updateMatrices(Camera *cam, float aspect);

#endif /* RENDER_CAMERA_H */