Use raw pointer of GLFWwindow instead shared_ptr

This commit is contained in:
SeanOMik 2021-12-02 16:56:49 -05:00
parent 539bd486e0
commit 794246eb02
4 changed files with 21 additions and 5 deletions

View File

@ -9,12 +9,12 @@
namespace simpleengine { namespace simpleengine {
class Event : public simpleengine::Destructable { class Event : public simpleengine::Destructable {
public: public:
explicit Event(std::shared_ptr<GLFWwindow> window = nullptr) : window(window) {} explicit Event(GLFWwindow* window = nullptr) : window(window) {}
virtual ~Event() = default; virtual ~Event() = default;
virtual void update(const float& delta_time) = 0; virtual void update(const float& delta_time) = 0;
virtual void render(std::shared_ptr<GLFWwindow> target) = 0; virtual void render(GLFWwindow* target) = 0;
protected: protected:
std::shared_ptr<GLFWwindow> window; GLFWwindow* window;
}; };
} }

View File

@ -4,7 +4,12 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#ifdef __linux__
#include <GL/glew.h>
#elif
#include <gl/glew.h> #include <gl/glew.h>
#endif
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "event/event.h" #include "event/event.h"
@ -35,14 +40,14 @@ namespace simpleengine {
int run(); int run();
//void AddEvent(Event* event); //void AddEvent(Event* event);
std::shared_ptr<GLFWwindow> get_window(); GLFWwindow* get_window();
private: private:
static void framebuffer_resize_callback(GLFWwindow*, int fbW, int fbH); static void framebuffer_resize_callback(GLFWwindow*, int fbW, int fbH);
void initialize(const int& gl_profile, const int& major_version, const int& minor_version, void initialize(const int& gl_profile, const int& major_version, const int& minor_version,
const bool& resizeable, const int& forward_compat = GL_TRUE); const bool& resizeable, const int& forward_compat = GL_TRUE);
std::shared_ptr<GLFWwindow> window; GLFWwindow* window;
std::vector<std::shared_ptr<simpleengine::Event>> events; std::vector<std::shared_ptr<simpleengine::Event>> events;
const bool& window_resizeable; const bool& window_resizeable;
}; };

View File

@ -1,8 +1,14 @@
#pragma once #pragma once
#include <chrono> #include <chrono>
#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>

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>