Files
sophia/engine/include/sophia/components.hpp
T
burkkyy 5e1caabde6 Add offscreen render targets and rename AssetRegistry to ResourceRegistry
Add a RenderTarget resource so the scene can render offscreen instead of
straight to the swapchain. The editor uses it to show the scene inside the
Viewport panel.

- Rename AssetRegistry to ResourceRegistry (AssetTraits -> ResourceTraits,
  assets() -> resources()) and move the pools from engine/src/assets to
  engine/src/resources. It now covers non-asset GPU resources as well.
- Replace loadMesh() with create<T>(...), and add create<RenderTarget>(),
  requestResize(), getExtent() and isAlive().
- Add RenderTarget and RenderTargetPool with RenderTargetHandle.
  Resizes are deferred and applied at the start of the next frame, when the
  GPU is idle.
- Add Application::setSceneTarget(). With no target set, the scene still
  renders to the swapchain. With a target set, the scene renders offscreen
  and the swapchain receives only the UI. Frame extent and camera projection
  follow the target's size.
- Add sophia::UI (Application::ui()) with image() and getTextureId() to draw
  a render target in an ImGui window, sizing the target to the available
  space. ImGuiRenderer now registers the target textures for this.
- ViewportPanel takes the UI and a target, and draws the scene image in place
  of the flat background fill.
- Update the testbed, the boids example, and the glossary for the rename.
2026-09-20 16:21:22 -07:00

38 lines
799 B
C++

#pragma once
#include <sophia/resource_registry.hpp>
#include <string>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
namespace sophia {
struct TagComponent {
std::string tag; // entt::hashed_string ?
};
struct TransformComponent {
glm::vec3 position{0.f, 0.f, 0.f};
glm::quat rotation{1.f, 0.f, 0.f, 0.f};
glm::vec3 scale{1.f, 1.f, 1.f};
glm::mat4 mat4() const {
return glm::translate(glm::mat4{1.f}, position) * glm::mat4_cast(rotation) *
glm::scale(glm::mat4{1.f}, scale);
}
glm::mat3 normalMatrix() const {
return glm::mat3{glm::transpose(glm::inverse(mat4()))};
}
};
struct MeshComponent {
MeshHandle handle;
};
} // namespace sophia