diff --git a/OpenGLEngine/Application.cpp b/OpenGLEngine/Application.cpp index 642e255..a2672f9 100644 --- a/OpenGLEngine/Application.cpp +++ b/OpenGLEngine/Application.cpp @@ -46,9 +46,6 @@ Application::Application(int width, int height) m_fps.prepare(); } - -Application::~Application() {} - int Application::run() { try diff --git a/OpenGLEngine/Application.h b/OpenGLEngine/Application.h index 1a6ee42..6de5f5f 100644 --- a/OpenGLEngine/Application.h +++ b/OpenGLEngine/Application.h @@ -15,7 +15,7 @@ class Application { public: Application(int width = -1, int height = -1); - virtual ~Application(); + virtual ~Application() {} int run(); diff --git a/OpenGLEngine/Camera2D.cpp b/OpenGLEngine/Camera2D.cpp index ba9a8bc..9673013 100644 --- a/OpenGLEngine/Camera2D.cpp +++ b/OpenGLEngine/Camera2D.cpp @@ -24,7 +24,6 @@ void Camera2D::update_position(const vec3& position) Poseable::update_position(-position); } -// TODO: Inline? void Camera2D::translate(const vec2& position) { translate(vec3(position.x, position.y, 0.0f)); diff --git a/OpenGLEngine/Camera2D.h b/OpenGLEngine/Camera2D.h index 3b0c0cb..6f77bc8 100644 --- a/OpenGLEngine/Camera2D.h +++ b/OpenGLEngine/Camera2D.h @@ -13,10 +13,10 @@ public: Camera2D(const vec3& size = vec3(2.0f, 2.0f, 2.0f), const vec3& position = vec3(0.0f, 0.0f, 0.0f)); void update_size(const vec3& size); - void update_position(const vec3& position) override; + void update_position(const vec3& position); void translate(const vec2& translation); - void translate(const vec3& translation) override; + void translate(const vec3& translation); const vec3& get_size() const { return m_size; } const vec3& get_position() const { return m_position; } diff --git a/OpenGLEngine/Camera3D.h b/OpenGLEngine/Camera3D.h index 39894ce..ced338e 100644 --- a/OpenGLEngine/Camera3D.h +++ b/OpenGLEngine/Camera3D.h @@ -24,7 +24,7 @@ public: void update_frustum(float fov_y, float aspect_ratio, float znear, float zfar); - void translate(const vec3& translation) override; + void translate(const vec3& translation); const vec3& get_position() const { return m_position; } vec3 get_forward() const { return vec3(m_orientation_matrix[2]); } diff --git a/OpenGLEngine/MyApplication.h b/OpenGLEngine/MyApplication.h index e9d7c0e..543cec9 100644 --- a/OpenGLEngine/MyApplication.h +++ b/OpenGLEngine/MyApplication.h @@ -11,6 +11,7 @@ class MyApplication : public: MyApplication(int width = -1, int height = -1); +protected: void init() override; void update(float delta_time, clock_t clock) override; diff --git a/OpenGLEngine/MyBatch.cpp b/OpenGLEngine/MyBatch.cpp index f1e509c..240db73 100644 --- a/OpenGLEngine/MyBatch.cpp +++ b/OpenGLEngine/MyBatch.cpp @@ -22,13 +22,10 @@ void MyBatch::setup_vao() glEnableVertexAttribArray(3); glEnableVertexAttribArray(4); glEnableVertexAttribArray(5); - - int orientation_location = offsetof(Poseable, m_orientation_matrix); - - glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(orientation_location + 0 * sizeof(vec4))); - glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(orientation_location + 1 * sizeof(vec4))); - glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(orientation_location + 2 * sizeof(vec4))); - glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(orientation_location + 3 * sizeof(vec4))); + glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(0 * sizeof(vec4))); + glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(1 * sizeof(vec4))); + glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(2 * sizeof(vec4))); + glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(3 * sizeof(vec4))); glVertexAttribDivisor(0, 0); // Only need to send the mesh data once (This should probably be done every time) glVertexAttribDivisor(1, 1); // Send the color data for each instance drawn diff --git a/OpenGLEngine/Poseable.h b/OpenGLEngine/Poseable.h index e2ebd00..3c38a91 100644 --- a/OpenGLEngine/Poseable.h +++ b/OpenGLEngine/Poseable.h @@ -15,15 +15,15 @@ public: const vec3& right = vec3(1.0f, 0.0f, 0.0f) ); - virtual void update_position(const vec3& position); + void update_position(const vec3& position); // Assumes that forward, up, and right are orthogonal and normalized - virtual void update_orientation(const vec3& forward, const vec3& up, const vec3& right); + void update_orientation(const vec3& forward, const vec3& up, const vec3& right); - virtual void translate(const vec3& translation); - virtual void rotate(const vec3& axis, float angle); + void translate(const vec3& translation); + void rotate(const vec3& axis, float angle); const mat4& get_orientation_matrix() const { return m_orientation_matrix; } - // Please dont use this. If you see it, tell michael that he is bad +protected: mat4 m_orientation_matrix; }; \ No newline at end of file