43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
#include <imgui.h>
|
|
|
|
#include <sophia/application.hpp>
|
|
#include <sophia/entity.hpp>
|
|
#include <sophia/frame_info.hpp>
|
|
#include <sophia/scene_view.hpp>
|
|
#include <sophia/ui/panel.hpp>
|
|
|
|
class Viewport : public sophia::Panel {
|
|
public:
|
|
Viewport(sophia::UI& ui, sophia::RenderTargetHandle target)
|
|
: Panel{{.name = "Viewport"}}, ui{ui}, target{target} {}
|
|
|
|
void onUpdate(const sophia::FrameInfo&) override {
|
|
ImGui::Text("Test ViewPort");
|
|
|
|
ui.image(target);
|
|
}
|
|
|
|
private:
|
|
sophia::UI& ui;
|
|
sophia::RenderTargetHandle target;
|
|
};
|
|
|
|
class Testbed : public sophia::Application {
|
|
public:
|
|
Testbed() : Application{{.width = 750, .height = 1000, .name = "Testbed"}} {}
|
|
|
|
void onCreate() override {
|
|
view = sceneViews().create(
|
|
{.scene = scenes().create(),
|
|
.target = resources().create<sophia::RenderTarget>(),
|
|
.clearColor = {0.1f, 0.1f, 0.15f, 1.f}});
|
|
|
|
panels().emplace<Viewport>(ui(), sceneViews().get(view).target);
|
|
}
|
|
|
|
private:
|
|
sophia::SceneViewHandle view;
|
|
};
|
|
|
|
SOPHIA_MAIN(Testbed)
|