Text Rendering works

This commit is contained in:
Dynamitos
2022-04-15 23:45:44 +02:00
parent eb23264c40
commit 03e1a5784d
70 changed files with 1178 additions and 476 deletions
+16 -4
View File
@@ -30,6 +30,10 @@ void FontAsset::save()
assert(false && "Cannot save font files");
}
// in case of the space character there is no bitmap
// so we create a single pixel empty texture
uint8 transparentPixel = 0;
void FontAsset::load()
{
FT_Library ft;
@@ -43,18 +47,26 @@ void FontAsset::load()
if(FT_Load_Char(face, c, FT_LOAD_RENDER))
{
std::cout << "error loading " << (char)c << std::endl;
continue;
}
Glyph& glyph = glyphs[c];
glyph.size = IVector2(face->glyph->bitmap.width, face->glyph->bitmap.rows);
glyph.bearing = IVector2(face->glyph->bitmap_left, face->glyph->bitmap_top);
glyph.advance = face->glyph->advance.x;
TextureCreateInfo imageData;
imageData.format = Gfx::SE_FORMAT_R8_UINT;
imageData.width = face->glyph->bitmap.width;
imageData.height = face->glyph->bitmap.rows;
imageData.resourceData.data = face->glyph->bitmap.buffer;
imageData.resourceData.size = imageData.width * imageData.height;
Glyph& glyph = glyphs[c];
if(imageData.width == 0 || imageData.width == 0)
{
imageData.width = 1;
imageData.height = 1;
imageData.resourceData.size = sizeof(uint8);
imageData.resourceData.data = &transparentPixel;
}
glyph.texture = graphics->createTexture2D(imageData);
glyph.size = IVector2(face->glyph->bitmap.width, face->glyph->bitmap.rows);
glyph.bearing = IVector2(face->glyph->bitmap_left, face->glyph->bitmap_top);
glyph.advance = face->glyph->advance.x;
}
FT_Done_Face(face);
FT_Done_FreeType(ft);
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "MinimalEngine.h"
#include "Containers/List.h"
#include "ThreadPool.h"
#include <filesystem>
namespace Seele
+1 -1
View File
@@ -32,7 +32,7 @@ void MaterialLoader::import(std::filesystem::path, PMaterialAsset asset)
asset->load();
graphics->getShaderCompiler()->registerMaterial(asset);
AssetRegistry::get().registerMaterial(asset);
//co_return;
////co_return;
}
PMaterialAsset MaterialLoader::getPlaceHolderMaterial()
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "MinimalEngine.h"
#include "Containers/List.h"
#include "ThreadPool.h"
#include <filesystem>
namespace Seele
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "MinimalEngine.h"
#include "Containers/List.h"
#include "ThreadPool.h"
#include <filesystem>
struct aiScene;
+1 -1
View File
@@ -71,5 +71,5 @@ void TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsse
textureAsset->load();
textureAsset->setStatus(Asset::Status::Ready);
//co_return;
////co_return;
}
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "MinimalEngine.h"
#include "Containers/List.h"
#include "ThreadPool.h"
#include <filesystem>
namespace Seele