summaryrefslogtreecommitdiff
path: root/inc/opengl
diff options
context:
space:
mode:
authormajortom6 <tombarrett@siu.edu>2017-02-19 10:41:00 -0600
committerTom Barrett <tombarrett@siu.edu>2017-03-07 13:23:41 -0600
commitfcf6abaccec7c7ed2fd306a9cf1ec378f303297c (patch)
tree75d4df2b09346014e4784c2b597f0110a6b82e5b /inc/opengl
parent5c46e0f0a924989201c6784b0f956bc442f14a7e (diff)
-refractoring of includes
Diffstat (limited to 'inc/opengl')
-rw-r--r--inc/opengl/camera.hpp39
-rw-r--r--inc/opengl/geoshader.hpp9
-rw-r--r--inc/opengl/graphicsdata.hpp66
3 files changed, 49 insertions, 65 deletions
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 <GL/glew.h>
#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 <glm/glm.hpp>
-#include <glm/gtx/transform.hpp>
-
-#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