Fixed some bugs but SHFont constructor still breaks

the vkImage is not loading correctly
This commit is contained in:
Brandon Mak 2022-11-15 20:40:43 +08:00
parent b6bae850bf
commit 292fdf4ee2
6 changed files with 22 additions and 15 deletions

View File

@ -148,7 +148,7 @@ namespace Sandbox
SHFrameRateController::UpdateFRC(); SHFrameRateController::UpdateFRC();
//std::system("FontCompiler.exe ../../Assets/Fonts/SegoeUI.ttf"); std::system("FontCompiler.exe ../../Assets/Fonts/SegoeUI.ttf");
// Link up SHDebugDraw // Link up SHDebugDraw
SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>()); SHDebugDraw::Init(SHSystemManager::GetSystem<SHDebugDrawSystem>());

View File

@ -48,15 +48,17 @@ namespace SHADE
// read the height // read the height
file.read(reinterpret_cast<char*>(&newFontAsset->bitmapHeight), sizeof(SHFontAsset::bitmapHeight)); file.read(reinterpret_cast<char*>(&newFontAsset->bitmapHeight), sizeof(SHFontAsset::bitmapHeight));
uint32_t bytesRequired = newFontAsset->bitmapWidth * newFontAsset->bitmapHeight * SHFontAsset::BYTES_PER_CHANNEL * SHFontAsset::NUM_CHANNELS; uint32_t bytesRequired = 0;
file.read(reinterpret_cast<char*>(&bytesRequired), sizeof(uint32_t));
// Read the bitmap // Read the bitmap
newFontAsset->bitmapData.resize(bytesRequired); newFontAsset->bitmapData.resize(bytesRequired);
file.read(reinterpret_cast<char*>(newFontAsset->bitmapData.data()), bytesRequired); file.read(reinterpret_cast<char*>(newFontAsset->bitmapData.data()), bytesRequired);
file.close(); file.close();
return nullptr; return newFontAsset;
} }
void SHFontLoader::Write(SHAssetData const* data, AssetPath path) void SHFontLoader::Write(SHAssetData const* data, AssetPath path)

View File

@ -130,6 +130,7 @@ namespace SHADE
static constexpr AssetID SSAO_BLUR = 39760835; ssaoBlurShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(SSAO_BLUR); static constexpr AssetID SSAO_BLUR = 39760835; ssaoBlurShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(SSAO_BLUR);
static constexpr AssetID TEXT_VS = 39816727; textVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_VS); static constexpr AssetID TEXT_VS = 39816727; textVS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_VS);
static constexpr AssetID TEXT_FS = 38024754; textFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_FS); static constexpr AssetID TEXT_FS = 38024754; textFS = SHResourceManager::LoadOrGet<SHVkShaderModule>(TEXT_FS);
static constexpr AssetID SEGOE_UI_FONT = 176667660; testFont = SHResourceManager::LoadOrGet<SHFont>(SEGOE_UI_FONT);
} }
void SHGraphicsSystem::InitSceneRenderGraph(void) noexcept void SHGraphicsSystem::InitSceneRenderGraph(void) noexcept

View File

@ -437,6 +437,8 @@ namespace SHADE
Handle<SHVkShaderModule> textVS; Handle<SHVkShaderModule> textVS;
Handle<SHVkShaderModule> textFS; Handle<SHVkShaderModule> textFS;
// Fonts
Handle<SHFont> testFont;
// Built-In Materials // Built-In Materials
Handle<SHMaterial> defaultMaterial; Handle<SHMaterial> defaultMaterial;

View File

@ -42,12 +42,14 @@ namespace SHADE
.depth = 1, .depth = 1,
.levels = 1, .levels = 1,
.arrayLayers = 1, .arrayLayers = 1,
//.imageFormat = vk::Format::eR8G8B8Snorm,
//.imageFormat = vk::Format::eR32Sfloat,
.imageFormat = vk::Format::eR32G32B32Sfloat, .imageFormat = vk::Format::eR32G32B32Sfloat,
.usageFlags = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst, .usageFlags = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst,
.createFlags = {} .createFlags = {}
}; };
uint32_t bytesRequired = fontAsset.bitmapWidth * fontAsset.bitmapHeight * SHFontAsset::BYTES_PER_CHANNEL * SHFontAsset::NUM_CHANNELS; uint32_t bytesRequired = asset.bitmapData.size();
uint32_t mipOffset = 0; uint32_t mipOffset = 0;
// Create the image // Create the image

View File

@ -316,7 +316,7 @@ namespace SHADE
return matHandle; return matHandle;
} }
else if constexpr (std::is_same_v<ResourceType, SHFontAsset>) else if constexpr (std::is_same_v<ResourceType, SHFont>)
{ {
loadedAssetData.emplace_back(assetId); loadedAssetData.emplace_back(assetId);
textureChanged = true; textureChanged = true;