mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-01-11 14:43:34 +00:00
fixing engine issue
This commit is contained in:
@@ -37,40 +37,6 @@ int main(int ac, char** av)
|
|||||||
Scop::Vec2ui32 skybox_size;
|
Scop::Vec2ui32 skybox_size;
|
||||||
main_scene.AddSkybox(std::make_shared<Scop::CubeTexture>(Scop::LoadBMPFile(GetResourcesPath() / "skybox.bmp", skybox_size), skybox_size.x, skybox_size.y));
|
main_scene.AddSkybox(std::make_shared<Scop::CubeTexture>(Scop::LoadBMPFile(GetResourcesPath() / "skybox.bmp", skybox_size), skybox_size.x, skybox_size.y));
|
||||||
|
|
||||||
Scop::Actor& object = main_scene.CreateActor(Scop::LoadModelFromObjFile(GetResourcesPath() / "knuckles.obj"));
|
|
||||||
object.SetScale(Scop::Vec3f{ 5.0f, 5.0f, 5.0f });
|
|
||||||
|
|
||||||
Scop::Actor& object2 = main_scene.CreateActor(Scop::CreateSphere());
|
|
||||||
object2.SetScale(Scop::Vec3f{ 5.0f, 5.0f, 5.0f });
|
|
||||||
object2.SetPosition(Scop::Vec3f{ 10.0f, 10.0f, 10.0f });
|
|
||||||
|
|
||||||
Scop::Vec2ui32 map_size;
|
|
||||||
|
|
||||||
Scop::MaterialTextures material_params;
|
|
||||||
material_params.albedo = std::make_shared<Scop::Texture>(Scop::LoadBMPFile(GetResourcesPath() / "knuckles.bmp", map_size), map_size.x, map_size.y);
|
|
||||||
|
|
||||||
std::shared_ptr<Scop::Material> material = std::make_shared<Scop::Material>(material_params);
|
|
||||||
object.GetModelRef().SetMaterial(material, 0);
|
|
||||||
|
|
||||||
auto object_update = [](Scop::NonOwningPtr<Scop::Scene> scene, Scop::NonOwningPtr<Scop::Actor> actor, Scop::Inputs& input, float delta)
|
|
||||||
{
|
|
||||||
static Scop::MaterialData material_data{};
|
|
||||||
|
|
||||||
WireframeHandler(scene, input);
|
|
||||||
MovementHandler(actor, input, delta);
|
|
||||||
ColorsTransitionHandler(actor, input, delta, material_data);
|
|
||||||
TextureTransitionHandler(actor, input, delta, material_data);
|
|
||||||
|
|
||||||
for(std::shared_ptr<Scop::Material> material : actor->GetModelRef().GetAllMaterials())
|
|
||||||
{
|
|
||||||
if(material)
|
|
||||||
material->SetMaterialData(material_data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using actor_hook = std::function<void(Scop::NonOwningPtr<Scop::Actor>)>;
|
|
||||||
object.AttachScript(std::make_shared<Scop::NativeActorScript>(actor_hook{}, object_update, actor_hook{}));
|
|
||||||
|
|
||||||
engine.RegisterMainScene(splash_scene.get());
|
engine.RegisterMainScene(splash_scene.get());
|
||||||
engine.Run();
|
engine.Run();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 MiB |
35366
Resources/knuckles.obj
35366
Resources/knuckles.obj
File diff suppressed because it is too large
Load Diff
@@ -48,9 +48,7 @@ namespace Scop
|
|||||||
private:
|
private:
|
||||||
inline static std::size_t s_buffer_count = 0;
|
inline static std::size_t s_buffer_count = 0;
|
||||||
|
|
||||||
#ifdef SCOP_HAS_DEBUG_UTILS_FUNCTIONS
|
std::string m_name;
|
||||||
std::string m_name;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VkBufferUsageFlags m_usage = 0;
|
VkBufferUsageFlags m_usage = 0;
|
||||||
VkMemoryPropertyFlags m_flags = 0;
|
VkMemoryPropertyFlags m_flags = 0;
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ namespace Scop
|
|||||||
bool BindPipeline(VkCommandBuffer) noexcept override { return false; };
|
bool BindPipeline(VkCommandBuffer) noexcept override { return false; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
|
||||||
std::vector<NonOwningPtr<Texture>> m_attachments;
|
std::vector<NonOwningPtr<Texture>> m_attachments;
|
||||||
std::vector<VkFramebuffer> m_framebuffers;
|
std::vector<VkFramebuffer> m_framebuffers;
|
||||||
std::vector<VkClearValue> m_clears;
|
std::vector<VkClearValue> m_clears;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Scop
|
|||||||
class Shader
|
class Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Shader(const std::vector<std::uint32_t>& bytecode, ShaderType type, ShaderLayout layout);
|
Shader(const std::vector<std::uint32_t>& bytecode, ShaderType type, ShaderLayout layout, std::string shader_name = {});
|
||||||
|
|
||||||
[[nodiscard]] inline const ShaderLayout& GetShaderLayout() const { return m_layout; }
|
[[nodiscard]] inline const ShaderLayout& GetShaderLayout() const { return m_layout; }
|
||||||
[[nodiscard]] inline const std::vector<std::uint32_t>& GetByteCode() const noexcept { return m_bytecode; }
|
[[nodiscard]] inline const std::vector<std::uint32_t>& GetByteCode() const noexcept { return m_bytecode; }
|
||||||
@@ -64,6 +64,7 @@ namespace Scop
|
|||||||
void GeneratePipelineLayout(ShaderLayout layout);
|
void GeneratePipelineLayout(ShaderLayout layout);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string m_name;
|
||||||
ShaderLayout m_layout;
|
ShaderLayout m_layout;
|
||||||
ShaderPipelineLayoutPart m_pipeline_layout_part;
|
ShaderPipelineLayoutPart m_pipeline_layout_part;
|
||||||
std::vector<std::uint32_t> m_bytecode;
|
std::vector<std::uint32_t> m_bytecode;
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ namespace Scop
|
|||||||
p_renderer = descriptor.renderer;
|
p_renderer = descriptor.renderer;
|
||||||
p_depth = descriptor.depth;
|
p_depth = descriptor.depth;
|
||||||
|
|
||||||
m_name = descriptor.name;
|
|
||||||
std::cout << m_name << std::endl;
|
|
||||||
|
|
||||||
std::vector<VkPushConstantRange> push_constants;
|
std::vector<VkPushConstantRange> push_constants;
|
||||||
std::vector<VkDescriptorSetLayout> set_layouts;
|
std::vector<VkDescriptorSetLayout> set_layouts;
|
||||||
push_constants.insert(push_constants.end(), p_vertex_shader->GetPipelineLayout().push_constants.begin(), p_vertex_shader->GetPipelineLayout().push_constants.end());
|
push_constants.insert(push_constants.end(), p_vertex_shader->GetPipelineLayout().push_constants.begin(), p_vertex_shader->GetPipelineLayout().push_constants.end());
|
||||||
@@ -140,7 +137,6 @@ namespace Scop
|
|||||||
{
|
{
|
||||||
if(m_pipeline == VK_NULL_HANDLE)
|
if(m_pipeline == VK_NULL_HANDLE)
|
||||||
return;
|
return;
|
||||||
std::cout << m_name << std::endl;
|
|
||||||
RenderCore::Get().WaitDeviceIdle();
|
RenderCore::Get().WaitDeviceIdle();
|
||||||
|
|
||||||
for(auto& fb : m_framebuffers)
|
for(auto& fb : m_framebuffers)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace Scop
|
namespace Scop
|
||||||
{
|
{
|
||||||
Shader::Shader(const std::vector<std::uint32_t>& bytecode, ShaderType type, ShaderLayout layout) : m_bytecode(bytecode), m_layout(std::move(layout))
|
Shader::Shader(const std::vector<std::uint32_t>& bytecode, ShaderType type, ShaderLayout layout, std::string name) : m_name(std::move(name)), m_bytecode(bytecode), m_layout(std::move(layout))
|
||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
@@ -15,7 +15,16 @@ namespace Scop
|
|||||||
default : FatalError("wtf"); break;
|
default : FatalError("wtf"); break;
|
||||||
}
|
}
|
||||||
m_module = kvfCreateShaderModule(RenderCore::Get().GetDevice(), m_bytecode.data(), m_bytecode.size());
|
m_module = kvfCreateShaderModule(RenderCore::Get().GetDevice(), m_bytecode.data(), m_bytecode.size());
|
||||||
Message("Vulkan: shader module created");
|
Message("Vulkan: shader module % created", m_name);
|
||||||
|
|
||||||
|
#ifdef SCOP_HAS_DEBUG_UTILS_FUNCTIONS
|
||||||
|
VkDebugUtilsObjectNameInfoEXT name_info{};
|
||||||
|
name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
||||||
|
name_info.objectType = VK_OBJECT_TYPE_SHADER_MODULE;
|
||||||
|
name_info.objectHandle = reinterpret_cast<std::uint64_t>(m_module);
|
||||||
|
name_info.pObjectName = m_name.c_str();
|
||||||
|
RenderCore::Get().vkSetDebugUtilsObjectNameEXT(RenderCore::Get().GetDevice(), &name_info);
|
||||||
|
#endif
|
||||||
|
|
||||||
GeneratePipelineLayout(m_layout);
|
GeneratePipelineLayout(m_layout);
|
||||||
}
|
}
|
||||||
@@ -59,7 +68,7 @@ namespace Scop
|
|||||||
return;
|
return;
|
||||||
kvfDestroyShaderModule(RenderCore::Get().GetDevice(), m_module);
|
kvfDestroyShaderModule(RenderCore::Get().GetDevice(), m_module);
|
||||||
m_module = VK_NULL_HANDLE;
|
m_module = VK_NULL_HANDLE;
|
||||||
Message("Vulkan: shader module destroyed");
|
Message("Vulkan: shader module % destroyed", m_name);
|
||||||
for(auto& layout : m_set_layouts)
|
for(auto& layout : m_set_layouts)
|
||||||
{
|
{
|
||||||
kvfDestroyDescriptorSetLayout(RenderCore::Get().GetDevice(), layout);
|
kvfDestroyDescriptorSetLayout(RenderCore::Get().GetDevice(), layout);
|
||||||
@@ -84,7 +93,7 @@ namespace Scop
|
|||||||
data.push_back(part);
|
data.push_back(part);
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
std::shared_ptr<Shader> shader = std::make_shared<Shader>(data, type, layout);
|
std::shared_ptr<Shader> shader = std::make_shared<Shader>(data, type, layout, filepath.stem().string());
|
||||||
Message("Vulkan: shader loaded %", filepath);
|
Message("Vulkan: shader loaded %", filepath);
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user