-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from AGH-Code-Industry/twarug/nvrhi_renderer
Basic nvrhi renderer
- Loading branch information
Showing
84 changed files
with
4,185 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#pragma once | ||
|
||
#include <Ecs.h> | ||
#include <Engine.h> | ||
#include <Scene.h> | ||
|
||
struct VelocityComponent { | ||
arch::math::float3 velocity; | ||
}; | ||
|
||
class NvrhiRendererTestApp: public arch::Application { | ||
void init() override { | ||
arch::Ref<arch::scene::Scene> testScene = arch::createRef<arch::scene::Scene>(); | ||
|
||
{ | ||
arch::ecs::Entity e = testScene->newEntity(); | ||
testScene->domain().addComponent<arch::scene::components::TransformComponent>( | ||
e, | ||
{ | ||
{ 0.0f, 0.0f, 0.0f }, | ||
{ 0.0f, 0.0f, 0.0f, 1.0f }, | ||
{ 1.0f, .5f, 0.0f }, | ||
} | ||
); | ||
|
||
// 2D square | ||
// struct Vertex { | ||
// float3 position; | ||
// float3 color; | ||
// float2 tex_coords; | ||
// }; | ||
|
||
// std::vector<Vertex> vertices{ | ||
// { float3(0.5f, 0.5f, 0.0f), {}, float2(1.0f, 1.0f) }, | ||
// { float3(0.5f, -0.5f, 0.0f), {}, float2(1.0f, 0.0f) }, | ||
// { float3(-0.5f, -0.5f, 0.0f), {}, float2(0.0f, 0.0f) }, | ||
// { float3(-0.5f, 0.5f, 0.0f), {}, float2(0.0f, 1.0f) } | ||
// }; | ||
// std::vector<u32> indices{ 0, 1, 3, 1, 2, 3 }; | ||
|
||
// Ref<Shader> vShader = Shader::load("shaders/vertex_shader.sprv"); | ||
// Ref<Shader> fShader = Shader::load("shaders/fragment_shader.sprv"); | ||
// Ref<Material> material = Material::create(vShader, fShader); | ||
// material->setTexture("_mainTxt", TextureLoader::read_file("textures/.jpg")); | ||
// material->SetFloat("_mixValue", 0.2f); | ||
// material->SetFloat3("_pos", glm::vec3(0.5f, 0.5f, 0.5f)); | ||
// material->SetColor("_color", glm::vec3(1.0f, 0.0f, 0.0f)); | ||
|
||
// Ref<Mesh> mesh = Mesh::create<Vertex>(vertices, indices); | ||
testScene->domain().addComponent<arch::scene::components::MeshComponent>(e, { /*mesh*/ }); | ||
testScene->domain().addComponent<VelocityComponent>(e, arch::float3{ 0.0f, .01f, 0.0f }); | ||
} | ||
|
||
{ | ||
arch::ecs::Entity e = testScene->newEntity(); | ||
testScene->domain().addComponent<arch::scene::components::TransformComponent>( | ||
e, | ||
{ | ||
{ 0.5f, 0.5f, 0.0f }, | ||
{ 0.0f, 0.0f, 0.0f, 1.0f }, | ||
arch::float3(1) | ||
} | ||
); | ||
testScene->domain().addComponent<arch::scene::components::MeshComponent>(e, { /*mesh*/ }); | ||
testScene->domain().addComponent<VelocityComponent>(e, arch::float3{ 0.0f, -.01f, 0.001f }); | ||
} | ||
|
||
arch::scene::SceneManager::get()->changeScene(testScene); | ||
} | ||
|
||
void update() override { | ||
auto view = arch::scene::SceneManager::get() | ||
->currentScene() | ||
->domain() | ||
.view<arch::scene::components::TransformComponent, VelocityComponent>(); | ||
|
||
for (auto [entity, transform, velocity] : view.all()) { | ||
if (transform.position.y < -.5f || transform.position.y > .5f) { | ||
velocity.velocity *= -1; | ||
} | ||
if (transform.position.x < -.5f || transform.position.x > .5f) { | ||
velocity.velocity.x *= -1; | ||
} | ||
|
||
transform.position.x += velocity.velocity.x; | ||
transform.position.y += velocity.velocity.y; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include "gfx/Buffer.h" | ||
#include "gfx/Mesh.h" | ||
#include "gfx/Renderer.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include "math/Math.h" | ||
|
||
namespace arch { | ||
|
||
using namespace arch::math; | ||
|
||
} // namespace arch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,4 @@ | ||
#pragma once | ||
|
||
#include <Ecs.h> | ||
#include <Hier.h> | ||
|
||
namespace arch { | ||
|
||
class Scene { | ||
public: | ||
|
||
/// @brief Hierarchy node class | ||
using Node = hier::HierarchyNode; | ||
|
||
/// @brief Default constructor | ||
Scene() noexcept; | ||
|
||
/// @brief Creates new entity | ||
/// @see arch::ecs::Domain::newEntity() | ||
ecs::Entity newEntity() noexcept; | ||
/// @brief Kills entity | ||
/// @see arch::ecs::Domain::kill(const ecs::Entity) | ||
void removeEntity(const ecs::Entity entity) noexcept; | ||
|
||
/// @brief Returns ecs::Domain of this scene | ||
ecs::Domain& domain() noexcept; | ||
/// @brief Returns readonly ecs::Domain of this scene | ||
const ecs::Domain& domain() const noexcept; | ||
|
||
/// @brief Returns root entity | ||
ecs::Entity root() const noexcept; | ||
/// @brief Returns root node | ||
Node& rootNode() noexcept; | ||
/// @brief Returns readonly root node | ||
const Node& rootNode() const noexcept; | ||
|
||
private: | ||
|
||
ecs::Domain _domain; | ||
Node* _rootNode; | ||
}; | ||
|
||
} // namespace arch | ||
#include "scene/Components.h" | ||
#include "scene/Scene.h" | ||
#include "scene/SceneManager.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include "buffer/Buffer.h" | ||
#include "buffer/BufferManager.h" | ||
#include "buffer/BufferType.h" | ||
#include "buffer/IndexBuffer.h" | ||
#include "buffer/VertexBuffer.h" | ||
|
||
namespace arch::gfx { | ||
|
||
using namespace arch::gfx::buffer; | ||
|
||
} // namespace arch::gfx |
Oops, something went wrong.