mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
update ModelViewer
This commit is contained in:
parent
fe69d31f97
commit
60106d4fb1
2 changed files with 17 additions and 4 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include "window/Window.hpp"
|
||||
#include "../GUI.hpp"
|
||||
|
||||
// TODO: remove
|
||||
// TODO: remove
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
|
@ -24,8 +25,7 @@ ModelViewer::ModelViewer(
|
|||
: Container(gui, size),
|
||||
modelName(modelName),
|
||||
camera(),
|
||||
batch(std::make_unique<Batch3D>(1024)),
|
||||
fbo(std::make_unique<Framebuffer>(size.x, size.y)) {
|
||||
batch(std::make_unique<Batch3D>(1024)) {
|
||||
camera.perspective = true;
|
||||
camera.position = glm::vec3(2, 2, 2);
|
||||
}
|
||||
|
|
@ -115,7 +115,13 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
return;
|
||||
}
|
||||
auto& prevShader = Shader::getUsed();
|
||||
|
||||
|
||||
if (!fbo) {
|
||||
if (size.x <= 0 || size.y <= 0) {
|
||||
return;
|
||||
}
|
||||
fbo = std::make_unique<Framebuffer>(size.x, size.y);
|
||||
}
|
||||
fbo->resize(size.x, size.y);
|
||||
{
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
|
@ -154,6 +160,13 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
Container::draw(pctx, assets);
|
||||
}
|
||||
|
||||
void ModelViewer::setVisible(bool flag) {
|
||||
if (!flag && fbo) {
|
||||
fbo.reset();
|
||||
}
|
||||
Container::setVisible(flag);
|
||||
}
|
||||
|
||||
void ModelViewer::setCenter(const glm::vec3& center) {
|
||||
this->center = center;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue