diff --git a/source/engine/graphics/front/engine/Engine.cpp b/source/engine/graphics/front/engine/Engine.cpp index 7908f9c106afac9e8327f33405051fede1e00f0f..fd7282a893c9cb64991b81330ee2b07eea0646ee 100644 --- a/source/engine/graphics/front/engine/Engine.cpp +++ b/source/engine/graphics/front/engine/Engine.cpp @@ -3,11 +3,17 @@ #define NORMALIZE(X) X/255.f namespace megu { + GraphicEngine::GraphicEngine(Window & window, float w, float h) + : _window(window), _renderer(w, h) { + glViewport(0, 0, window.width(), window.height()); + this->_renderer.setClearColor(NORMALIZE(135.f), NORMALIZE(170.f), NORMALIZE(255.f)); + } + GraphicEngine::GraphicEngine(Window & window) : _window(window), _renderer(window.width(), window.height()) { glViewport(0, 0, window.width(), window.height()); this->_renderer.setClearColor(NORMALIZE(135.f), NORMALIZE(170.f), NORMALIZE(255.f)); - } + } void GraphicEngine::push(Priority priority, const Renderer & renderer) { this->_layers[priority] = std::make_unique<Layer>(renderer); diff --git a/source/engine/graphics/front/engine/Engine.hpp b/source/engine/graphics/front/engine/Engine.hpp index 116b7de0a1f15ed1e55d3f23e7e12a9d3559c89d..6442d3f8e6998f0a1ac0dc438bdabfdf68bd9e61 100644 --- a/source/engine/graphics/front/engine/Engine.hpp +++ b/source/engine/graphics/front/engine/Engine.hpp @@ -11,6 +11,7 @@ namespace megu { class GraphicEngine { public: GraphicEngine() = delete; + GraphicEngine(Window &, float, float); GraphicEngine(Window &); ~GraphicEngine() = default; diff --git a/source/engine/graphics/front/engine/Renderer.cpp b/source/engine/graphics/front/engine/Renderer.cpp index 3b97d5a2326f7de7b859d95cc0df96ffff01cf4d..be10866cb2f79046e64b0621b5cb9c1765d85ac8 100644 --- a/source/engine/graphics/front/engine/Renderer.cpp +++ b/source/engine/graphics/front/engine/Renderer.cpp @@ -2,7 +2,7 @@ namespace megu { Renderer::Renderer(float x, float y) - : _view(0, 0, y, x) { + : _view(0, 0, x, y) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); } diff --git a/source/engine/graphics/front/engine/Renderer.hpp b/source/engine/graphics/front/engine/Renderer.hpp index 9157f4c4ff4387f0869dfa90201188d9d16091b0..f7624fa2357bbf2e82eefa997d478f09fff1cedb 100644 --- a/source/engine/graphics/front/engine/Renderer.hpp +++ b/source/engine/graphics/front/engine/Renderer.hpp @@ -22,6 +22,8 @@ namespace megu { void clear() const; void setClearColor(float, float, float, float = 1.f) const; + View & view() {return this->_view;} + private: View _view; }; diff --git a/source/main.cpp b/source/main.cpp index 727695ff5fc74b9a9080bfe596b2f7675b21a4b4..39b4cf180d747e14ab73b2dc73a1b5e663883808 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -7,8 +7,8 @@ #include <imgui_impl_glfw.h> #include <imgui_impl_opengl3.h> -#define WINDOW_WIDTH 640 -#define WINDOW_HEIGHT 640 +#define WINDOW_WIDTH 1280 +#define WINDOW_HEIGHT 720 #include <engine/io/Window.hpp> #include <engine/graphics/back/cameras/View.hpp> @@ -82,7 +82,7 @@ int main(int argc, const char * argv[]) { images.push_back(std::make_unique<megu::Image>(id == 1 ? texture_1 : texture_2)); glm::vec2 pos = to_screen_coordinate({x, y}, 32.f, 32.f, 1.f); - images.back()->setPosition({pos.x + 25, pos.y}); + images.back()->setPosition({pos.x + window.width()/2, pos.y + window.height()/2}); } ++x; @@ -128,7 +128,7 @@ int main(int argc, const char * argv[]) { images_2.push_back(std::make_unique<megu::Image>(texture_3)); glm::vec2 pos = to_screen_coordinate({x_2, y_2}, 32.f, 32.f); - images_2.back()->setPosition({pos.x + 25, pos.y}); + images_2.back()->setPosition({pos.x + window.width()/2, pos.y + window.height()/2}); } ++x_2; @@ -174,7 +174,7 @@ int main(int argc, const char * argv[]) { images_3.push_back(std::make_unique<megu::Image>(texture_4)); glm::vec2 pos = to_screen_coordinate({x_3, y_3}, 32.f, 32.f, 2.f); - images_3.back()->setPosition({pos.x + 25, pos.y}); + images_3.back()->setPosition({pos.x + window.width()/2, pos.y + window.height()/2}); } ++x_3; @@ -194,7 +194,7 @@ int main(int argc, const char * argv[]) { //? Engines megu::GraphicEngine engine(window); - megu::Renderer basic_renderer(320, 320); + megu::Renderer basic_renderer(640*2, 360*2); engine.push(0, basic_renderer); engine.push(1, basic_renderer);