Forgot to push all code for last commit

This commit is contained in:
SeanOMik 2021-12-02 16:58:15 -05:00
parent 794246eb02
commit 779df14f67
11 changed files with 56 additions and 21 deletions

View File

@ -1,7 +1,12 @@
#pragma once #pragma once
#ifdef __linux__
#include <GL/glew.h>
#include <GL/gl.h>
#elif
#include <gl/glew.h> #include <gl/glew.h>
#include <gl/GL.h> #include <gl/gl.h>
#endif
#include "vbo.h" #include "vbo.h"

View File

@ -1,7 +1,12 @@
#pragma once #pragma once
#ifdef __linux__
#include <GL/glew.h>
#include <GL/gl.h>
#elif
#include <gl/glew.h> #include <gl/glew.h>
#include <gl/GL.h> #include <gl/gl.h>
#endif
namespace simpleengine::gfx { namespace simpleengine::gfx {
class VBO { class VBO {

View File

@ -11,7 +11,7 @@ namespace simpleengine {
private: private:
using super = simpleengine::Event; using super = simpleengine::Event;
public: public:
explicit Renderable(std::shared_ptr<GLFWwindow> window = nullptr) : super(window) {} explicit Renderable(GLFWwindow* window = nullptr) : super(window) {}
virtual ~Renderable() = default; virtual ~Renderable() = default;
}; };
} }

View File

@ -1,7 +1,12 @@
#pragma once #pragma once
#ifdef __linux__
#include <GL/glew.h>
#include <GL/gl.h>
#elif
#include <gl/glew.h> #include <gl/glew.h>
#include <gl/gl.h> #include <gl/gl.h>
#endif
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@ -104,7 +109,7 @@ namespace simpleengine {
} }
virtual void render(std::shared_ptr<GLFWwindow> target) { virtual void render(GLFWwindow* target) {
glUseProgram(*program); glUseProgram(*program);
} }

View File

@ -1,7 +1,12 @@
#pragma once #pragma once
#ifdef __linux__
#include <GL/glew.h>
#include <GL/gl.h>
#elif
#include <gl/glew.h> #include <gl/glew.h>
#include <gl/gl.h> #include <gl/gl.h>
#endif
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@ -44,6 +49,6 @@ namespace simpleengine::shapes_2d {
virtual void update(const float& delta_time) override; virtual void update(const float& delta_time) override;
virtual void render(std::shared_ptr<GLFWwindow> target) override; virtual void render(GLFWwindow* target) override;
}; };
} }

View File

@ -1,7 +1,12 @@
#pragma once #pragma once
#ifdef __linux__
#include <GL/glew.h>
#include <GL/gl.h>
#elif
#include <gl/glew.h> #include <gl/glew.h>
#include <gl/gl.h> #include <gl/gl.h>
#endif
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
@ -40,6 +45,6 @@ namespace simpleengine::shapes_2d {
void set_texture(gfx::Texture texture); void set_texture(gfx::Texture texture);
virtual void update(const float& delta_time) override; virtual void update(const float& delta_time) override;
virtual void render(std::shared_ptr<GLFWwindow> target) override; virtual void render(GLFWwindow* target) override;
}; };
} }

View File

@ -88,15 +88,15 @@ namespace simpleengine {
} }
static glm::mat4 rotation_x_matrix(float degrees) { static glm::mat4 rotation_x_matrix(float degrees) {
return rotation_axis(degrees, glm::vec3(1.f, 0.f, 0.f)); return rotation_matrix(degrees, glm::vec3(1.f, 0.f, 0.f));
} }
static glm::mat4 rotation_y_matrix(float degrees) { static glm::mat4 rotation_y_matrix(float degrees) {
return rotation_axis(degrees, glm::vec3(0.f, 1.f, 0.f)); return rotation_matrix(degrees, glm::vec3(0.f, 1.f, 0.f));
} }
static glm::mat4 rotation_z_matrix(float degrees) { static glm::mat4 rotation_z_matrix(float degrees) {
return rotation_axis(degrees, glm::vec3(0.f, 0.f, 1.f)); return rotation_matrix(degrees, glm::vec3(0.f, 0.f, 1.f));
} }
void rotate(float degrees, glm::vec3 rotation_axis) { void rotate(float degrees, glm::vec3 rotation_axis) {

View File

@ -1,7 +1,12 @@
#pragma once #pragma once
#ifdef __linux__
#include <GL/glew.h>
#include <GL/gl.h>
#elif
#include <gl/glew.h> #include <gl/glew.h>
#include <gl/gl.h> #include <gl/gl.h>
#endif
#include <glm/glm.hpp> #include <glm/glm.hpp>

View File

@ -3,29 +3,34 @@
#include <iostream> #include <iostream>
#ifdef __linux__
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <GL/gl.h>
#elif
#include <gl/glew.h> #include <gl/glew.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <gl/gl.h> #include <gl/gl.h>
#endif
simpleengine::Game::Game(int w, int h, const std::string& window_name, const int& gl_profile, const int& major_version, simpleengine::Game::Game(int w, int h, const std::string& window_name, const int& gl_profile, const int& major_version,
const int& minor_version, const bool& resizeable, const int& forward_compat) : window_resizeable(resizeable) { const int& minor_version, const bool& resizeable, const int& forward_compat) : window_resizeable(resizeable) {
initialize(gl_profile, major_version, minor_version, window_resizeable, forward_compat); initialize(gl_profile, major_version, minor_version, window_resizeable, forward_compat);
// Create a window // Create a window
window = std::shared_ptr<GLFWwindow>(glfwCreateWindow(w, h, window_name.c_str(), NULL, NULL)); window = glfwCreateWindow(w, h, window_name.c_str(), NULL, NULL);
// If we're not resizeable, we need to set the viewport size. // If we're not resizeable, we need to set the viewport size.
if (!resizeable) { if (!resizeable) {
int fbWidth; int fbWidth;
int fbHeight; int fbHeight;
glfwGetFramebufferSize(window.get(), &fbWidth, &fbHeight); glfwGetFramebufferSize(window, &fbWidth, &fbHeight);
glViewport(0, 0, fbWidth, fbHeight); glViewport(0, 0, fbWidth, fbHeight);
} else { } else {
glfwSetFramebufferSizeCallback(window.get(), simpleengine::Game::framebuffer_resize_callback); glfwSetFramebufferSizeCallback(window, simpleengine::Game::framebuffer_resize_callback);
} }
glfwMakeContextCurrent(window.get()); glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE; glewExperimental = GL_TRUE;
@ -48,7 +53,7 @@ void simpleengine::Game::initialize(const int& gl_profile, const int& major_vers
} }
simpleengine::Game::~Game() { simpleengine::Game::~Game() {
glfwDestroyWindow(window);
} }
void simpleengine::Game::add_event(std::shared_ptr<simpleengine::Event> event) { void simpleengine::Game::add_event(std::shared_ptr<simpleengine::Event> event) {
@ -81,7 +86,7 @@ void simpleengine::Game::render_items() {
} }
int simpleengine::Game::run() { int simpleengine::Game::run() {
while (!glfwWindowShouldClose(window.get())) { while (!glfwWindowShouldClose(window)) {
// Update input // Update input
glfwPollEvents(); glfwPollEvents();
@ -90,19 +95,19 @@ int simpleengine::Game::run() {
render_window(); render_window();
// End draw // End draw
glfwSwapBuffers(window.get()); glfwSwapBuffers(window);
glFlush(); glFlush();
} }
return 0; return 0;
} }
std::shared_ptr<GLFWwindow> simpleengine::Game::get_window() { GLFWwindow* simpleengine::Game::get_window() {
return window; return window;
} }
void simpleengine::Game::exit() { void simpleengine::Game::exit() {
glfwSetWindowShouldClose(window.get(), true); glfwSetWindowShouldClose(window, true);
glfwTerminate(); glfwTerminate();
} }

View File

@ -36,7 +36,7 @@ namespace simpleengine::shapes_2d {
} }
void Square::render(std::shared_ptr<GLFWwindow> target) { void Square::render(GLFWwindow* target) {
shader.use(); shader.use();
// If theres a texture set, tell the fragment shader that and bind to the texture for drawing. // If theres a texture set, tell the fragment shader that and bind to the texture for drawing.

View File

@ -43,7 +43,7 @@ namespace simpleengine::shapes_2d {
} */ } */
} }
void Triangle::render(std::shared_ptr<GLFWwindow> target) { void Triangle::render(GLFWwindow* target) {
shader.use(); shader.use();
if (texture.has_value()) { if (texture.has_value()) {