From a71d221ad99e2c582eb70d4e2576fae367c549d0 Mon Sep 17 00:00:00 2001 From: OusmBlueNinja <89956790+OusmBlueNinja@users.noreply.github.com> Date: Sat, 12 Apr 2025 21:01:08 -0500 Subject: [PATCH] Added Editor Camera --- build.log | 38 +++---- src/assets/scenes/test.cene | 37 ++++++- src/src/Components/CameraComponent.cpp | 28 +++-- src/src/Components/CameraComponent.h | 27 +++-- src/src/Engine.cpp | 148 +++++++++++++++++++------ src/src/Entitys/Object.cpp | 63 +++-------- src/src/Entitys/Object.h | 53 ++++++--- src/src/Renderer.cpp | 25 ++--- src/src/Renderer.h | 2 +- 9 files changed, 270 insertions(+), 151 deletions(-) diff --git a/build.log b/build.log index 8b7274a..93e9d33 100644 --- a/build.log +++ b/build.log @@ -1,5 +1,5 @@ -[COMPILE] g++ -std=c++20 -Wall -Isrc/include -Isrc/vendor -Isrc/vendor/imgui -IC:/msys64/mingw64/include -MMD -MP -c src\src\Engine.cpp -o src\build\src\Engine.osrc\src\Engine.cpp:23:9: warning: "NOMINMAX" redefined - 23 | #define NOMINMAX +[COMPILE] g++ -std=c++20 -Wall -Isrc/include -Isrc/vendor -Isrc/vendor/imgui -IC:/msys64/mingw64/include -MMD -MP -c src\src\Engine.cpp -o src\build\src\Engine.osrc\src\Engine.cpp:24:9: warning: "NOMINMAX" redefined + 24 | #define NOMINMAX | ^~~~~~~~ In file included from C:/msys64/mingw64/include/c++/14.2.0/x86_64-w64-mingw32/bits/c++config.h:680, from C:/msys64/mingw64/include/c++/14.2.0/bits/memoryfwd.h:48, @@ -11,32 +11,30 @@ C:/msys64/mingw64/include/c++/14.2.0/x86_64-w64-mingw32/bits/os_defines.h:45:9: | ^~~~~~~~ In file included from C:/msys64/mingw64/include/yaml-cpp/parser.h:13, from C:/msys64/mingw64/include/yaml-cpp/yaml.h:10, - from src\src\Entitys/Object.h:6, + from src\src\Entitys/Object.h:7, from src\src\Engine.cpp:2: C:/msys64/mingw64/include/yaml-cpp/dll.h:22:65: note: '#pragma message: Defining YAML_CPP_API for DLL import' 22 | # pragma message( "Defining YAML_CPP_API for DLL import" ) | ^ -[COMPILE] g++ -std=c++20 -Wall -Isrc/include -Isrc/vendor -Isrc/vendor/imgui -IC:/msys64/mingw64/include -MMD -MP -c src\src\Entitys\Object.cpp -o src\build\src\Entitys\Object.oIn file included from C:/msys64/mingw64/include/yaml-cpp/parser.h:13, +[COMPILE] g++ -std=c++20 -Wall -Isrc/include -Isrc/vendor -Isrc/vendor/imgui -IC:/msys64/mingw64/include -MMD -MP -c src\src\Renderer.cpp -o src\build\src\Renderer.oIn file included from C:/msys64/mingw64/include/yaml-cpp/parser.h:13, from C:/msys64/mingw64/include/yaml-cpp/yaml.h:10, - from src\src\Entitys\Object.h:6, - from src\src\Entitys\Object.cpp:1: + from src\src\Components/Component.h:5, + from src\src\Components/SpriteComponent.h:3, + from src\src\Renderer.cpp:2: C:/msys64/mingw64/include/yaml-cpp/dll.h:22:65: note: '#pragma message: Defining YAML_CPP_API for DLL import' 22 | # pragma message( "Defining YAML_CPP_API for DLL import" ) | ^ -src\src\Entitys\Object.h: In constructor 'Object::Object(const std::string&)': -src\src\Entitys\Object.h:48:15: warning: 'Object::localPosition' will be initialized after [-Wreorder] - 48 | glm::vec2 localPosition; - | ^~~~~~~~~~~~~ -src\src\Entitys\Object.h:41:9: warning: 'int Object::id' [-Wreorder] - 41 | int id; - | ^~ -src\src\Entitys\Object.cpp:10:1: warning: when initialized here [-Wreorder] - 10 | Object::Object(const std::string& name) - | ^~~~~~ -[LINK] g++ src\build\src\Engine.o src\build\src\main.o src\build\src\Renderer.o src\build\src\Components\SpriteComponent.o src\build\src\Entitys\Object.o src\build\src\utils\FileDialog.o src\build\src\utils\Shader.o src\build\vendor\imgui\imgui.o src\build\vendor\imgui\imgui_demo.o src\build\vendor\imgui\imgui_draw.o src\build\vendor\imgui\imgui_impl_glfw.o src\build\vendor\imgui\imgui_impl_opengl3.o src\build\vendor\imgui\imgui_tables.o src\build\vendor\imgui\imgui_widgets.o -o src\build\app.exe -LC:/msys64/mingw64/lib -lglfw3 -lglew32 -lopengl32 -lgdi32 -lyaml-cpp -lcomdlg32 -lssl -lcrypto +[COMPILE] g++ -std=c++20 -Wall -Isrc/include -Isrc/vendor -Isrc/vendor/imgui -IC:/msys64/mingw64/include -MMD -MP -c src\src\Components\CameraComponent.cpp -o src\build\src\Components\CameraComponent.oIn file included from C:/msys64/mingw64/include/yaml-cpp/parser.h:13, + from C:/msys64/mingw64/include/yaml-cpp/yaml.h:10, + from src\src\Components\Component.h:5, + from src\src\Components\CameraComponent.h:2, + from src\src\Components\CameraComponent.cpp:1: +C:/msys64/mingw64/include/yaml-cpp/dll.h:22:65: note: '#pragma message: Defining YAML_CPP_API for DLL import' + 22 | # pragma message( "Defining YAML_CPP_API for DLL import" ) + | ^ -[TIME] Build duration: 9.21s -[RUN] Executed app.exe successfully. -[TIME] Total runtime: 55.09s +[LINK] g++ src\build\src\Engine.o src\build\src\main.o src\build\src\Renderer.o src\build\src\Components\CameraComponent.o src\build\src\Components\SpriteComponent.o src\build\src\Entitys\Object.o src\build\src\utils\FileDialog.o src\build\src\utils\Shader.o src\build\vendor\imgui\imgui.o src\build\vendor\imgui\imgui_demo.o src\build\vendor\imgui\imgui_draw.o src\build\vendor\imgui\imgui_impl_glfw.o src\build\vendor\imgui\imgui_impl_opengl3.o src\build\vendor\imgui\imgui_tables.o src\build\vendor\imgui\imgui_widgets.o -o src\build\app.exe -LC:/msys64/mingw64/lib -lglfw3 -lglew32 -lopengl32 -lgdi32 -lyaml-cpp -lcomdlg32 -lssl -lcrypto + +[TIME] Build duration: 11.26s diff --git a/src/assets/scenes/test.cene b/src/assets/scenes/test.cene index fd7d54f..7262a71 100644 --- a/src/assets/scenes/test.cene +++ b/src/assets/scenes/test.cene @@ -1,12 +1,41 @@ engine_version: 0.1.0 scene_name: test -scene_hash: 2bef506b8552068aab28115edf9550411c1fab67befdc32a4946ec33da7a8021 +scene_hash: b3488ddfbb343e554cb1782c1b79598e15545d752cfec63be97f90c8d422aaf5 format_version: 1 objects: - - name: Face Image - position: [0, 0] + - name: Sprite Object + position: [438, 0] + layer: 0 + components: + - type: CameraComponent + fov: 45 + aspect: 1.76999998 + zoom: 1 + - type: SpriteComponent + texture: C:\Users\spenc\OneDrive\Pictures\49555.jpg + normalMap: "" + children: + - name: NewObject + position: [190, 189] + layer: 0 + components: + - type: SpriteComponent + texture: C:\Users\spenc\OneDrive\Pictures\49555.jpg + normalMap: "" + children: [] + - name: NewObject + position: [0, 444] + layer: 0 + components: + - type: SpriteComponent + texture: C:\Users\spenc\OneDrive\Pictures\49555.jpg + normalMap: "" + children: [] + - name: NewObject + position: [0, 444] + layer: 0 components: - type: SpriteComponent texture: C:\Users\spenc\OneDrive\Pictures\49555.jpg - normalMap: C:\Users\spenc\OneDrive\Pictures\49555.jpg + normalMap: "" children: [] \ No newline at end of file diff --git a/src/src/Components/CameraComponent.cpp b/src/src/Components/CameraComponent.cpp index 78107fc..e9c22de 100644 --- a/src/src/Components/CameraComponent.cpp +++ b/src/src/Components/CameraComponent.cpp @@ -1,19 +1,29 @@ #include "CameraComponent.h" +#include "../Entitys/Object.h" -CameraComponent::CameraComponent(Object* owner) - : Component(owner) {} +CameraComponent::CameraComponent(Object* owner) : Component(owner) {} -void CameraComponent::Save(YAML::Emitter& out) { +std::string CameraComponent::GetName() const { + return "CameraComponent"; +} + +void CameraComponent::Save(YAML::Emitter& out) const { out << YAML::BeginMap; - out << YAML::Key << "type" << YAML::Value << "CameraComponent"; - out << YAML::Key << "zoom" << YAML::Value << zoom; - out << YAML::Key << "aspectRatio" << YAML::Value << aspectRatio; + out << YAML::Key << "type" << YAML::Value << GetName(); out << YAML::Key << "fov" << YAML::Value << fov; + out << YAML::Key << "aspect" << YAML::Value << aspect; + out << YAML::Key << "zoom" << YAML::Value << zoom; + out << YAML::Key << "primary" << YAML::Value << primary; + + out << YAML::EndMap; } void CameraComponent::Load(const YAML::Node& node) { - zoom = node["zoom"] ? node["zoom"].as() : 1.0f; - aspectRatio = node["aspectRatio"] ? node["aspectRatio"].as() : 16.0f / 9.0f; - fov = node["fov"] ? node["fov"].as() : 45.0f; + if (node["fov"]) fov = node["fov"].as(); + if (node["aspect"]) aspect = node["aspect"].as(); + if (node["zoom"]) zoom = node["zoom"].as(); + if (node["primary"]) primary = node["primary"].as(); + + } diff --git a/src/src/Components/CameraComponent.h b/src/src/Components/CameraComponent.h index 9b6cae1..c6f38da 100644 --- a/src/src/Components/CameraComponent.h +++ b/src/src/Components/CameraComponent.h @@ -1,24 +1,35 @@ #pragma once #include "Component.h" #include -#include class CameraComponent : public Component { public: - float zoom = 1.0f; - float aspectRatio = 16.0f / 9.0f; - float fov = 45.0f; - CameraComponent(Object* owner); - void Save(YAML::Emitter& out) override; + std::string GetName() const override; + void Save(YAML::Emitter& out) const override; void Load(const YAML::Node& node) override; + + float GetZoom() const { return zoom; } - float GetAspectRatio() const { return aspectRatio; } + float GetAspect() const { return aspect; } float GetFOV() const { return fov; } + bool IsPrimary() const { return primary; } + void SetZoom(float z) { zoom = z; } - void SetAspectRatio(float a) { aspectRatio = a; } + void SetAspect(float a) { aspect = a; } void SetFOV(float f) { fov = f; } + void SetPrimary(bool p) { primary = p; } + + +private: + float zoom = 1.0f; + float fov = 45.0f; + float aspect = 1.77f; + bool primary = true; + }; + + diff --git a/src/src/Engine.cpp b/src/src/Engine.cpp index 1524c2b..52ec1ae 100644 --- a/src/src/Engine.cpp +++ b/src/src/Engine.cpp @@ -2,6 +2,8 @@ #include "Entitys/Object.h" #include "Renderer.h" #include "components/SpriteComponent.h" +#include "components/CameraComponent.h" + #include "utils/FileDialog.h" #include @@ -10,7 +12,6 @@ #include #include - #include #include #include @@ -28,6 +29,36 @@ static std::vector> objects; static std::shared_ptr selected = nullptr; static bool playing = false; + +struct EditorCamera +{ + glm::vec2 position = glm::vec2(0.0f); + float zoom = 1.0f; + + void HandleInput() + { + if (ImGui::IsWindowHovered()) + { + if (ImGui::IsMouseDragging(ImGuiMouseButton_Right)) + { + ImVec2 delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right); + ImGui::ResetMouseDragDelta(ImGuiMouseButton_Right); + position -= glm::vec2(delta.x, -delta.y) / zoom; + } + + float wheel = ImGui::GetIO().MouseWheel; + if (wheel != 0.0f) + { + float zoomFactor = 1.1f; + zoom *= (wheel > 0) ? zoomFactor : (1.0f / zoomFactor); + zoom = std::clamp(zoom, 0.1f, 10.0f); + } + } + } +}; + +static EditorCamera editorCamera; + GLFWwindow *window = nullptr; Engine::Engine() @@ -106,8 +137,6 @@ void Engine::Run() ImGui::Begin("Scene Tree"); - - if (ImGui::BeginPopupContextWindow("SceneTreeContext", ImGuiPopupFlags_MouseButtonRight)) { if (ImGui::MenuItem("Create New Object")) @@ -129,16 +158,11 @@ void Engine::Run() } ImGui::EndPopup(); } - - - for (auto &obj : objects) if (!obj->GetParent()) // Only draw root nodes DrawObjectNode(obj); - - ImGui::End(); ImGui::Begin("Inspector"); @@ -155,13 +179,20 @@ void Engine::Run() ImGui::InputInt("Layer", &selected->layer); - // Add component + // Add SpriteComponent if (ImGui::Button("Add SpriteComponent")) { if (!selected->GetComponent()) selected->AddComponent(); } + // Add CameraComponent + if (ImGui::Button("Add CameraComponent")) + { + if (!selected->GetComponent()) + selected->AddComponent(); + } + // Show SpriteComponent UI if (auto sprite = selected->GetComponent()) { @@ -192,6 +223,29 @@ void Engine::Run() selected->RemoveComponent(); } } + + // Show CameraComponent UI + if (auto cam = selected->GetComponent()) + { + ImGui::Separator(); + ImGui::Text("Camera Component"); + + float fov = cam->GetFOV(); + float aspect = cam->GetAspect(); + float zoom = cam->GetZoom(); + + if (ImGui::DragFloat("FOV", &fov, 0.1f, 1.0f, 179.0f)) + cam->SetFOV(fov); + if (ImGui::DragFloat("Aspect", &aspect, 0.01f, 0.1f, 5.0f)) + cam->SetAspect(aspect); + if (ImGui::DragFloat("Zoom", &zoom, 0.1f, 0.1f, 10.0f)) + cam->SetZoom(zoom); + + if (ImGui::Button("Remove CameraComponent")) + { + selected->RemoveComponent(); + } + } } else { @@ -199,67 +253,91 @@ void Engine::Run() } ImGui::End(); - - - - // Viewport ImGui::Begin("Viewport", nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); ImVec2 size = ImGui::GetContentRegionAvail(); + + if (!playing) + editorCamera.HandleInput(); + + glm::vec2 cameraOffset = editorCamera.position; + float camZoom = editorCamera.zoom; + + if (playing) + { + for (const auto &obj : objects) + { + if (auto cam = obj->GetComponent()) + { + if (cam->IsPrimary()) + { + cameraOffset = obj->GetWorldPosition(); + camZoom = cam->GetZoom(); + break; + } + } + } + } + Renderer::Resize((int)size.x, (int)size.y); Renderer::Begin(); std::vector> toDraw; - - std::function&)> collect = [&](const std::shared_ptr& obj) { + std::function &)> collect = [&](const std::shared_ptr &obj) + { toDraw.push_back(obj); - for (const auto& child : obj->GetChildren()) + for (const auto &child : obj->GetChildren()) collect(child); }; - - for (const auto& obj : objects) + + for (const auto &obj : objects) if (!obj->GetParent()) collect(obj); - - std::sort(toDraw.begin(), toDraw.end(), [](const auto& a, const auto& b) { - return a->layer < b->layer; - }); - - for (const auto& obj : toDraw) { - if (auto sprite = obj->GetComponent()) { - Renderer::DrawSprite(sprite.get(), obj->GetWorldPosition()); + + std::sort(toDraw.begin(), toDraw.end(), [](const auto &a, const auto &b) + { return a->layer < b->layer; }); + + for (const auto &obj : toDraw) + { + if (auto sprite = obj->GetComponent()) + { + glm::vec2 renderPos = (obj->GetWorldPosition() - cameraOffset) * camZoom; + Renderer::DrawSprite(sprite.get(), renderPos, camZoom); } } - Renderer::End(); GLuint texID = Renderer::GetRenderTexture(); ImGui::Image((ImTextureID)(uintptr_t)texID, size, ImVec2(0, 1), ImVec2(1, 0)); ImGui::End(); - if (ImGui::BeginPopup("RenameObject")) { + if (ImGui::BeginPopup("RenameObject")) + { static char nameBuffer[128]; static bool once = true; - - if (once && selected) { + + if (once && selected) + { strcpy(nameBuffer, selected->GetName().c_str()); once = false; } - + ImGui::InputText("##rename", nameBuffer, sizeof(nameBuffer)); - if (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::Button("OK")) { + if (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::Button("OK")) + { if (selected) selected->SetName(nameBuffer); ImGui::CloseCurrentPopup(); once = true; } - + ImGui::SameLine(); - if (ImGui::Button("Cancel")) { + if (ImGui::Button("Cancel")) + { ImGui::CloseCurrentPopup(); once = true; } - + ImGui::EndPopup(); } diff --git a/src/src/Entitys/Object.cpp b/src/src/Entitys/Object.cpp index b2057c3..7ac1314 100644 --- a/src/src/Entitys/Object.cpp +++ b/src/src/Entitys/Object.cpp @@ -1,14 +1,14 @@ #include "Object.h" -#include "../Components/SpriteComponent.h" #include "../Components/Component.h" - +#include "../Components/SpriteComponent.h" +#include "../Components/CameraComponent.h" #include static int nextID = 0; Object::Object(const std::string& name) - : name(name), localPosition(0.0f, 0.0f), id(nextID++), layer(1) {} + : name(name), localPosition(0.0f, 0.0f), id(nextID++) {} Object::~Object() {} @@ -49,79 +49,48 @@ void Object::SetName(const std::string& n) { name = n; } std::vector>& Object::GetChildren() { return children; } Object* Object::GetParent() const { return parent; } -// === Component System === - -template -std::shared_ptr Object::GetComponent() const { - for (const auto& comp : components) { - if (auto casted = std::dynamic_pointer_cast(comp)) - return casted; - } - return nullptr; -} - -template -std::shared_ptr Object::AddComponent() { - auto existing = GetComponent(); - if (existing) return existing; - - std::shared_ptr component = std::make_shared(this); - components.push_back(component); - return component; -} - -template -void Object::RemoveComponent() { - components.erase(std::remove_if(components.begin(), components.end(), - [](const std::shared_ptr& comp) { - return std::dynamic_pointer_cast(comp) != nullptr; - }), components.end()); -} - -// Explicit template instantiation -template std::shared_ptr Object::GetComponent() const; -template std::shared_ptr Object::AddComponent(); -template void Object::RemoveComponent(); - void Object::Save(YAML::Emitter& out) const { out << YAML::BeginMap; out << YAML::Key << "name" << YAML::Value << name; out << YAML::Key << "position" << YAML::Value << YAML::Flow << YAML::BeginSeq << localPosition.x << localPosition.y << YAML::EndSeq; - + out << YAML::Key << "layer" << YAML::Value << layer; out << YAML::Key << "components" << YAML::Value << YAML::BeginSeq; - for (const auto& comp : components) { + for (const auto& comp : components) comp->Save(out); - } out << YAML::EndSeq; - out << YAML::Key << "children" << YAML::Value << YAML::BeginSeq; for (const auto& child : children) child->Save(out); out << YAML::EndSeq; - out << YAML::EndMap; } void Object::Load(const YAML::Node& node) { name = node["name"].as(); auto pos = node["position"]; - localPosition = { pos[0].as(), pos[1].as() }; + if (pos && pos.IsSequence() && pos.size() == 2) { + localPosition.x = pos[0].as(); + localPosition.y = pos[1].as(); + } + if (node["layer"]) + layer = node["layer"].as(); - components.clear(); if (node["components"]) { for (const auto& compNode : node["components"]) { std::string type = compNode["type"].as(); if (type == "SpriteComponent") { - auto comp = AddComponent(); + auto comp = AddComponent(); + comp->Load(compNode); + } else if (type == "CameraComponent") { + auto comp = AddComponent(); comp->Load(compNode); } } } - children.clear(); if (node["children"]) { for (const auto& childNode : node["children"]) { - auto child = std::make_shared("(loaded)"); + auto child = std::make_shared("Child"); child->Load(childNode); AddChild(child); } diff --git a/src/src/Entitys/Object.h b/src/src/Entitys/Object.h index 330fbab..b61314e 100644 --- a/src/src/Entitys/Object.h +++ b/src/src/Entitys/Object.h @@ -1,30 +1,30 @@ #pragma once + #include #include #include #include #include -#include "../Components/Component.h" +class Component; class Object { public: Object(const std::string& name); ~Object(); - void SetParent(Object* newParent); - void AddChild(std::shared_ptr child); - void RemoveChild(Object* child); - - glm::vec2 GetWorldPosition() const; - glm::vec2 GetLocalPosition() const; - void SetLocalPosition(glm::vec2 pos); - const std::string& GetName() const; void SetName(const std::string& name); - std::vector>& GetChildren(); + glm::vec2 GetLocalPosition() const; + void SetLocalPosition(glm::vec2 pos); + glm::vec2 GetWorldPosition() const; + + void SetParent(Object* parent); Object* GetParent() const; + void AddChild(std::shared_ptr child); + void RemoveChild(Object* child); + std::vector>& GetChildren(); template std::shared_ptr GetComponent() const; @@ -38,10 +38,8 @@ public: void Save(YAML::Emitter& out) const; void Load(const YAML::Node& node); - int id; - bool selected = false; - - int layer; + int id = 0; + int layer = 0; private: std::string name; @@ -50,3 +48,30 @@ private: std::vector> children; std::vector> components; }; + +template +std::shared_ptr Object::GetComponent() const { + for (const auto& comp : components) { + if (auto casted = std::dynamic_pointer_cast(comp)) + return casted; + } + return nullptr; +} + +template +std::shared_ptr Object::AddComponent() { + auto existing = GetComponent(); + if (existing) return existing; + + std::shared_ptr component = std::make_shared(this); + components.push_back(component); + return component; +} + +template +void Object::RemoveComponent() { + components.erase(std::remove_if(components.begin(), components.end(), + [](const std::shared_ptr& comp) { + return std::dynamic_pointer_cast(comp) != nullptr; + }), components.end()); +} diff --git a/src/src/Renderer.cpp b/src/src/Renderer.cpp index eea0ff4..c77242c 100644 --- a/src/src/Renderer.cpp +++ b/src/src/Renderer.cpp @@ -92,23 +92,22 @@ void Renderer::End() { glBindFramebuffer(GL_FRAMEBUFFER, 0); } -void Renderer::DrawSprite(SpriteComponent* sprite, const glm::vec2& pos) { - if (!sprite || sprite->GetTextureID() == 0) return; +void Renderer::DrawSprite(SpriteComponent* sprite, const glm::vec2& pos, float scale) { + GLuint tex = sprite->GetTextureID(); + if (!tex) return; - spriteShader.Use(); - spriteShader.SetVec2("uPos", pos); - spriteShader.SetVec2("uSize", sprite->GetSize()); - spriteShader.SetVec2("uScreen", glm::vec2(width, height)); - spriteShader.SetInt("uTex", 0); + glBindTexture(GL_TEXTURE_2D, tex); + glBegin(GL_QUADS); + float size = 100.0f * scale; - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, sprite->GetTextureID()); - - glBindVertexArray(quadVAO); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glBindVertexArray(0); + glTexCoord2f(0, 0); glVertex2f(pos.x, pos.y); + glTexCoord2f(1, 0); glVertex2f(pos.x + size, pos.y); + glTexCoord2f(1, 1); glVertex2f(pos.x + size, pos.y + size); + glTexCoord2f(0, 1); glVertex2f(pos.x, pos.y + size); + glEnd(); } + GLuint Renderer::GetRenderTexture() { return textureColorBuffer; } diff --git a/src/src/Renderer.h b/src/src/Renderer.h index 68d92e6..8ec5d0e 100644 --- a/src/src/Renderer.h +++ b/src/src/Renderer.h @@ -10,7 +10,7 @@ public: static void Resize(int w, int h); static void Begin(); static void End(); - static void DrawSprite(SpriteComponent* sprite, const glm::vec2& pos); + static void DrawSprite(SpriteComponent* sprite, const glm::vec2& pos, float scale); static GLuint GetRenderTexture(); static glm::ivec2 GetSize();