Skip to content

Instantly share code, notes, and snippets.

View PascalHann's full-sized avatar

Pascal Hann PascalHann

View GitHub Profile
@PascalHann
PascalHann / OrbitCamera.cpp
Last active November 22, 2019 17:19
Simple orbit camera for C++ and OpenGL using 3D polar coordinates
#include "OrbitCamera.h"
glm::mat4 OrbitCamera::generateViewMatrix(glm::vec3 eye, glm::vec3 target, glm::vec3 up)
{
//zAxis is the axis the viewer is looking along when the program is initialized
glm::vec3 zAxis = glm::normalize(eye - target);
glm::vec3 xAxis = glm::normalize(glm::cross(up, zAxis));
glm::vec3 yAxis = glm::normalize(glm::cross(zAxis, xAxis));
glm::mat4 viewMatrix = {