Skip to content

Commit

Permalink
Fixed some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherrytree56567 committed Mar 23, 2024
1 parent 8dd358a commit c45bd72
Show file tree
Hide file tree
Showing 60 changed files with 245 additions and 578 deletions.
34 changes: 16 additions & 18 deletions Drizzle3D/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,21 @@ namespace Drizzle3D {
LayerDispatcher.DispatchLayerAttach();
}

void App::Run() {
while (!glfwWindowShouldClose(D3DWindow.returnwindow())) {
dispatch.ResetEvents();
std::unique_ptr<AppTickEvent> a = std::make_unique<AppTickEvent>();
dispatch.AddEvent(std::move(a));
D3DWindow.ProcessEvents();
std::unique_ptr<AppUpdateEvent> b = std::make_unique<AppUpdateEvent>();
dispatch.AddEvent(std::move(b));
update(this);
dispatch.DispatchEvent(D3DWindow.returnwindow());
std::unique_ptr<AppRenderEvent> r = std::make_unique<AppRenderEvent>();
dispatch.AddEvent(std::move(r));
D3DWindow.Render();
LayerDispatcher.DispatchLayerRender();
D3DWindow.clearKeyCodes();
D3DWindow.clearKeyReleasedCodes();
dispatch.ResetEvents();
}
bool App::Run() {
dispatch.ResetEvents();
std::unique_ptr<AppTickEvent> a = std::make_unique<AppTickEvent>();
dispatch.AddEvent(std::move(a));
D3DWindow.ProcessEvents();
std::unique_ptr<AppUpdateEvent> b = std::make_unique<AppUpdateEvent>();
dispatch.AddEvent(std::move(b));
dispatch.DispatchEvent(D3DWindow.returnwindow());
std::unique_ptr<AppRenderEvent> r = std::make_unique<AppRenderEvent>();
dispatch.AddEvent(std::move(r));
D3DWindow.Render();
LayerDispatcher.DispatchLayerRender();
D3DWindow.clearKeyCodes();
D3DWindow.clearKeyReleasedCodes();
dispatch.ResetEvents();
return !glfwWindowShouldClose(D3DWindow.returnwindow());
}
}
5 changes: 1 addition & 4 deletions Drizzle3D/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ namespace Drizzle3D {
public:
Drizzle3D_API App(char* WindowName = (char*)"New Drizzle3D Game", int width = 800, int height = 600);

Drizzle3D_API void Run();
Drizzle3D_API bool Run();

Drizzle3D_API Window* window() { return &D3DWindow; }
Drizzle3D_API std::shared_ptr<ImGuiLayer> ImguiLayer() { return imguilayer; }
Drizzle3D_API std::shared_ptr<RenderingLayer> GetRenderingLayer() { return renderinglayer; }
Drizzle3D_API std::shared_ptr<ResourceManager> GetResourceManager() { return resourcemgr; }
Drizzle3D_API EventDispatcher* dispatcher() { return &dispatch; }

typedef void(*UpdateFunc)(App* myApp);
UpdateFunc update = [](App* myApp){};

private:
// Managers
std::shared_ptr<ResourceManager> resourcemgr;
Expand Down
52 changes: 26 additions & 26 deletions Drizzle3D/AppEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,64 @@
#include "Events.h"

namespace Drizzle3D {
class Drizzle3D_API WindowResizeEvent : public Event {
class WindowResizeEvent : public Event {
public:
WindowResizeEvent(unsigned int width, unsigned int height) : m_Width(width), m_Height(height) {}
Drizzle3D_API WindowResizeEvent(unsigned int width, unsigned int height) : m_Width(width), m_Height(height) {}

unsigned int GetWidth() const { return m_Width; }
unsigned int GetHeight() const { return m_Height; }
Drizzle3D_API unsigned int GetWidth() const { return m_Width; }
Drizzle3D_API unsigned int GetHeight() const { return m_Height; }

EventType GetEventType() override { return EventType::WindowResize; }
Drizzle3D_API EventType GetEventType() override { return EventType::WindowResize; }
private:
unsigned int m_Width, m_Height;
};

class Drizzle3D_API WindowMoveEvent : public Event {
class WindowMoveEvent : public Event {
public:
WindowMoveEvent(unsigned int x, unsigned int y) : m_x(x), m_y(y) {}
Drizzle3D_API WindowMoveEvent(unsigned int x, unsigned int y) : m_x(x), m_y(y) {}

unsigned int GetWidth() const { return m_x; }
unsigned int GetHeight() const { return m_y; }
EventType GetEventType() override { return EventType::WindowMoved; }
Drizzle3D_API unsigned int GetWidth() const { return m_x; }
Drizzle3D_API unsigned int GetHeight() const { return m_y; }
Drizzle3D_API EventType GetEventType() override { return EventType::WindowMoved; }
private:
unsigned int m_x, m_y;
};

class Drizzle3D_API WindowFocusEvent : public Event {
class WindowFocusEvent : public Event {
public:
WindowFocusEvent(bool isFocused) : m_is_focused(isFocused) {}
Drizzle3D_API WindowFocusEvent(bool isFocused) : m_is_focused(isFocused) {}

bool IsFocused() const { return m_is_focused; }
EventType GetEventType() override { return EventType::WindowFocus; }
Drizzle3D_API bool IsFocused() const { return m_is_focused; }
Drizzle3D_API EventType GetEventType() override { return EventType::WindowFocus; }
private:
bool m_is_focused;
};

class Drizzle3D_API WindowCloseEvent : public Event {
class WindowCloseEvent : public Event {
public:
WindowCloseEvent() = default;
Drizzle3D_API WindowCloseEvent() = default;

EventType GetEventType() override { return EventType::WindowClose; }
Drizzle3D_API EventType GetEventType() override { return EventType::WindowClose; }
};

class Drizzle3D_API AppTickEvent : public Event {
class AppTickEvent : public Event {
public:
AppTickEvent() = default;
Drizzle3D_API AppTickEvent() = default;

EventType GetEventType() override { return EventType::AppTick; }
Drizzle3D_API EventType GetEventType() override { return EventType::AppTick; }
};

class Drizzle3D_API AppUpdateEvent : public Event {
class AppUpdateEvent : public Event {
public:
AppUpdateEvent() = default;
Drizzle3D_API AppUpdateEvent() = default;

EventType GetEventType() override { return EventType::AppUpdate; }
Drizzle3D_API EventType GetEventType() override { return EventType::AppUpdate; }
};

class Drizzle3D_API AppRenderEvent : public Event {
class AppRenderEvent : public Event {
public:
AppRenderEvent() = default;
Drizzle3D_API AppRenderEvent() = default;

EventType GetEventType() override { return EventType::AppRender; }
Drizzle3D_API EventType GetEventType() override { return EventType::AppRender; }
};
}
34 changes: 17 additions & 17 deletions Drizzle3D/Events.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ namespace Drizzle3D {
MouseButtonPressed, MouseButtonReleased, MouseMoved, MouseScrolled
};

class Drizzle3D_API Event {
class Event {
public:
virtual ~Event() = default;
Drizzle3D_API virtual ~Event() = default;

bool Handled = false;

virtual EventType GetEventType() = 0;
Drizzle3D_API virtual EventType GetEventType() = 0;
};

class Drizzle3D_API EventDispatcher {
class EventDispatcher {
public:
EventDispatcher(const EventDispatcher&) = delete;
EventDispatcher& operator=(const EventDispatcher&) = delete;
EventDispatcher() = default;
EventDispatcher& operator=(EventDispatcher&&) = default;
EventDispatcher(EventDispatcher&&) = default;
Drizzle3D_API EventDispatcher(const EventDispatcher&) = delete;
Drizzle3D_API EventDispatcher& operator=(const EventDispatcher&) = delete;
Drizzle3D_API EventDispatcher() = default;
Drizzle3D_API EventDispatcher& operator=(EventDispatcher&&) = default;
Drizzle3D_API EventDispatcher(EventDispatcher&&) = default;
typedef void (*EventCallback)(GLFWwindow* app, std::unique_ptr<Event> events, std::any);
void AddEvent(std::unique_ptr<Event> newEvent);
std::unique_ptr<Event> GetEvent(EventType eventType);
void RemoveHandledEvents();
bool isUnhandledEvent(EventType eventType);
void ResetEvents() { events.clear(); }
void AddEventListener(EventType eventType, EventCallback callback, std::any a = NULL);
void RemoveEventListener(EventType eventType, EventCallback callback);
void DispatchEvent(GLFWwindow* window);
Drizzle3D_API void AddEvent(std::unique_ptr<Event> newEvent);
Drizzle3D_API std::unique_ptr<Event> GetEvent(EventType eventType);
Drizzle3D_API void RemoveHandledEvents();
Drizzle3D_API bool isUnhandledEvent(EventType eventType);
Drizzle3D_API void ResetEvents() { events.clear(); }
Drizzle3D_API void AddEventListener(EventType eventType, EventCallback callback, std::any a = NULL);
Drizzle3D_API void RemoveEventListener(EventType eventType, EventCallback callback);
Drizzle3D_API void DispatchEvent(GLFWwindow* window);
private:
std::vector<std::unique_ptr<Event>> events;
std::unordered_map<EventType, std::vector<std::pair<EventCallback, std::any>>> eventCallbacks;
Expand Down
4 changes: 2 additions & 2 deletions Drizzle3D/FirstPersonCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include "App.h"

namespace Drizzle3D {
class Drizzle3D_API FirstPersonCamera {
class FirstPersonCamera {
public:
FirstPersonCamera(std::shared_ptr<App> app);
Drizzle3D_API FirstPersonCamera(std::shared_ptr<App> app);

glm::vec3 position = glm::vec3(0, 0, 5);
float horizontalAngle = 0.0f;
Expand Down
22 changes: 11 additions & 11 deletions Drizzle3D/ImGuiLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ namespace Drizzle3D {
ImGuiSliderFlags flags = NULL;
};

class Drizzle3D_API ImGuiLayer : public Layer {
class ImGuiLayer : public Layer {
public:
ImGuiLayer(Window* window) : name("ImGUI"), show(true), pWindow(window) {}
Drizzle3D_API ImGuiLayer(Window* window) : name("ImGUI"), show(true), pWindow(window) {}

typedef void (*ImGUICode)(std::shared_ptr<ImGuiLayer> igui);

ImGUICode code = [](std::shared_ptr<ImGuiLayer> igui) {};

void OnAttach() override;
void OnDetach() { }
void Render() override;
Drizzle3D_API void OnAttach() override;
Drizzle3D_API void OnDetach() { }
Drizzle3D_API void Render() override;

bool IsShown() const override { return show; }
const std::string& GetName() const override { return name; }
void SetShow(bool value) override { show = value; }
void setIGUI(std::shared_ptr<ImGuiLayer> ig) { igui = ig; }
void IterateSliderFloat();
void GUISliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = NULL, int flags = NULL);
Drizzle3D_API bool IsShown() const override { return show; }
Drizzle3D_API const std::string& GetName() const override { return name; }
Drizzle3D_API void SetShow(bool value) override { show = value; }
Drizzle3D_API void setIGUI(std::shared_ptr<ImGuiLayer> ig) { igui = ig; }
Drizzle3D_API void IterateSliderFloat();
Drizzle3D_API void GUISliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = NULL, int flags = NULL);
ImGuiContext* imguiContext = NULL;

private:
Expand Down
16 changes: 8 additions & 8 deletions Drizzle3D/KeyEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@

namespace Drizzle3D {

class Drizzle3D_API KeyPressedEvent : public Event {
class KeyPressedEvent : public Event {
public:
KeyPressedEvent(const KeyCode keycode) : m_KeyCode(keycode) {}
Drizzle3D_API KeyPressedEvent(const KeyCode keycode) : m_KeyCode(keycode) {}

KeyCode GetKeyCode() { return m_KeyCode; }
Drizzle3D_API KeyCode GetKeyCode() { return m_KeyCode; }

EventType GetEventType() override { return EventType::KeyPressed; }
Drizzle3D_API EventType GetEventType() override { return EventType::KeyPressed; }
private:
KeyCode m_KeyCode;
};

class Drizzle3D_API KeyReleasedEvent : public Event {
class KeyReleasedEvent : public Event {
public:
KeyReleasedEvent(const KeyCode keycode) : m_KeyCode(keycode) {}
Drizzle3D_API KeyReleasedEvent(const KeyCode keycode) : m_KeyCode(keycode) {}

KeyCode GetKeyCode() { return m_KeyCode; }
Drizzle3D_API KeyCode GetKeyCode() { return m_KeyCode; }

EventType GetEventType() override { return EventType::KeyReleased; }
Drizzle3D_API EventType GetEventType() override { return EventType::KeyReleased; }
private:
KeyCode m_KeyCode;
};
Expand Down
6 changes: 3 additions & 3 deletions Drizzle3D/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include <GLFW/glfw3.h>

namespace Drizzle3D {
class Drizzle3D_API Material {
class Material {
public:
Material(std::shared_ptr<ResourceManager> resourcemgr, const char* fname, const char* fgname);
GLuint GetShaderProgram() { return shaderProgram; }
Drizzle3D_API Material(std::shared_ptr<ResourceManager> resourcemgr, const char* fname, const char* fgname);
Drizzle3D_API GLuint GetShaderProgram() { return shaderProgram; }
private:
GLuint shaderProgram;
};
Expand Down
36 changes: 18 additions & 18 deletions Drizzle3D/MouseEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,48 @@
#include "MouseCodes.h"

namespace Drizzle3D {
class Drizzle3D_API MouseMovedEvent : public Event {
class MouseMovedEvent : public Event {
public:
MouseMovedEvent(const float x, const float y) : m_MouseX(x), m_MouseY(y) {}
Drizzle3D_API MouseMovedEvent(const float x, const float y) : m_MouseX(x), m_MouseY(y) {}

float GetX() const { return m_MouseX; }
float GetY() const { return m_MouseY; }
Drizzle3D_API float GetX() const { return m_MouseX; }
Drizzle3D_API float GetY() const { return m_MouseY; }

EventType GetEventType() override { return EventType::MouseMoved; }
Drizzle3D_API EventType GetEventType() override { return EventType::MouseMoved; }
private:
float m_MouseX, m_MouseY;
};

class Drizzle3D_API MouseScrolledEvent : public Event {
class MouseScrolledEvent : public Event {
public:
MouseScrolledEvent(const float xOffset, const float yOffset) : m_XOffset(xOffset), m_YOffset(yOffset) {}
Drizzle3D_API MouseScrolledEvent(const float xOffset, const float yOffset) : m_XOffset(xOffset), m_YOffset(yOffset) {}

float GetXOffset() const { return m_XOffset; }
float GetYOffset() const { return m_YOffset; }
Drizzle3D_API float GetXOffset() const { return m_XOffset; }
Drizzle3D_API float GetYOffset() const { return m_YOffset; }

EventType GetEventType() override { return EventType::MouseScrolled; }
Drizzle3D_API EventType GetEventType() override { return EventType::MouseScrolled; }
private:
float m_XOffset, m_YOffset;
};

class Drizzle3D_API MouseButtonPressedEvent : public Event {
class MouseButtonPressedEvent : public Event {
public:
MouseButtonPressedEvent(const MouseCode button) : m_Button(button) {}
Drizzle3D_API MouseButtonPressedEvent(const MouseCode button) : m_Button(button) {}

MouseCode GetMouseButton() const { return m_Button; }
Drizzle3D_API MouseCode GetMouseButton() const { return m_Button; }

EventType GetEventType() override { return EventType::MouseButtonPressed; }
Drizzle3D_API EventType GetEventType() override { return EventType::MouseButtonPressed; }
private:
MouseCode m_Button;
};

class Drizzle3D_API MouseButtonReleasedEvent : public Event {
class MouseButtonReleasedEvent : public Event {
public:
MouseButtonReleasedEvent(const MouseCode button) : m_Button(button) {}
Drizzle3D_API MouseButtonReleasedEvent(const MouseCode button) : m_Button(button) {}

MouseCode GetMouseButton() const { return m_Button; }
Drizzle3D_API MouseCode GetMouseButton() const { return m_Button; }

EventType GetEventType() override { return EventType::MouseButtonReleased; }
Drizzle3D_API EventType GetEventType() override { return EventType::MouseButtonReleased; }
private:
MouseCode m_Button;
};
Expand Down
4 changes: 2 additions & 2 deletions Drizzle3D/RenderingLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ namespace Drizzle3D {
};

struct Object {
GLuint VertexArray, VertexBuffer, IndexBuffer;
GLuint VertexArray, VertexBuffer, IndexBuffer = 0;
std::vector<float> vertices;
std::vector<unsigned int> indices;
glm::mat4 modelMatrix;
GLuint textureID = NULL;
GLuint mat = 0;
char* name;
char* name = (char*)"PLZ_SPECIFY_A_NAME";
};

struct Camera {
Expand Down
10 changes: 5 additions & 5 deletions Drizzle3D/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ namespace Drizzle3D {
const char mode[2];
};

class Drizzle3D_API ResourceManager {
class ResourceManager {
public:
Resource loadFile(const std::string& filePath, const char mode[2]);
Drizzle3D_API Resource loadFile(const std::string& filePath, const char mode[2]);

bool fileExists(const std::string& filePath) const;
Drizzle3D_API bool fileExists(const std::string& filePath) const;

void writeFile(const std::string& filePath, const std::string& content);
Drizzle3D_API void writeFile(const std::string& filePath, const std::string& content);

std::string& getTempFileContent(const std::string& filePath);
Drizzle3D_API std::string& getTempFileContent(const std::string& filePath);
private:
std::unordered_map<std::string, std::string> resources;
};
Expand Down
Loading

0 comments on commit c45bd72

Please sign in to comment.