From 779df14f6775274fa285a82f2e8a5ef8dea4b250 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Thu, 2 Dec 2021 16:58:15 -0500 Subject: [PATCH] Forgot to push all code for last commit --- include/simpleengine/gfx/vao.h | 7 ++++++- include/simpleengine/gfx/vbo.h | 7 ++++++- include/simpleengine/renderable.h | 2 +- include/simpleengine/shader_program.h | 7 ++++++- include/simpleengine/shapes/2d/square.h | 7 ++++++- include/simpleengine/shapes/2d/triangle.h | 7 ++++++- include/simpleengine/vector.h | 6 +++--- include/simpleengine/vertex.h | 5 +++++ src/game.cpp | 25 ++++++++++++++--------- src/shapes/2d/square.cpp | 2 +- src/shapes/2d/triangle.cpp | 2 +- 11 files changed, 56 insertions(+), 21 deletions(-) diff --git a/include/simpleengine/gfx/vao.h b/include/simpleengine/gfx/vao.h index 975c17c..ad86891 100644 --- a/include/simpleengine/gfx/vao.h +++ b/include/simpleengine/gfx/vao.h @@ -1,7 +1,12 @@ #pragma once +#ifdef __linux__ +#include +#include +#elif #include -#include +#include +#endif #include "vbo.h" diff --git a/include/simpleengine/gfx/vbo.h b/include/simpleengine/gfx/vbo.h index 02bc18a..73fab84 100644 --- a/include/simpleengine/gfx/vbo.h +++ b/include/simpleengine/gfx/vbo.h @@ -1,7 +1,12 @@ #pragma once +#ifdef __linux__ +#include +#include +#elif #include -#include +#include +#endif namespace simpleengine::gfx { class VBO { diff --git a/include/simpleengine/renderable.h b/include/simpleengine/renderable.h index ceccdcd..a093a58 100644 --- a/include/simpleengine/renderable.h +++ b/include/simpleengine/renderable.h @@ -11,7 +11,7 @@ namespace simpleengine { private: using super = simpleengine::Event; public: - explicit Renderable(std::shared_ptr window = nullptr) : super(window) {} + explicit Renderable(GLFWwindow* window = nullptr) : super(window) {} virtual ~Renderable() = default; }; } \ No newline at end of file diff --git a/include/simpleengine/shader_program.h b/include/simpleengine/shader_program.h index 12ad2b9..8253cd9 100644 --- a/include/simpleengine/shader_program.h +++ b/include/simpleengine/shader_program.h @@ -1,7 +1,12 @@ #pragma once +#ifdef __linux__ +#include +#include +#elif #include #include +#endif #include @@ -104,7 +109,7 @@ namespace simpleengine { } - virtual void render(std::shared_ptr target) { + virtual void render(GLFWwindow* target) { glUseProgram(*program); } diff --git a/include/simpleengine/shapes/2d/square.h b/include/simpleengine/shapes/2d/square.h index 33d4bf5..ce1c207 100644 --- a/include/simpleengine/shapes/2d/square.h +++ b/include/simpleengine/shapes/2d/square.h @@ -1,7 +1,12 @@ #pragma once +#ifdef __linux__ +#include +#include +#elif #include #include +#endif #include @@ -44,6 +49,6 @@ namespace simpleengine::shapes_2d { virtual void update(const float& delta_time) override; - virtual void render(std::shared_ptr target) override; + virtual void render(GLFWwindow* target) override; }; } \ No newline at end of file diff --git a/include/simpleengine/shapes/2d/triangle.h b/include/simpleengine/shapes/2d/triangle.h index 4ae6a9d..dd1f8a3 100644 --- a/include/simpleengine/shapes/2d/triangle.h +++ b/include/simpleengine/shapes/2d/triangle.h @@ -1,7 +1,12 @@ #pragma once +#ifdef __linux__ +#include +#include +#elif #include #include +#endif #include @@ -40,6 +45,6 @@ namespace simpleengine::shapes_2d { void set_texture(gfx::Texture texture); virtual void update(const float& delta_time) override; - virtual void render(std::shared_ptr target) override; + virtual void render(GLFWwindow* target) override; }; } \ No newline at end of file diff --git a/include/simpleengine/vector.h b/include/simpleengine/vector.h index f2b73ec..e359a23 100644 --- a/include/simpleengine/vector.h +++ b/include/simpleengine/vector.h @@ -88,15 +88,15 @@ namespace simpleengine { } 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) { - 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) { - 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) { diff --git a/include/simpleengine/vertex.h b/include/simpleengine/vertex.h index 0992a0d..1c115fd 100644 --- a/include/simpleengine/vertex.h +++ b/include/simpleengine/vertex.h @@ -1,7 +1,12 @@ #pragma once +#ifdef __linux__ +#include +#include +#elif #include #include +#endif #include diff --git a/src/game.cpp b/src/game.cpp index 11c475d..7eae309 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3,29 +3,34 @@ #include +#ifdef __linux__ +#include +#include +#include +#elif #include #include - #include +#endif 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) { initialize(gl_profile, major_version, minor_version, window_resizeable, forward_compat); // Create a window - window = std::shared_ptr(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 (!resizeable) { int fbWidth; int fbHeight; - glfwGetFramebufferSize(window.get(), &fbWidth, &fbHeight); + glfwGetFramebufferSize(window, &fbWidth, &fbHeight); glViewport(0, 0, fbWidth, fbHeight); } else { - glfwSetFramebufferSizeCallback(window.get(), simpleengine::Game::framebuffer_resize_callback); + glfwSetFramebufferSizeCallback(window, simpleengine::Game::framebuffer_resize_callback); } - glfwMakeContextCurrent(window.get()); + glfwMakeContextCurrent(window); glewExperimental = GL_TRUE; @@ -48,7 +53,7 @@ void simpleengine::Game::initialize(const int& gl_profile, const int& major_vers } simpleengine::Game::~Game() { - + glfwDestroyWindow(window); } void simpleengine::Game::add_event(std::shared_ptr event) { @@ -81,7 +86,7 @@ void simpleengine::Game::render_items() { } int simpleengine::Game::run() { - while (!glfwWindowShouldClose(window.get())) { + while (!glfwWindowShouldClose(window)) { // Update input glfwPollEvents(); @@ -90,19 +95,19 @@ int simpleengine::Game::run() { render_window(); // End draw - glfwSwapBuffers(window.get()); + glfwSwapBuffers(window); glFlush(); } return 0; } -std::shared_ptr simpleengine::Game::get_window() { +GLFWwindow* simpleengine::Game::get_window() { return window; } void simpleengine::Game::exit() { - glfwSetWindowShouldClose(window.get(), true); + glfwSetWindowShouldClose(window, true); glfwTerminate(); } diff --git a/src/shapes/2d/square.cpp b/src/shapes/2d/square.cpp index a1df328..66d7a39 100644 --- a/src/shapes/2d/square.cpp +++ b/src/shapes/2d/square.cpp @@ -36,7 +36,7 @@ namespace simpleengine::shapes_2d { } - void Square::render(std::shared_ptr target) { + void Square::render(GLFWwindow* target) { shader.use(); // If theres a texture set, tell the fragment shader that and bind to the texture for drawing. diff --git a/src/shapes/2d/triangle.cpp b/src/shapes/2d/triangle.cpp index 2e81ce6..2a84bd0 100644 --- a/src/shapes/2d/triangle.cpp +++ b/src/shapes/2d/triangle.cpp @@ -43,7 +43,7 @@ namespace simpleengine::shapes_2d { } */ } - void Triangle::render(std::shared_ptr target) { + void Triangle::render(GLFWwindow* target) { shader.use(); if (texture.has_value()) {