[nostalgia/scene/studio] Cleanup

This commit is contained in:
Gary Talent 2023-05-30 20:01:56 -05:00
parent 79e6838ab3
commit 220f272867
4 changed files with 14 additions and 20 deletions

View File

@ -14,11 +14,7 @@ ox::Vector<studio::EditorMaker> StudioModule::editors(core::Context *ctx) noexce
{
{"nscn"},
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
try {
return ox::make<SceneEditorImGui>(ctx, path);
} catch (const ox::Exception &ex) {
return ex.toError();
}
return ox::makeCatch<SceneEditorImGui>(ctx, path);
}
},
};

View File

@ -4,9 +4,9 @@
#include <imgui.h>
#include <nostalgia/core/gfx.hpp>
#include <keel/media.hpp>
#include <ox/std/memory.hpp>
#include <nostalgia/core/gfx.hpp>
#include "sceneeditor-imgui.hpp"
@ -46,7 +46,7 @@ void SceneEditorImGui::draw(core::Context*) noexcept {
}
void SceneEditorImGui::onActivated() noexcept {
m_view.setupScene();
oxLogError(m_view.setupScene());
}
ox::Error SceneEditorImGui::saveItem() noexcept {

View File

@ -2,31 +2,29 @@
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <nostalgia/core/gfx.hpp>
#include "sceneeditorview.hpp"
namespace nostalgia::scene {
SceneEditorView::SceneEditorView(core::Context *ctx, const SceneStatic &sceneStatic) noexcept:
m_ctx(*ctx),
m_ctx(ctx),
m_sceneStatic(sceneStatic),
m_scene(m_sceneStatic) {
}
void SceneEditorView::setupScene() noexcept {
oxIgnoreError(m_scene.setupDisplay(&m_ctx));
ox::Error SceneEditorView::setupScene() noexcept {
return m_scene.setupDisplay(m_ctx);
}
void SceneEditorView::draw(int width, int height) noexcept {
if (width != m_frameBuffer.width || height != m_frameBuffer.height) {
glutils::resizeInitFrameBuffer(&m_frameBuffer, width, height);
core::gl::setRenderSize(&m_ctx, width, height);
oxIgnoreError(m_scene.setupDisplay(&m_ctx));
}
glBindFramebuffer(GL_FRAMEBUFFER, m_frameBuffer);
glViewport(0, 0, m_frameBuffer.width, m_frameBuffer.height);
// draw begin
core::gl::drawMainView(&m_ctx);
// draw end
glutils::bind(m_frameBuffer);
core::gl::setRenderSize(m_ctx, width, height);
core::gl::drawMainView(m_ctx);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

View File

@ -13,7 +13,7 @@ namespace nostalgia::scene {
class SceneEditorView {
private:
core::Context &m_ctx;
core::Context *const m_ctx = nullptr;
const SceneStatic &m_sceneStatic;
Scene m_scene;
glutils::FrameBuffer m_frameBuffer;
@ -21,7 +21,7 @@ class SceneEditorView {
public:
SceneEditorView(core::Context *ctx, const SceneStatic &sceneStatic) noexcept;
void setupScene() noexcept;
ox::Error setupScene() noexcept;
void draw(int width, int height) noexcept;