From fcf6abaccec7c7ed2fd306a9cf1ec378f303297c Mon Sep 17 00:00:00 2001 From: majortom6 Date: Sun, 19 Feb 2017 10:41:00 -0600 Subject: -refractoring of includes --- inc/opengl/camera.hpp | 39 ++++++++++++++------------- inc/opengl/geoshader.hpp | 9 +++---- inc/opengl/graphicsdata.hpp | 66 +++++++++++++++++---------------------------- 3 files changed, 49 insertions(+), 65 deletions(-) (limited to 'inc/opengl') diff --git a/inc/opengl/camera.hpp b/inc/opengl/camera.hpp index 62ae837..06a5a88 100644 --- a/inc/opengl/camera.hpp +++ b/inc/opengl/camera.hpp @@ -1,57 +1,58 @@ #ifndef camera_h #define camera_h +#include "constants.hpp" + struct Camera { public: Camera(const glm::vec3& pos, float fov, float aspect, float zNear, float zFar){ - this->pos = pos; - this->forward = glm::vec3(0.0f, 0.0f, -1.0f); - this->up = glm::vec3(0.0f, 1.0f, 0.0f); - this->projection = glm::perspective(fov, aspect, zNear, zFar); + this->pos = pos; + this->forward = glm::vec3(0.0f, 0.0f, -1.0f); + this->up = glm::vec3(0.0f, 1.0f, 0.0f); + this->projection = glm::perspective(fov, aspect, zNear, zFar); } inline glm::mat4 GetViewProjection() const { - return projection * glm::lookAt(pos, pos + forward, up); + return projection * glm::lookAt(pos, pos + forward, up); } void MoveForward(){ - pos += forward * amt; + pos += forward * MOVE_AMOUNT; } void MoveBackward(){ - pos += forward * -amt; + pos += forward * -MOVE_AMOUNT; } void MoveRight(){ - pos += -glm::cross(up, forward) * amt; + pos += -glm::cross(up, forward) * MOVE_AMOUNT; } void MoveLeft(){ - pos += glm::cross(up, forward) * amt; + pos += glm::cross(up, forward) * MOVE_AMOUNT; } void MoveUp(){ - pos += glm::vec3(0,.2,0); + pos += glm::vec3(0,MOVE_AMOUNT,0); } void MoveDown(){ - pos -= glm::vec3(0,.2,0); + pos -= glm::vec3(0,MOVE_AMOUNT,0); } void Pitch(float angle){ - glm::vec3 right = glm::normalize(glm::cross(up, forward)); + glm::vec3 right = glm::normalize(glm::cross(up, forward)); - forward = glm::vec3(glm::normalize(glm::rotate(angle, right) * glm::vec4(forward, 0.0))); - up = glm::normalize(glm::cross(forward, right)); + forward = glm::vec3(glm::normalize(glm::rotate(angle, right) * glm::vec4(forward, 0.0))); + up = glm::normalize(glm::cross(forward, right)); } private: - float amt = .2; - glm::mat4 projection; - glm::vec3 pos; - glm::vec3 forward; - glm::vec3 up; + glm::mat4 projection; + glm::vec3 pos; + glm::vec3 forward; + glm::vec3 up; }; #endif diff --git a/inc/opengl/geoshader.hpp b/inc/opengl/geoshader.hpp index 2619a92..d068a55 100644 --- a/inc/opengl/geoshader.hpp +++ b/inc/opengl/geoshader.hpp @@ -5,7 +5,6 @@ #include #include "constants.hpp" -#include "graphicsdata.hpp" #include "transform.hpp" class GeoShader @@ -13,10 +12,10 @@ class GeoShader public: GeoShader(const std::string& fileName); - void Bind(); - void Update(const Transform& transform, const Camera& camera); - virtual ~GeoShader(); - GLuint m_program; + void Bind(); + void Update(const Transform& transform, const Camera& camera); + virtual ~GeoShader(); + GLuint m_program; private: std::string LoadShader(const std::string& fileName); diff --git a/inc/opengl/graphicsdata.hpp b/inc/opengl/graphicsdata.hpp index df8d76e..a0398dc 100644 --- a/inc/opengl/graphicsdata.hpp +++ b/inc/opengl/graphicsdata.hpp @@ -1,49 +1,33 @@ #ifndef graphicsdata_h #define graphicsdata_h -#include -#include - -#include "camera.hpp" - class GraphicsData { - public: - - float x; - float y; - float r; - float g; - float b; - float sides; - - GraphicsData(){ - this->x = 0; - this->y = 0; - this->r = 0; - this->g = 0; - this->b = 0; - this->sides = 0; - } - - - GraphicsData(float x,float y,float r,float g,float b,float sides){ - this->x = 0; - this->y = 0; - this->r = 0; - this->g = 0; - this->b = 0; - this->sides = 0; - } - - float getX(){ - return x; - } - - float getY(){ - return y; - } - + public: + GraphicsData(){ + this->x = 0; + this->y = 0; + this->r = 0; + this->g = 0; + this->b = 0; + this->sides = 0; + } + + GraphicsData(float x1, float y1, float r1, float g1, float b1, float sides1){ + this->x = x1; + this->y = y1; + this->r = r1; + this->g = g1; + this->b = b1; + this->sides = sides1; + } + + float x; + float y; + float r; + float g; + float b; + float sides; }; #endif -- cgit v1.2.3