Add offscreen render targets and rename AssetRegistry to ResourceRegistry #8

Merged
burkkyy merged 26 commits from dev into main 2026-09-25 20:39:26 -07:00
4 changed files with 62 additions and 63 deletions
Showing only changes of commit 6a50cdb4e8 - Show all commits
+2 -1
View File
@@ -2,6 +2,7 @@
namespace sophia {
Entity::Entity(entt::entity handle, Scene* scene) : handle(handle), scene(scene) {}
Entity::Entity(entt::entity handle, Scene* scene)
: handle(handle), scene(scene) {}
} // namespace sophia
+8 -12
View File
@@ -1,9 +1,9 @@
#pragma once
#include <sophia/scene.hpp>
#include <entt/entt.hpp>
#include <sophia/util/assert.hpp>
#include <sophia/scene.hpp>
#include <sophia/types.hpp>
#include <sophia/util/assert.hpp>
namespace sophia {
@@ -18,27 +18,25 @@ public:
template <typename T, typename... Args>
T& addComponent(Args&&... args) {
SOPHIA_ASSERT(!hasComponent<T>(), "Entity already has component!");
T& component = scene->registry.emplace<T>(handle, std::forward<Args>(args)...);
T& component =
scene->registry.emplace<T>(handle, std::forward<Args>(args)...);
// scene->OnComponentAdded<T>(*this, component);
return component;
}
template <typename T>
T& getComponent()
{
T& getComponent() {
SOPHIA_ASSERT(hasComponent<T>(), "Entity does not have component!");
return scene->registry.get<T>(handle);
}
template <typename T>
bool hasComponent()
{
bool hasComponent() {
return scene->registry.all_of<T>(handle);
}
template <typename T>
void removeComponent()
{
void removeComponent() {
SOPHIA_ASSERT(hasComponent<T>(), "Entity does not have component!");
scene->registry.remove<T>(handle);
}
@@ -54,9 +52,7 @@ public:
return handle == other.handle && scene == other.scene;
}
bool operator!=(const Entity& other) const {
return !(*this == other);
}
bool operator!=(const Entity& other) const { return !(*this == other); }
private:
entt::entity handle{entt::null};
+7 -5
View File
@@ -1,7 +1,7 @@
#include "rendering/scene_renderer.hpp"
#include <sophia/util/assert.hpp>
#include <sophia/components.hpp>
#include <sophia/util/assert.hpp>
namespace sophia {
@@ -10,17 +10,19 @@ namespace {
glm::mat4 transform{1.f};
glm::vec4 color{1.f};
};
}
} // namespace
SceneRenderer::SceneRenderer(ResourceRegistry& resources)
: resources{resources} {}
SceneRenderer::~SceneRenderer() {}
void SceneRenderer::render(const Scene& scene, Entity camera, RenderTargetHandle target) {
SOPHIA_ASSERT(camera.hasComponent<CameraComponent>(), "camera does not have camera component!");
void SceneRenderer::render(const Scene& scene, Entity camera,
RenderTargetHandle target) {
SOPHIA_ASSERT(camera.hasComponent<CameraComponent>(),
"camera does not have camera component!");
auto& R = scene.registry;
auto& registry = scene.registry;
// Get all mesh
// For each mesh, get all entities(ES) that have a transform and that mesh