A small OpenGL 3+ renderer and game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

64 lines
1.0 KiB

#pragma once
#include <glm/glm.hpp>
#include "types.h"
struct Camera
{
float hAngle;
float vAngle;
glm::vec3 position;
glm::vec3 forward;
glm::vec3 up;
glm::vec3 left;
glm::vec3 target;
glm::vec3 world_up;
glm::mat4 model;
glm::mat4 view;
glm::mat4 projection;
glm::mat4 MVP;
};
// FIXME: we should keep to our convention of passing pointers to structs in
// these interface functions
glm::vec2
cameraUnproject(Camera& cam, int x, int y, int vp_width, int vp_height);
glm::vec3
cameraCreateRay(Camera& cam, glm::ivec2 vp_coords, glm::ivec2 vp_dims);
bool
cameraIntersectPlane(Camera& cam,
glm::vec3 ray,
glm::vec3 plane_origin,
glm::vec3 plane_normal,
glm::vec3& intersection);
void
cameraInitPerspective(Camera* cam,
glm::vec3 position,
glm::vec3 target,
glm::vec3 world_up,
float aspect_ratio = 16.f / 9.f);
void
cameraMove(Camera& cam,
bool up,
bool left,
bool down,
bool right,
bool forward,
bool backward);
void
cameraRotate(Camera& cam, i32 xrel, i32 yrel);
void
cameraRoll(Camera& cam, bool CW, bool CCW);