add opportunity to pack atlas and meta data in same file
This commit is contained in:
@@ -67,13 +67,15 @@ namespace OpenVulkano
|
||||
m_drawablesPool.resize(N);
|
||||
|
||||
#ifdef MSDFGEN_AVAILABLE
|
||||
Charset charset = Charset::ASCII;
|
||||
for (unicode_t c = 0x0410; c <= 0x041F; c++)
|
||||
{
|
||||
// some unicode values
|
||||
charset.add(c);
|
||||
}
|
||||
m_atlasGenerator.GenerateAtlas(fontPath, charset, "roboto-regular-atlas.png");
|
||||
Charset charset = FontAtlasGenerator::LoadAllGlyphs(fontPath);
|
||||
//Charset charset = Charset::ASCII;
|
||||
//for (unicode_t c = 0x0410; c <= 0x041F; c++)
|
||||
//{
|
||||
// // some unicode values
|
||||
// charset.add(c);
|
||||
//}
|
||||
m_atlasGenerator.GenerateAtlas(fontPath, charset);
|
||||
m_atlasGenerator.SaveAtlasMetadataInfo("atlas_metadata", true);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < texts.size(); i++)
|
||||
@@ -81,16 +83,19 @@ namespace OpenVulkano
|
||||
#ifdef MSDFGEN_AVAILABLE
|
||||
TextDrawable* t = new TextDrawable(&m_atlasGenerator, texts[i].second);
|
||||
#else
|
||||
auto metadataInfo = resourceLoader.GetResource("atlas_metadata");
|
||||
auto data = resourceLoader.GetResource("roboto-regular-atlas.png");
|
||||
Image::ImageLoaderPng loader;
|
||||
static auto image = loader.loadData(reinterpret_cast<uint8_t*>(data.Data()), data.Size());
|
||||
static Texture tex;
|
||||
tex.resolution = image->resolution;
|
||||
tex.textureBuffer = image->data.Data();
|
||||
tex.format = image->dataFormat;
|
||||
tex.size = image->data.Size(); // 1 channel
|
||||
TextDrawable* t = new TextDrawable(metadataInfo, &tex, texts[i].second);
|
||||
auto metadataInfo = resourceLoader.GetResource("full_atlas_metadata_packed");
|
||||
TextDrawable* t = new TextDrawable(metadataInfo, texts[i].second);
|
||||
// OR use separate texture + metadata file
|
||||
//auto metadataInfo = resourceLoader.GetResource("atlas_metadata");
|
||||
//auto data = resourceLoader.GetResource("roboto-regular-atlas.png");
|
||||
//Image::ImageLoaderPng loader;
|
||||
//static auto image = loader.loadData(reinterpret_cast<uint8_t*>(data.Data()), data.Size());
|
||||
//static Texture tex;
|
||||
//tex.resolution = image->resolution;
|
||||
//tex.textureBuffer = image->data.Data();
|
||||
//tex.format = image->dataFormat;
|
||||
//tex.size = image->data.Size(); // 1 channel
|
||||
//TextDrawable* t = new TextDrawable(metadataInfo, &tex, texts[i].second);
|
||||
#endif // MSDFGEN_AVAILABLE
|
||||
t->GenerateText(texts[i].first);
|
||||
m_drawablesPool[i] = t;
|
||||
|
||||
Binary file not shown.
BIN
examples/ExampleSources/full_atlas_metadata_packed
Normal file
BIN
examples/ExampleSources/full_atlas_metadata_packed
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 449 KiB |
Reference in New Issue
Block a user