diff --git a/src/nostalgia/scene/studio/module.cpp b/src/nostalgia/scene/studio/module.cpp index 6a794aca..4144ae35 100644 --- a/src/nostalgia/scene/studio/module.cpp +++ b/src/nostalgia/scene/studio/module.cpp @@ -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); } }, }; diff --git a/src/nostalgia/scene/studio/sceneeditor-imgui.cpp b/src/nostalgia/scene/studio/sceneeditor-imgui.cpp index 2926d3be..752d74f2 100644 --- a/src/nostalgia/scene/studio/sceneeditor-imgui.cpp +++ b/src/nostalgia/scene/studio/sceneeditor-imgui.cpp @@ -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 { diff --git a/src/nostalgia/scene/studio/sceneeditorview.cpp b/src/nostalgia/scene/studio/sceneeditorview.cpp index bea6b23e..dd6d1ebe 100644 --- a/src/nostalgia/scene/studio/sceneeditorview.cpp +++ b/src/nostalgia/scene/studio/sceneeditorview.cpp @@ -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); } diff --git a/src/nostalgia/scene/studio/sceneeditorview.hpp b/src/nostalgia/scene/studio/sceneeditorview.hpp index a3072d95..f031c067 100644 --- a/src/nostalgia/scene/studio/sceneeditorview.hpp +++ b/src/nostalgia/scene/studio/sceneeditorview.hpp @@ -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;