[nostalgia] Fix scaling of SceneEditorView not to be completely broken

This commit is contained in:
2023-12-09 23:16:59 -06:00
parent 62c671e823
commit 371044d63d
6 changed files with 53 additions and 23 deletions
@@ -78,7 +78,16 @@ void setSprite(Context &ctx, Sprite const&s) noexcept;
}
namespace nostalgia::core::gl {
constexpr ox::CStringView GlslVersion = "#version 330";
void draw(core::Context&, ox::Size const&) noexcept;
}
constexpr ox::CStringView GlslVersion = "#version 330";
constexpr auto DefaultScale = 5;
[[nodiscard]]
ox::Size drawSize(int scale = DefaultScale) noexcept;
void draw(core::Context &ctx, ox::Size const&renderSz) noexcept;
void draw(core::Context&, int scale = 5) noexcept;
}
@@ -6,5 +6,4 @@ target_sources(
target_link_libraries(
NostalgiaCore PUBLIC
GlUtils
lodepng
)
+10 -3
View File
@@ -2,8 +2,6 @@
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <lodepng.h>
#include <ox/std/array.hpp>
#include <ox/std/fmt.hpp>
#include <ox/std/vec.hpp>
@@ -21,7 +19,7 @@
namespace nostalgia::core {
constexpr auto Scale = 10;
constexpr auto Scale = 1;
namespace renderer {
@@ -234,6 +232,7 @@ static glutils::GLTexture createTexture(
GLsizei w,
GLsizei h,
const void *pixels) noexcept {
oxDebugf("createTexture(w: {}, h: {}, pixels: ...)", w, h);
GLuint texId = 0;
glGenTextures(1, &texId);
glutils::GLTexture tex(texId);
@@ -607,6 +606,10 @@ void setTile(
namespace gl {
ox::Size drawSize(int scale) noexcept {
return {240 * scale, 160 * scale};
}
void draw(core::Context &ctx, ox::Size const&renderSz) noexcept {
glViewport(0, 0, renderSz.width, renderSz.height);
glutils::clearScreen();
@@ -616,6 +619,10 @@ void draw(core::Context &ctx, ox::Size const&renderSz) noexcept {
}
}
void draw(core::Context &ctx, int scale) noexcept {
draw(ctx, drawSize(scale));
}
}
}