Initial claude dump

This commit is contained in:
2026-09-25 22:59:01 -07:00
parent 5644782a1f
commit a21a842b5b
26 changed files with 1101 additions and 158 deletions
+58 -3
View File
@@ -1,5 +1,7 @@
#include <iostream>
#include <sophia/application.hpp>
#include <sophia/components.hpp>
#include <sophia/entity.hpp>
#include "panels/asset_browser_panel.hpp"
#include "panels/inspector_panel.hpp"
@@ -15,12 +17,19 @@ class Editor : public sophia::Application {
debugUI().show();
panels().emplace<SceneHierarchyPanel>();
panels().emplace<InspectorPanel>();
textures.emplace_back("Checker", createCheckerTexture());
sophia::SceneHandle sceneHandle = scenes().create();
sophia::Scene& scene = scenes().get(sceneHandle);
sophia::Entity camera = createDemoScene(scene);
panels().emplace<SceneHierarchyPanel>(scene, selected);
panels().emplace<InspectorPanel>(selected, textures);
panels().emplace<AssetBrowserPanel>();
sophia::RenderTargetHandle sceneTarget =
resources().create<sophia::RenderTarget>();
views().create({.scene = scenes().create(), .target = sceneTarget});
views().create(
{.scene = sceneHandle, .target = sceneTarget, .camera = camera});
panels().emplace<ViewportPanel>(ui(), sceneTarget);
panels().setDefaultLayout(
@@ -31,6 +40,52 @@ class Editor : public sophia::Application {
}
void onUpdate(const sophia::FrameInfo& frameInfo) override {}
private:
sophia::Entity createDemoScene(sophia::Scene& scene) {
sophia::Entity camera = scene.createEntity("Main Camera");
camera.addComponent<sophia::CameraComponent>();
scene.setActiveCamera(camera);
sophia::Entity checker = scene.createEntity("Checker");
checker.getComponent<sophia::TransformComponent>().position = {-1.5f, 0.f,
0.f};
checker.addComponent<sophia::SpriteComponent>(sophia::SpriteComponent{
.texture = textures[0].second, .size = {2.f, 2.f}});
sophia::Entity red = scene.createEntity("Red");
red.getComponent<sophia::TransformComponent>().position = {1.f, -0.5f, 0.f};
red.addComponent<sophia::SpriteComponent>(sophia::SpriteComponent{
.color = {0.9f, 0.25f, 0.25f, 1.f}, .size = {2.f, 2.f}});
// Drawn over "Red" because of its higher sort order.
sophia::Entity blue = scene.createEntity("Blue (translucent)");
blue.getComponent<sophia::TransformComponent>().position = {1.75f, 0.25f,
0.f};
blue.addComponent<sophia::SpriteComponent>(
sophia::SpriteComponent{.color = {0.25f, 0.45f, 0.95f, 0.6f},
.size = {2.f, 2.f},
.sortOrder = 1});
return camera;
}
sophia::TextureHandle createCheckerTexture() {
constexpr sophia::u32 SIZE = 8;
std::vector<sophia::u8> pixels(SIZE * SIZE * 4);
for (sophia::u32 y = 0; y < SIZE; y++) {
for (sophia::u32 x = 0; x < SIZE; x++) {
sophia::u8 value = ((x + y) % 2 == 0) ? 230 : 60;
sophia::u8* pixel = &pixels[(y * SIZE + x) * 4];
pixel[0] = pixel[1] = pixel[2] = value;
pixel[3] = 255;
}
}
return resources().create<sophia::Texture>(SIZE, SIZE, std::move(pixels));
}
sophia::Entity selected;
InspectorPanel::TextureList textures;
};
SOPHIA_MAIN(Editor)