Shifted Graphics system to SBTestScene

This commit is contained in:
Brandon Mak 2022-09-21 16:29:54 +08:00
parent 80dc8d0a71
commit 270c8240c1
4 changed files with 32 additions and 17 deletions

View File

@ -21,6 +21,11 @@
#include "Graphics/MiddleEnd/Meshes/SHPrimitiveGenerator.h"
#include "ECS_Base/Managers/SHEntityManager.h"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Scene/SHSceneManager.h"
#include "Scenes/SBTestScene.h"
using namespace SHADE;
namespace Sandbox
{
@ -45,7 +50,7 @@ namespace Sandbox
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::RenderRoutine>();
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::EndRoutine>();
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHRenderable>();
graphicsSystem->SetWindow(&window);
sdlWindow = SDL_CreateWindowFrom(window.GetHWND());
@ -61,28 +66,17 @@ namespace Sandbox
// Set up scripting
SHADE::SHScriptEngine::Init();
// Create temp meshes
const auto CUBE_MESH = SHADE::SHPrimitiveGenerator::Cube(*graphicsSystem);
graphicsSystem->BuildMeshBuffers();
// Create Materials
auto matInst = graphicsSystem->AddMaterialInstance();
// Create entity and add mesh
auto entity = SHADE::SHEntityManager::CreateEntity<SHADE::SHRenderable>();
auto& renderable = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHRenderable>(entity);
renderable.Mesh = CUBE_MESH;
renderable.SetMaterial(matInst);
renderable.TransformMatrix.Translate(0.0f, 0.0f, 2.0f);
SHSceneManager::InitSceneManager<SBTestScene>("TestScene");
}
void SBApplication::Update(void)
{
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
//TODO: Change true to window is open
while (!window.WindowShouldClose())
{
SHSceneManager::UpdateSceneManager();
SHSceneManager::SceneUpdate(1/60.0f);
//#ifdef SHEDITOR
//#endif
graphicsSystem->BeginRender();
@ -108,7 +102,7 @@ namespace Sandbox
#ifdef SHEDITOR
SHADE::SHEditor::Exit();
#endif
SHSceneManager::Exit();
SHADE::SHScriptEngine::Exit();
SHADE::SHSystemManager::Exit();
SDL_DestroyWindow(sdlWindow);

View File

@ -1,6 +1,13 @@
#include "SBpch.h"
#include "SBTestScene.h"
#include "ECS_Base/Managers/SHSystemManager.h"
#include "Graphics/MiddleEnd/Meshes/SHPrimitiveGenerator.h"
#include "ECS_Base/Managers/SHEntityManager.h"
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
#include "Scene/SHSceneManager.h"
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
using namespace SHADE;
namespace Sandbox
@ -21,7 +28,20 @@ namespace Sandbox
}
void SBTestScene::Init()
{
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
// Create temp meshes
const auto CUBE_MESH = SHADE::SHPrimitiveGenerator::Cube(*graphicsSystem);
graphicsSystem->BuildMeshBuffers();
// Create Materials
auto matInst = graphicsSystem->AddMaterialInstance();
// Create entity and add mesh
auto entity = SHADE::SHEntityManager::CreateEntity<SHADE::SHRenderable>();
auto& renderable = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHRenderable>(entity);
renderable.Mesh = CUBE_MESH;
renderable.SetMaterial(matInst);
renderable.TransformMatrix.Translate(0.0f, 0.0f, 2.0f);
}
void SBTestScene::Update(float dt)
{

View File

@ -8,7 +8,7 @@
* of DigiPen Institute of Technology is prohibited.
****************************************************************************************/
#include <SHpch.h>
#include "SHpch.h"
// Primary Header
#include "SHSceneGraph.h"

View File

@ -16,6 +16,7 @@
#include "ECS_Base/General/SHFamily.h"
#include "SHScene.h"
#include <functional>
#include "SH_API.h"
namespace SHADE
{