feat: initial DX12 foundation framework
This commit is contained in:
84
EngineTest/Lights.cpp
Normal file
84
EngineTest/Lights.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file Lights.cpp
|
||||
* @brief 渲染测试场景灯光创建与销毁逻辑。
|
||||
*/
|
||||
#include "EngineAPI/GameEntity.h"
|
||||
#include "EngineAPI/Light.h"
|
||||
#include "EngineAPI/TransformComponent.h"
|
||||
#include "Graphics_Beta/Renderer.h"
|
||||
#include "Test.h"
|
||||
|
||||
#if TEST_RENDERER
|
||||
|
||||
using namespace XEngine;
|
||||
|
||||
game_entity::entity create_one_game_entity(math::v3 position, math::v3 rotation, const char* script_name);
|
||||
void remove_game_entity(game_entity::entity_id id);
|
||||
|
||||
const u64 left_set{ 0 };
|
||||
const u64 right_set{ 1 };
|
||||
|
||||
utl::vector<graphics::light> lights;
|
||||
|
||||
constexpr math::v3
|
||||
rgb_to_color(u8 r, u8 g, u8 b) { return { r / 255.f, g / 255.f, b / 255.f }; }
|
||||
|
||||
void
|
||||
generate_lights()
|
||||
{
|
||||
// LEFT_SET
|
||||
graphics::light_init_info info{};
|
||||
info.entity_id = create_one_game_entity({}, {}, nullptr).get_id();
|
||||
info.type = graphics::light::directioinal;
|
||||
info.light_set_key = left_set;
|
||||
info.intensity = 1.f;
|
||||
info.color = rgb_to_color(174, 174, 174);
|
||||
|
||||
lights.emplace_back(graphics::create_light(info));
|
||||
|
||||
info.entity_id = create_one_game_entity({}, { math::pi * 0.5f,0,0 }, nullptr).get_id();
|
||||
info.color = rgb_to_color(17, 27, 28);
|
||||
lights.emplace_back(graphics::create_light(info));
|
||||
|
||||
|
||||
info.entity_id = create_one_game_entity({}, { -math::pi * 0.5f,0,0 }, nullptr).get_id();
|
||||
info.color = rgb_to_color(63, 47, 38);
|
||||
lights.emplace_back(graphics::create_light(info));
|
||||
|
||||
|
||||
//// RIGHT_SET
|
||||
//info.entity_id = create_one_game_entity({}, {}, nullptr).get_id();
|
||||
//info.type = graphics::light::directioinal;
|
||||
//info.light_set_key = right_set;
|
||||
//info.intensity = 1.f;
|
||||
//info.color = rgb_to_color(174, 174, 174);
|
||||
|
||||
//lights.emplace_back(graphics::create_light(info));
|
||||
|
||||
//info.entity_id = create_one_game_entity({}, { math::pi * 0.5f,0,0 }, nullptr).get_id();
|
||||
//info.color = rgb_to_color(17, 27, 28);
|
||||
//lights.emplace_back(graphics::create_light(info));
|
||||
|
||||
|
||||
//info.entity_id = create_one_game_entity({}, { -math::pi * 0.5f,0,0 }, nullptr).get_id();
|
||||
//info.color = rgb_to_color(63, 47, 38);
|
||||
//lights.emplace_back(graphics::create_light(info));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
remove_lights()
|
||||
{
|
||||
for (auto& light : lights)
|
||||
{
|
||||
const game_entity::entity_id id{ light.entity_id() };
|
||||
graphics::remove_light(light.get_id(), light.get_light_set_key());
|
||||
remove_game_entity(id);
|
||||
}
|
||||
|
||||
lights.clear();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user