remove Viewport class
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include "graphics/core/DrawContext.hpp"
|
||||
#include "graphics/core/Shader.hpp"
|
||||
#include "graphics/core/Texture.hpp"
|
||||
#include "graphics/core/Viewport.hpp"
|
||||
#include "graphics/commons/Model.hpp"
|
||||
|
||||
#include <glm/ext.hpp>
|
||||
@@ -127,7 +126,7 @@ std::unique_ptr<Atlas> BlocksPreview::build(
|
||||
glm::vec3(0, 1, 0)));
|
||||
|
||||
AtlasBuilder builder;
|
||||
ctx.setViewport(Viewport(iconSize, iconSize));
|
||||
ctx.setViewport({iconSize, iconSize});
|
||||
display::setBgColor(glm::vec4(0.0f));
|
||||
|
||||
fbo.bind();
|
||||
|
||||
@@ -64,8 +64,6 @@ void GuidesRenderer::renderDebugLines(
|
||||
) {
|
||||
DrawContext ctx = pctx.sub(&batch);
|
||||
const auto& viewport = ctx.getViewport();
|
||||
uint displayWidth = viewport.getWidth();
|
||||
uint displayHeight = viewport.getHeight();
|
||||
|
||||
ctx.setDepthTest(true);
|
||||
|
||||
@@ -91,15 +89,15 @@ void GuidesRenderer::renderDebugLines(
|
||||
}
|
||||
|
||||
float length = 40.f;
|
||||
glm::vec3 tsl(displayWidth / 2, displayHeight / 2, 0.f);
|
||||
glm::vec3 tsl(viewport.x / 2, viewport.y / 2, 0.f);
|
||||
glm::mat4 model(glm::translate(glm::mat4(1.f), tsl));
|
||||
linesShader.uniformMatrix(
|
||||
"u_projview",
|
||||
glm::ortho(
|
||||
0.f,
|
||||
static_cast<float>(displayWidth),
|
||||
static_cast<float>(viewport.x),
|
||||
0.f,
|
||||
static_cast<float>(displayHeight),
|
||||
static_cast<float>(viewport.y),
|
||||
-length,
|
||||
length
|
||||
) * model *
|
||||
|
||||
@@ -101,11 +101,9 @@ void Skybox::draw(
|
||||
float daytime,
|
||||
float fog)
|
||||
{
|
||||
const Viewport& viewport = pctx.getViewport();
|
||||
int width = viewport.getWidth();
|
||||
int height = viewport.getHeight();
|
||||
const glm::uvec2& viewport = pctx.getViewport();
|
||||
|
||||
drawBackground(camera, assets, width, height);
|
||||
drawBackground(camera, assets, viewport.x, viewport.y);
|
||||
|
||||
DrawContext ctx = pctx.sub();
|
||||
ctx.setBlendMode(BlendMode::addition);
|
||||
@@ -145,7 +143,7 @@ void Skybox::refresh(const DrawContext& pctx, float t, float mie, uint quality)
|
||||
ctx.setDepthMask(false);
|
||||
ctx.setDepthTest(false);
|
||||
ctx.setFramebuffer(fbo.get());
|
||||
ctx.setViewport(Viewport(size, size));
|
||||
ctx.setViewport({size, size});
|
||||
|
||||
auto cubemap = dynamic_cast<Cubemap*>(fbo->getTexture());
|
||||
assert(cubemap != nullptr);
|
||||
|
||||
@@ -85,14 +85,14 @@ void TextsRenderer::renderNote(
|
||||
}
|
||||
pos /= projpos.w;
|
||||
pos.z = 0;
|
||||
xvec = {2.0f / viewport.getWidth() * scale, 0, 0};
|
||||
yvec = {0, 2.0f / viewport.getHeight() * scale, 0};
|
||||
xvec = {2.0f / viewport.x * scale, 0, 0};
|
||||
yvec = {0, 2.0f / viewport.y * scale, 0};
|
||||
} else {
|
||||
auto matrix = camera.getProjView();
|
||||
auto screenPos = matrix * glm::vec4(pos, 1.0f);
|
||||
|
||||
xvec = glm::vec3(2.0f / viewport.getWidth() * scale, 0, 0);
|
||||
yvec = glm::vec3(0, 2.0f / viewport.getHeight() * scale, 0);
|
||||
xvec = glm::vec3(2.0f / viewport.x * scale, 0, 0);
|
||||
yvec = glm::vec3(0, 2.0f / viewport.y * scale, 0);
|
||||
|
||||
pos = screenPos / screenPos.w;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ void WorldRenderer::draw(
|
||||
auto world = level.getWorld();
|
||||
|
||||
const auto& vp = pctx.getViewport();
|
||||
camera.setAspectRatio(vp.getRatio());
|
||||
camera.setAspectRatio(vp.x / static_cast<float>(vp.y));
|
||||
|
||||
const auto& settings = engine.getSettings();
|
||||
const auto& worldInfo = world->getInfo();
|
||||
|
||||
Reference in New Issue
Block a user