diff --git a/open_engine/include/open_engine.hpp b/open_engine/include/open_engine.hpp index 88b8eb2..bdd2244 100644 --- a/open_engine/include/open_engine.hpp +++ b/open_engine/include/open_engine.hpp @@ -16,6 +16,7 @@ #include "open_engine/input/keycodes.hpp" #include "open_engine/renderer/render_command.hpp" +#include "open_engine/renderer/subtexture2d.hpp" #include "open_engine/renderer/framebuffer.hpp" #include "open_engine/renderer/renderer2d.hpp" #include "open_engine/renderer/renderer.hpp" diff --git a/open_engine/include/open_engine/application.hpp b/open_engine/include/open_engine/application.hpp index 149e619..efb6ac1 100644 --- a/open_engine/include/open_engine/application.hpp +++ b/open_engine/include/open_engine/application.hpp @@ -13,7 +13,7 @@ namespace OpenEngine { class Application { public: - Application(); + Application(const std::string& name = "OpenEngine Project"); ~Application(); virtual void OnEvent(Event& event); @@ -26,7 +26,8 @@ namespace OpenEngine { inline static Application& Get() { return *instance; }; inline Window& GetWindow() { return *window; }; - inline void StopRunning() { running = false; }; + + void Close(); private: void Run(); @@ -34,6 +35,7 @@ namespace OpenEngine { bool OnWindowResize(WindowResizeEvent& event); private: + const std::string name; std::unique_ptr window; inline static Application* instance; diff --git a/open_engine/include/open_engine/input/input_system.hpp b/open_engine/include/open_engine/input/input_system.hpp index a909167..8adcb45 100644 --- a/open_engine/include/open_engine/input/input_system.hpp +++ b/open_engine/include/open_engine/input/input_system.hpp @@ -14,52 +14,25 @@ namespace OpenEngine { class Input { public: - virtual ~Input() = default; - Input(const Input&) = delete; - Input& operator=(const Input&) = delete; + static bool IsKeyPressed(KeyCode keycode); - inline static bool IsKeyPressed(KeyCode keycode) { return instance->IsKeyPressedImpl(keycode); }; + static bool IsMouseButtonPressed(MouseCode button); - inline static bool IsMouseButtonPressed(MouseCode button) { return instance->IsMouseButtonPressedImpl(button); }; + static std::pair GetMousePosition(); + static float GetMouseX(); + static float GetMouseY(); - inline static std::pair GetMousePosition() { return instance->GetMousePositionImpl(); }; - inline static bool GetMouseX() { return instance->GetMouseXImpl(); }; - inline static bool GetMouseY() { return instance->GetMouseYImpl(); }; + static bool JoystickExists(unsigned int joystick); + static std::map GetJoystickList(); - inline static bool JoystickExists(unsigned int joystick) { return instance->JoystickExistsImpl(joystick); }; - inline static std::map GetJoystickList() { return instance->GetJoystickListImpl(); }; + static float GetJoystickAxis(unsigned int joystick, unsigned int axis); + static const float* GetJoystickAxes(unsigned int joystick); + static unsigned int GetJoystickAxesCount(unsigned int joystick); - inline static float GetJoystickAxis(unsigned int joystick, unsigned int axis) { return instance->GetJoystickAxisImpl(joystick, axis); }; - inline static const float* GetJoystickAxes(unsigned int joystick) { return instance->GetJoystickAxesImpl(joystick); }; - inline static unsigned int GetJoystickAxesCount(unsigned int joystick) { return instance->GetJoystickAxesCountImpl(joystick); }; - - inline static bool IsJoystickButtonPressed(unsigned int joystick, unsigned int button) { return instance->IsJoystickButtonPressedImpl(joystick, button); }; - - protected: - Input() = default; - - virtual bool IsKeyPressedImpl(KeyCode keycode) = 0; - - virtual bool IsMouseButtonPressedImpl(MouseCode button) = 0; - - virtual std::pair GetMousePositionImpl() = 0; - virtual float GetMouseXImpl() = 0; - virtual float GetMouseYImpl() = 0; - - virtual bool JoystickExistsImpl(unsigned int joystick) = 0; - virtual std::map GetJoystickListImpl() = 0; - virtual const std::string GetJoystickNameImpl(unsigned int joystick) = 0; - - virtual float GetJoystickAxisImpl(unsigned int joystick, unsigned int axis) = 0; - virtual const float* GetJoystickAxesImpl(unsigned int joystick) = 0; - virtual unsigned int GetJoystickAxesCountImpl(unsigned int joystick) = 0; - - virtual bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) = 0; + static bool IsJoystickButtonPressed(unsigned int joystick, unsigned int button); private: - inline static const std::string GetJoystickName(unsigned int joystick) { return instance->GetJoystickNameImpl(joystick); }; - - static Scope instance; + static const std::string GetJoystickName(unsigned int joystick); }; } diff --git a/open_engine/include/open_engine/input/linux_input.hpp b/open_engine/include/open_engine/input/linux_input.hpp deleted file mode 100644 index 0841d08..0000000 --- a/open_engine/include/open_engine/input/linux_input.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef LINUX_INPUT_HPP -#define LINUX_INPUT_HPP - -#include "open_engine/input/input_system.hpp" -#include "open_engine/input/keycodes.hpp" - -namespace OpenEngine { - class LinuxInput : public Input - { - protected: - virtual bool IsKeyPressedImpl(KeyCode keycode) override; - - virtual bool IsMouseButtonPressedImpl(MouseCode button) override; - - virtual std::pair GetMousePositionImpl() override; - virtual float GetMouseXImpl() override; - virtual float GetMouseYImpl() override; - - virtual bool JoystickExistsImpl(unsigned int joystick) override; - - virtual float GetJoystickAxisImpl(unsigned int joystick, unsigned int axis) override; - virtual const std::string GetJoystickNameImpl(unsigned int joystick) override; - - virtual std::map GetJoystickListImpl() override; - virtual const float* GetJoystickAxesImpl(unsigned int joystick) override; - virtual unsigned int GetJoystickAxesCountImpl(unsigned int joystick) override; - - virtual bool IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) override; - }; -} - -#endif // LINUX_INPUT_HPP diff --git a/open_engine/include/open_engine/renderer/renderer2d.hpp b/open_engine/include/open_engine/renderer/renderer2d.hpp index 5b265cf..f66f024 100644 --- a/open_engine/include/open_engine/renderer/renderer2d.hpp +++ b/open_engine/include/open_engine/renderer/renderer2d.hpp @@ -2,6 +2,7 @@ #define RENDERER2D_HPP #include "open_engine/orthographic_camera.hpp" +#include "open_engine/renderer/subtexture2d.hpp" #include "open_engine/renderer/texture.hpp" #include "open_engine/ref_scope.hpp" @@ -36,6 +37,7 @@ namespace OpenEngine { static void DrawQuad(const Transform& transform_data, const glm::vec4& color); static void DrawQuad(const Transform& transform_data, const Ref& texture, float tiling_factor = 1.0f); + static void DrawQuad(const Transform& transform_data, const Ref& subtexture, float tiling_factor = 1.0f); static void ResetStats(); static const Statistics& GetStats(); diff --git a/open_engine/include/open_engine/renderer/subtexture2d.hpp b/open_engine/include/open_engine/renderer/subtexture2d.hpp new file mode 100644 index 0000000..6a5e34e --- /dev/null +++ b/open_engine/include/open_engine/renderer/subtexture2d.hpp @@ -0,0 +1,28 @@ +#ifndef SUBTEXTURE2D_HPP +#define SUBTEXTURE2D_HPP + +#include "open_engine/renderer/texture.hpp" + +#include + +namespace OpenEngine { + class Subtexture2D + { + public: + Subtexture2D(const Ref& texture, glm::vec2& min, glm::vec2& max); + + const Ref& GetTexture() { return atlas; }; + const glm::vec2* GetCoords() { return coords; }; + + static Ref CreateFromCoords(const Ref texture, + const glm::vec2& coordinates, + const glm::vec2& cell_size, + const glm::vec2& sprite_size = { 1.0f, 1.0f } ); + + private: + Ref atlas; + glm::vec2 coords[4]; + }; +} + +#endif // SUBTEXTURE2D_HPP diff --git a/open_engine/include/open_engine/window/window.hpp b/open_engine/include/open_engine/window/window.hpp index 2b64558..b119606 100644 --- a/open_engine/include/open_engine/window/window.hpp +++ b/open_engine/include/open_engine/window/window.hpp @@ -10,12 +10,12 @@ namespace OpenEngine { struct WindowProps { std::string title; - unsigned int width; - unsigned int height; + uint32_t width; + uint32_t height; WindowProps(const std::string& title = "OpenEngine", - unsigned int width = 1280, - unsigned int height = 729) + uint32_t width = 1280, + uint32_t height = 729) :title(title), width(width), height(height) { } @@ -29,7 +29,7 @@ namespace OpenEngine { struct WindowData { std::string title; - unsigned int width, height; + uint32_t width, height; bool vsync; EventCallbackFunction event_callback; @@ -39,8 +39,8 @@ namespace OpenEngine { virtual void OnUpdate() = 0; - virtual unsigned int GetWidth() const = 0; - virtual unsigned int GetHeight() const = 0; + virtual uint32_t GetWidth() const = 0; + virtual uint32_t GetHeight() const = 0; virtual void SetEventCallback(const EventCallbackFunction& callback) = 0; virtual void SetVSync(bool enabled) = 0; diff --git a/open_engine/src/open_engine/application.cpp b/open_engine/src/open_engine/application.cpp index 4be793f..ec8d2da 100755 --- a/open_engine/src/open_engine/application.cpp +++ b/open_engine/src/open_engine/application.cpp @@ -13,14 +13,15 @@ #include namespace OpenEngine { - Application::Application() + Application::Application(const std::string& name) + : name(name) { OE_PROFILE_FUNCTION(); OE_CORE_ASSERT(!instance, "Application already exists!"); instance = this; - window = Window::Create(); + window = Window::Create(WindowProps(name)); window->SetEventCallback(BIND_EVENT_FN(Application::OnEvent)); { @@ -90,11 +91,16 @@ namespace OpenEngine { bool Application::OnWindowClose(WindowCloseEvent& event) { - running = false; + Close(); return true; } + void Application::Close() + { + running = false; + } + bool Application::OnWindowResize(WindowResizeEvent& event) { OE_PROFILE_FUNCTION(); diff --git a/open_engine/src/open_engine/imgui/imgui_layer.cpp b/open_engine/src/open_engine/imgui/imgui_layer.cpp index d54c7b0..16822cf 100644 --- a/open_engine/src/open_engine/imgui/imgui_layer.cpp +++ b/open_engine/src/open_engine/imgui/imgui_layer.cpp @@ -340,8 +340,10 @@ namespace OpenEngine { void ImGuiLayer::OnEvent(Event& event) { + /* ImGuiIO& io = ImGui::GetIO(); event.handled |= event.IsInCategory(EventCategoryMouse) & io.WantCaptureMouse; event.handled |= event.IsInCategory(EventCategoryKeyboard) & io.WantCaptureKeyboard; + */ } } diff --git a/open_engine/src/open_engine/input/linux_input.cpp b/open_engine/src/open_engine/input/glfw_input.cpp similarity index 70% rename from open_engine/src/open_engine/input/linux_input.cpp rename to open_engine/src/open_engine/input/glfw_input.cpp index 1ca6c16..b1b0233 100644 --- a/open_engine/src/open_engine/input/linux_input.cpp +++ b/open_engine/src/open_engine/input/glfw_input.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include #include @@ -11,9 +11,7 @@ namespace OpenEngine { - Scope Input::instance = CreateScope(); - - bool LinuxInput::IsKeyPressedImpl(KeyCode keycode) + bool Input::IsKeyPressed(KeyCode keycode) { auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); auto state = glfwGetKey(window, static_cast(keycode)); @@ -21,7 +19,7 @@ namespace OpenEngine { return state == GLFW_PRESS || state == GLFW_REPEAT; } - bool LinuxInput::IsMouseButtonPressedImpl(MouseCode keycode) + bool Input::IsMouseButtonPressed(MouseCode keycode) { auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); auto state = glfwGetMouseButton(window, static_cast(keycode)); @@ -29,7 +27,7 @@ namespace OpenEngine { return state == GLFW_PRESS; } - std::pair LinuxInput::GetMousePositionImpl() + std::pair Input::GetMousePosition() { auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); @@ -39,16 +37,16 @@ namespace OpenEngine { return {(float)x, (float)y}; } - float LinuxInput::GetMouseXImpl() + float Input::GetMouseX() { - auto [x, y] = GetMousePositionImpl(); + auto [x, y] = GetMousePosition(); return (float)x; } - float LinuxInput::GetMouseYImpl() + float Input::GetMouseY() { - auto [x, y] = GetMousePositionImpl(); + auto [x, y] = GetMousePosition(); return (float)y; @@ -56,16 +54,16 @@ namespace OpenEngine { auto axes = glfwGetJoystickAxes(0, &count); } - bool LinuxInput::JoystickExistsImpl(unsigned int joystick) + bool Input::JoystickExists(unsigned int joystick) { bool status = glfwJoystickPresent(joystick); return status; } - const float* LinuxInput::GetJoystickAxesImpl(unsigned int joystick) + const float* Input::GetJoystickAxes(unsigned int joystick) { - if (!JoystickExistsImpl(joystick)) { + if (!JoystickExists(joystick)) { OE_CORE_WARN("Joystick number {} is not present.", joystick); return nullptr; } @@ -76,9 +74,9 @@ namespace OpenEngine { return axes; } - float LinuxInput::GetJoystickAxisImpl(unsigned int joystick, unsigned int axis) + float Input::GetJoystickAxis(unsigned int joystick, unsigned int axis) { - if (!JoystickExistsImpl(joystick)) { + if (!JoystickExists(joystick)) { OE_CORE_WARN("Joystick number {} is not present.", joystick); return 0.0f; } @@ -94,7 +92,7 @@ namespace OpenEngine { return axes[axis]; } - const std::string LinuxInput::GetJoystickNameImpl(unsigned int joystick) + const std::string Input::GetJoystickName(unsigned int joystick) { auto name = glfwGetJoystickName(joystick); @@ -106,7 +104,7 @@ namespace OpenEngine { return name; } - std::map LinuxInput::GetJoystickListImpl() + std::map Input::GetJoystickList() { std::map joysticks; @@ -120,9 +118,9 @@ namespace OpenEngine { return joysticks; } - unsigned int LinuxInput::GetJoystickAxesCountImpl(unsigned int joystick) + unsigned int Input::GetJoystickAxesCount(unsigned int joystick) { - if (!JoystickExistsImpl(joystick)) { + if (!JoystickExists(joystick)) { OE_CORE_WARN("Joystick number {} is not present.", joystick); return 0; } @@ -133,9 +131,9 @@ namespace OpenEngine { return count; } - bool LinuxInput::IsJoystickButtonPressedImpl(unsigned int joystick, unsigned int button) + bool Input::IsJoystickButtonPressed(unsigned int joystick, unsigned int button) { - if (!JoystickExistsImpl(joystick)) + if (!JoystickExists(joystick)) OE_CORE_WARN("Joystick number {} is not present.", joystick); int count; diff --git a/open_engine/src/open_engine/renderer/renderer2d.cpp b/open_engine/src/open_engine/renderer/renderer2d.cpp index fda780d..6bf5cc2 100755 --- a/open_engine/src/open_engine/renderer/renderer2d.cpp +++ b/open_engine/src/open_engine/renderer/renderer2d.cpp @@ -164,6 +164,9 @@ namespace OpenEngine { { OE_PROFILE_FUNCTION(); + constexpr size_t quad_vertex_count = 4; + constexpr glm::vec2 texture_coords[] = { { 0.0f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f }}; + if (renderer_data.quad_index_count >= Renderer2DData::max_indices) FlushAndReset(); @@ -193,33 +196,64 @@ namespace OpenEngine { * glm::rotate(glm::mat4(1.0f), glm::radians(transform_data.rotation), { 0.0f, 0.0f, 1.0f }) * glm::scale(glm::mat4(1.0f), transform_data.size); - renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[0]; - renderer_data.quad_vertex_ptr->color = color; - renderer_data.quad_vertex_ptr->tex_coord = { 0.0f, 0.0f }; - renderer_data.quad_vertex_ptr->tex_index = texture_index; - renderer_data.quad_vertex_ptr->tiling_factor = tiling_factor; - renderer_data.quad_vertex_ptr++; + for (size_t i = 0; i < quad_vertex_count; i++) { + renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[i]; + renderer_data.quad_vertex_ptr->color = color; + renderer_data.quad_vertex_ptr->tex_coord = texture_coords[i]; + renderer_data.quad_vertex_ptr->tex_index = texture_index; + renderer_data.quad_vertex_ptr->tiling_factor = tiling_factor; + renderer_data.quad_vertex_ptr++; + } - renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[1]; - renderer_data.quad_vertex_ptr->color = color; - renderer_data.quad_vertex_ptr->tex_coord = {1.0f, 0.0f}; - renderer_data.quad_vertex_ptr->tex_index = texture_index; - renderer_data.quad_vertex_ptr->tiling_factor = tiling_factor; - renderer_data.quad_vertex_ptr++; + renderer_data.quad_index_count += 6; + renderer_data.stats.quad_count++; + } - renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[2]; - renderer_data.quad_vertex_ptr->color = color; - renderer_data.quad_vertex_ptr->tex_coord = {1.0f, 1.0f}; - renderer_data.quad_vertex_ptr->tex_index = texture_index; - renderer_data.quad_vertex_ptr->tiling_factor = tiling_factor; - renderer_data.quad_vertex_ptr++; + void Renderer2D::DrawQuad(const Transform& transform_data, const Ref& subtexture, float tiling_factor) + { + OE_PROFILE_FUNCTION(); - renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[3]; - renderer_data.quad_vertex_ptr->color = color; - renderer_data.quad_vertex_ptr->tex_coord = {0.0f, 1.0f}; - renderer_data.quad_vertex_ptr->tex_index = texture_index; - renderer_data.quad_vertex_ptr->tiling_factor = tiling_factor; - renderer_data.quad_vertex_ptr++; + constexpr size_t quad_vertex_count = 4; + const glm::vec2* texture_coords = subtexture->GetCoords(); + const Ref& texture = subtexture->GetTexture(); + + if (renderer_data.quad_index_count >= Renderer2DData::max_indices) + FlushAndReset(); + + constexpr glm::vec4 color = glm::vec4(1.0f); + + glm::vec3 position = transform_data.position; + glm::vec3 size = transform_data.size; + + float texture_index = 0; + for (uint32_t i = 1; i < renderer_data.texture_slot_index; i++) { + if (*renderer_data.texture_slots[i].get() == *texture.get()) { + texture_index = (float)i; + break; + } + } + + if (texture_index == 0) { + if (renderer_data.texture_slot_index >= Renderer2DData::max_texture_slots) + FlushAndReset(); + + texture_index = (float)renderer_data.texture_slot_index; + renderer_data.texture_slots[renderer_data.texture_slot_index] = texture; + renderer_data.texture_slot_index++; + } + + glm::mat4 transform = glm::translate(glm::mat4(1.0f), transform_data.position) + * glm::rotate(glm::mat4(1.0f), glm::radians(transform_data.rotation), { 0.0f, 0.0f, 1.0f }) + * glm::scale(glm::mat4(1.0f), transform_data.size); + + for (size_t i = 0; i < quad_vertex_count; i++) { + renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[i]; + renderer_data.quad_vertex_ptr->color = color; + renderer_data.quad_vertex_ptr->tex_coord = texture_coords[i]; + renderer_data.quad_vertex_ptr->tex_index = texture_index; + renderer_data.quad_vertex_ptr->tiling_factor = tiling_factor; + renderer_data.quad_vertex_ptr++; + } renderer_data.quad_index_count += 6; renderer_data.stats.quad_count++; @@ -229,6 +263,9 @@ namespace OpenEngine { { OE_PROFILE_FUNCTION(); + constexpr size_t quad_vertex_count = 4; + constexpr glm::vec2 texture_coords[] = { { 0.0f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f }}; + if (renderer_data.quad_index_count >= Renderer2DData::max_indices) FlushAndReset(); @@ -239,33 +276,15 @@ namespace OpenEngine { * glm::rotate(glm::mat4(1.0f), glm::radians(transform_data.rotation), { 0.0f, 0.0f, 1.0f }) * glm::scale(glm::mat4(1.0f), transform_data.size); - renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[0]; - renderer_data.quad_vertex_ptr->color = color; - renderer_data.quad_vertex_ptr->tex_coord = { 0.0f, 0.0f }; - renderer_data.quad_vertex_ptr->tex_index = 0; - renderer_data.quad_vertex_ptr->tiling_factor = 0; - renderer_data.quad_vertex_ptr++; - renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[1]; - renderer_data.quad_vertex_ptr->color = color; - renderer_data.quad_vertex_ptr->tex_coord = {1.0f, 0.0f}; - renderer_data.quad_vertex_ptr->tex_index = 0; - renderer_data.quad_vertex_ptr->tiling_factor = 0; - renderer_data.quad_vertex_ptr++; - - renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[2]; - renderer_data.quad_vertex_ptr->color = color; - renderer_data.quad_vertex_ptr->tex_coord = {1.0f, 1.0f}; - renderer_data.quad_vertex_ptr->tex_index = 0; - renderer_data.quad_vertex_ptr->tiling_factor = 0; - renderer_data.quad_vertex_ptr++; - - renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[3]; - renderer_data.quad_vertex_ptr->color = color; - renderer_data.quad_vertex_ptr->tex_coord = {0.0f, 1.0f}; - renderer_data.quad_vertex_ptr->tex_index = 0; - renderer_data.quad_vertex_ptr->tiling_factor = 0; - renderer_data.quad_vertex_ptr++; + for (size_t i = 0; i < quad_vertex_count; i++) { + renderer_data.quad_vertex_ptr->position = transform * renderer_data.quad_vertex_positioning[i]; + renderer_data.quad_vertex_ptr->color = color; + renderer_data.quad_vertex_ptr->tex_coord = texture_coords[i]; + renderer_data.quad_vertex_ptr->tex_index = 0; + renderer_data.quad_vertex_ptr->tiling_factor = 1.0f; + renderer_data.quad_vertex_ptr++; + } renderer_data.quad_index_count += 6; renderer_data.stats.quad_count++; diff --git a/open_engine/src/open_engine/renderer/subtexture2d.cpp b/open_engine/src/open_engine/renderer/subtexture2d.cpp new file mode 100644 index 0000000..2a5230b --- /dev/null +++ b/open_engine/src/open_engine/renderer/subtexture2d.cpp @@ -0,0 +1,27 @@ +#include + +#include + +#include + +namespace OpenEngine { + Subtexture2D::Subtexture2D(const Ref& texture, glm::vec2& min, glm::vec2& max) + : atlas(texture) + { + coords[0] = { min.x, min.y }; + coords[1] = { max.x, min.y }; + coords[2] = { max.x, max.y }; + coords[3] = { min.x, max.y }; + } + + Ref Subtexture2D::CreateFromCoords(const Ref texture, + const glm::vec2& coordinates, + const glm::vec2& cell_size, + const glm::vec2& sprite_size) + { + glm::vec2 min = { (coordinates.x * cell_size.x) / texture->GetWidth(), (coordinates.y * cell_size.y) / texture->GetHeight() }; + glm::vec2 max = { ((coordinates.x + sprite_size.x) * cell_size.x) / texture->GetWidth(), ((coordinates.y + sprite_size.y) * cell_size.y) / texture->GetHeight() }; + + return CreateRef(texture, min, max); + } +} diff --git a/open_engine/src/open_engine/window/linux_window.cpp b/open_engine/src/open_engine/window/linux_window.cpp index 6138ebb..ca02e66 100644 --- a/open_engine/src/open_engine/window/linux_window.cpp +++ b/open_engine/src/open_engine/window/linux_window.cpp @@ -121,7 +121,7 @@ namespace OpenEngine { } }); - glfwSetCharCallback(gl_window, [] (GLFWwindow* window, unsigned int keycode) + glfwSetCharCallback(gl_window, [] (GLFWwindow* window, uint32_t keycode) { WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);