Skip to content
Snippets Groups Projects
Commit d1b31218 authored by BATON Theau's avatar BATON Theau
Browse files

Resolve renderer resolution bug

parent 9b2c943e
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,12 @@
#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());
......
......@@ -11,6 +11,7 @@ namespace megu {
class GraphicEngine {
public:
GraphicEngine() = delete;
GraphicEngine(Window &, float, float);
GraphicEngine(Window &);
~GraphicEngine() = default;
......
......@@ -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);
}
......
......@@ -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;
};
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment