Renamed SHTextRenderer and to SHTextRenderable and added C# interface #239
|
@ -13,7 +13,7 @@
|
|||
#include "Physics/Interface/SHRigidBodyComponent.h"
|
||||
#include "Physics/Interface/SHColliderComponent.h"
|
||||
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRendererComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||
|
||||
#include "Assets/SHAssetManager.h"
|
||||
#include "Camera/SHCameraComponent.h"
|
||||
|
|
|
@ -497,11 +497,11 @@ namespace SHADE
|
|||
}
|
||||
|
||||
template<>
|
||||
static void DrawComponent(SHTextRendererComponent* component)
|
||||
static void DrawComponent(SHTextRenderableComponent* component)
|
||||
{
|
||||
if (!component)
|
||||
return;
|
||||
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHTextRendererComponent>());
|
||||
ImGui::PushID(SHFamilyID<SHComponent>::GetID<SHTextRenderableComponent>());
|
||||
const auto componentType = rttr::type::get(*component);
|
||||
SHEditorWidgets::CheckBox("##IsActive", [component]() {return component->isActive; }, [component](bool const& active) {component->isActive = active; }, "Is Component Active");
|
||||
ImGui::SameLine();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "UI/SHCanvasComponent.h"
|
||||
#include "SHEditorComponentView.h"
|
||||
#include "AudioSystem/SHAudioListenerComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRendererComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ namespace SHADE
|
|||
{
|
||||
DrawComponent(uiComponent);
|
||||
}
|
||||
if (auto textRendererComponent = SHComponentManager::GetComponent_s<SHTextRendererComponent>(eid))
|
||||
if (auto textRendererComponent = SHComponentManager::GetComponent_s<SHTextRenderableComponent>(eid))
|
||||
{
|
||||
DrawComponent(textRendererComponent);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ namespace SHADE
|
|||
DrawAddComponentWithEnforcedComponentButton<SHRenderable, SHTransformComponent>(eid);
|
||||
DrawAddComponentWithEnforcedComponentButton<SHRigidBodyComponent, SHTransformComponent>(eid);
|
||||
DrawAddComponentWithEnforcedComponentButton<SHColliderComponent, SHTransformComponent>(eid);
|
||||
DrawAddComponentWithEnforcedComponentButton<SHTextRendererComponent, SHTransformComponent>(eid);
|
||||
DrawAddComponentWithEnforcedComponentButton<SHTextRenderableComponent, SHTransformComponent>(eid);
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHTextRendererComponent.h"
|
||||
#include "SHTextRenderableComponent.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
||||
void SHTextRendererComponent::MakeDirty(void) noexcept
|
||||
void SHTextRenderableComponent::MakeDirty(void) noexcept
|
||||
{
|
||||
requiresRecompute = true;
|
||||
}
|
||||
|
||||
void SHTextRendererComponent::Clean(void) noexcept
|
||||
void SHTextRenderableComponent::Clean(void) noexcept
|
||||
{
|
||||
requiresRecompute = false;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace SHADE
|
|||
|
||||
*/
|
||||
/***************************************************************************/
|
||||
void SHTextRendererComponent::OnCreate(void)
|
||||
void SHTextRenderableComponent::OnCreate(void)
|
||||
{
|
||||
text = "My name is Brandon.";
|
||||
requiresRecompute = true;
|
||||
|
@ -31,7 +31,7 @@ namespace SHADE
|
|||
color = SHColour::WHITE;
|
||||
}
|
||||
|
||||
void SHTextRendererComponent::OnDestroy(void)
|
||||
void SHTextRenderableComponent::OnDestroy(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -49,13 +49,13 @@ namespace SHADE
|
|||
|
||||
*/
|
||||
/***************************************************************************/
|
||||
void SHTextRendererComponent::SetText(std::string_view newText) noexcept
|
||||
void SHTextRenderableComponent::SetText(std::string_view newText) noexcept
|
||||
{
|
||||
text = newText;
|
||||
MakeDirty();
|
||||
}
|
||||
|
||||
void SHTextRendererComponent::SetFont(Handle<SHFont> font) noexcept
|
||||
void SHTextRenderableComponent::SetFont(Handle<SHFont> font) noexcept
|
||||
{
|
||||
fontHandle = font;
|
||||
MakeDirty();
|
||||
|
@ -72,12 +72,12 @@ namespace SHADE
|
|||
|
||||
*/
|
||||
/***************************************************************************/
|
||||
std::string const& SHTextRendererComponent::GetText(void) const noexcept
|
||||
std::string const& SHTextRenderableComponent::GetText(void) const noexcept
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
Handle<SHFont> SHTextRendererComponent::GetFont(void) const noexcept
|
||||
Handle<SHFont> SHTextRenderableComponent::GetFont(void) const noexcept
|
||||
{
|
||||
return fontHandle;
|
||||
}
|
||||
|
@ -90,6 +90,6 @@ namespace rttr
|
|||
{
|
||||
using namespace SHADE;
|
||||
|
||||
registration::class_<SHTextRendererComponent>("Text Renderer Component");
|
||||
registration::class_<SHTextRenderableComponent>("Text Renderer Component");
|
||||
};
|
||||
}
|
|
@ -13,7 +13,7 @@ namespace SHADE
|
|||
class SHVkDescriptorSetGroup;
|
||||
class SHVkBuffer;
|
||||
|
||||
class SH_API SHTextRendererComponent final : public SHComponent
|
||||
class SH_API SHTextRenderableComponent final : public SHComponent
|
||||
{
|
||||
public:
|
||||
static constexpr uint32_t MAX_CHARACTERS = 500;
|
|
@ -1,6 +1,6 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHTextRenderingSubSystem.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRendererComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||
#include "Math/Vector/SHVec4.h"
|
||||
#include "Graphics/Devices/SHVkLogicalDevice.h"
|
||||
|
@ -14,20 +14,20 @@
|
|||
|
||||
namespace SHADE
|
||||
{
|
||||
void SHTextRenderingSubSystem::RecomputePositions(SHTextRendererComponent& textComp) noexcept
|
||||
void SHTextRenderingSubSystem::RecomputePositions(SHTextRenderableComponent& textComp) noexcept
|
||||
{
|
||||
if (textComp.text.empty() || !textComp.fontHandle)
|
||||
return;
|
||||
|
||||
// Create the buffer
|
||||
if (!textComp.indexingDataBuffer)
|
||||
textComp.indexingDataBuffer = logicalDevice->CreateBuffer(SHTextRendererComponent::MAX_CHARACTERS * sizeof(uint32_t), nullptr, SHTextRendererComponent::MAX_CHARACTERS * sizeof(uint32_t), vk::BufferUsageFlagBits::eVertexBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
|
||||
textComp.indexingDataBuffer = logicalDevice->CreateBuffer(SHTextRenderableComponent::MAX_CHARACTERS * sizeof(uint32_t), nullptr, SHTextRenderableComponent::MAX_CHARACTERS * sizeof(uint32_t), vk::BufferUsageFlagBits::eVertexBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
|
||||
|
||||
if (!textComp.charPositionDataBuffer)
|
||||
textComp.charPositionDataBuffer = logicalDevice->CreateBuffer(SHTextRendererComponent::MAX_CHARACTERS * sizeof(SHVec4), nullptr, SHTextRendererComponent::MAX_CHARACTERS * sizeof(SHVec4), vk::BufferUsageFlagBits::eVertexBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
|
||||
textComp.charPositionDataBuffer = logicalDevice->CreateBuffer(SHTextRenderableComponent::MAX_CHARACTERS * sizeof(SHVec4), nullptr, SHTextRenderableComponent::MAX_CHARACTERS * sizeof(SHVec4), vk::BufferUsageFlagBits::eVertexBuffer, VMA_MEMORY_USAGE_AUTO, VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
|
||||
|
||||
// For indexing font transformation in the shader
|
||||
std::vector <SHTextRendererComponent::TextIndexingType> indexingData;
|
||||
std::vector <SHTextRenderableComponent::TextIndexingType> indexingData;
|
||||
|
||||
// For placing glyphs correctly
|
||||
std::vector <SHVec4> charPositionData;
|
||||
|
@ -49,7 +49,7 @@ namespace SHADE
|
|||
// for every character
|
||||
for (uint32_t i = 0; i < numChars; ++i)
|
||||
{
|
||||
SHTextRendererComponent::TextIndexingType index = glyphTransformIndices.at(textComp.text[i]);
|
||||
SHTextRenderableComponent::TextIndexingType index = glyphTransformIndices.at(textComp.text[i]);
|
||||
|
||||
// Copy baseline
|
||||
SHVec4 characterPos = baselineOrigin;
|
||||
|
@ -83,7 +83,7 @@ namespace SHADE
|
|||
//}
|
||||
}
|
||||
|
||||
textComp.indexingDataBuffer->WriteToMemory(indexingData.data(), static_cast<uint32_t>(indexingData.size()) * sizeof (SHTextRendererComponent::TextIndexingType),0, 0);
|
||||
textComp.indexingDataBuffer->WriteToMemory(indexingData.data(), static_cast<uint32_t>(indexingData.size()) * sizeof (SHTextRenderableComponent::TextIndexingType),0, 0);
|
||||
textComp.charPositionDataBuffer->WriteToMemory(charPositionData.data(), static_cast<uint32_t>(charPositionData.size()) * sizeof (SHVec4), 0, 0);
|
||||
|
||||
indexingData.clear();
|
||||
|
@ -93,7 +93,7 @@ namespace SHADE
|
|||
|
||||
void SHTextRenderingSubSystem::Init(Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkDescriptorPool> descPool, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS, std::function<void(Handle<SHVkCommandBuffer>, uint32_t)> const& bindFunction) noexcept
|
||||
{
|
||||
SHComponentManager::CreateComponentSparseSet<SHTextRendererComponent>();
|
||||
SHComponentManager::CreateComponentSparseSet<SHTextRenderableComponent>();
|
||||
|
||||
cameraDescSetBind = bindFunction;
|
||||
|
||||
|
@ -179,7 +179,7 @@ namespace SHADE
|
|||
|
||||
void SHTextRenderingSubSystem::Run(uint32_t frameIndex) noexcept
|
||||
{
|
||||
auto& textRendererComps = SHComponentManager::GetDense<SHTextRendererComponent>();
|
||||
auto& textRendererComps = SHComponentManager::GetDense<SHTextRenderableComponent>();
|
||||
|
||||
for (auto& comp : textRendererComps)
|
||||
{
|
||||
|
@ -194,7 +194,7 @@ namespace SHADE
|
|||
|
||||
void SHTextRenderingSubSystem::Render(Handle<SHVkCommandBuffer> cmdBuffer, uint32_t frameIndex) noexcept
|
||||
{
|
||||
auto& textRendererComps = SHComponentManager::GetDense<SHTextRendererComponent>();
|
||||
auto& textRendererComps = SHComponentManager::GetDense<SHTextRenderableComponent>();
|
||||
for (auto& comp : textRendererComps)
|
||||
{
|
||||
auto* transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID());
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace SHADE
|
|||
class SHVkBuffer;
|
||||
class SHLightComponent;
|
||||
class SHVkCommandBuffer;
|
||||
class SHTextRendererComponent;
|
||||
class SHTextRenderableComponent;
|
||||
class SHVkPipeline;
|
||||
class SHVkPipelineLayout;
|
||||
class SHVkRenderpass;
|
||||
|
@ -48,7 +48,7 @@ namespace SHADE
|
|||
std::function<void(Handle<SHVkCommandBuffer>, uint32_t)> cameraDescSetBind;
|
||||
|
||||
private:
|
||||
void RecomputePositions(SHTextRendererComponent& textComp) noexcept;
|
||||
void RecomputePositions(SHTextRenderableComponent& textComp) noexcept;
|
||||
|
||||
public:
|
||||
void Init(Handle<SHVkLogicalDevice> device, Handle<SHVkRenderpass> compatibleRenderpass, Handle<SHSubpass> subpass, Handle<SHVkDescriptorPool> descPool, Handle<SHVkShaderModule> textVS, Handle<SHVkShaderModule> textFS, std::function<void(Handle<SHVkCommandBuffer>, uint32_t)> const& bindFunction) noexcept;
|
||||
|
|
|
@ -211,7 +211,7 @@ namespace SHADE
|
|||
AddComponentToComponentNode<SHLightComponent>(components, eid);
|
||||
AddComponentToComponentNode<SHRigidBodyComponent>(components, eid);
|
||||
AddConvComponentToComponentNode<SHColliderComponent>(components, eid);
|
||||
AddConvComponentToComponentNode<SHTextRendererComponent>(components, eid);
|
||||
AddConvComponentToComponentNode<SHTextRenderableComponent>(components, eid);
|
||||
|
||||
node[ComponentsNode] = components;
|
||||
|
||||
|
@ -263,7 +263,7 @@ namespace SHADE
|
|||
AddComponentID<SHRigidBodyComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHLightComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHColliderComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHTextRendererComponent>(componentIDList, componentsNode);
|
||||
AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode);
|
||||
|
||||
return componentIDList;
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ namespace SHADE
|
|||
SHSerializationHelper::InitializeComponentFromNode<SHRigidBodyComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::ConvertNodeToComponent<SHRenderable>(componentsNode, eid);
|
||||
SHSerializationHelper::ConvertNodeToComponent<SHColliderComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::ConvertNodeToComponent<SHTextRendererComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::ConvertNodeToComponent<SHTextRenderableComponent>(componentsNode, eid);
|
||||
SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
|
||||
#include "SHSerializationTools.h"
|
||||
#include "Physics/Interface/SHColliderComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRendererComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||
#include "Graphics/MiddleEnd/TextRendering/SHFont.h"
|
||||
|
||||
namespace YAML
|
||||
|
@ -327,12 +327,12 @@ namespace YAML
|
|||
};
|
||||
|
||||
template<>
|
||||
struct convert<SHTextRendererComponent>
|
||||
struct convert<SHTextRenderableComponent>
|
||||
{
|
||||
static constexpr std::string_view TEXT_YAML_TAG = "Text";
|
||||
static constexpr std::string_view FONT_YAML_TAG = "Font";
|
||||
|
||||
static YAML::Node encode(SHTextRendererComponent const& rhs)
|
||||
static YAML::Node encode(SHTextRenderableComponent const& rhs)
|
||||
{
|
||||
YAML::Node node;
|
||||
node[TEXT_YAML_TAG.data()] = rhs.GetText();
|
||||
|
@ -347,7 +347,7 @@ namespace YAML
|
|||
}
|
||||
return node;
|
||||
}
|
||||
static bool decode(YAML::Node const& node, SHTextRendererComponent& rhs)
|
||||
static bool decode(YAML::Node const& node, SHTextRenderableComponent& rhs)
|
||||
{
|
||||
if (node[TEXT_YAML_TAG.data()].IsDefined())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue