Code cleanup
This commit is contained in:
parent
7719491f2c
commit
af653e7bcf
1 changed files with 4 additions and 40 deletions
|
|
@ -65,9 +65,6 @@ void parsebmFont()
|
||||||
std::ifstream fstream(filename);
|
std::ifstream fstream(filename);
|
||||||
assert(fstream.good());
|
assert(fstream.good());
|
||||||
|
|
||||||
// todo : from texture
|
|
||||||
const uint32_t texdim = 512;
|
|
||||||
|
|
||||||
while (!fstream.eof())
|
while (!fstream.eof())
|
||||||
{
|
{
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
@ -304,26 +301,13 @@ public:
|
||||||
|
|
||||||
// todo : function fill buffer with quads from font
|
// todo : function fill buffer with quads from font
|
||||||
|
|
||||||
void generateQuad()
|
// Creates a vertex buffer containing quads for the passed text
|
||||||
|
void generateText(std:: string text)
|
||||||
{
|
{
|
||||||
// Setup vertices for a single uv-mapped quad
|
|
||||||
/*
|
|
||||||
#define dim 1.0f
|
|
||||||
std::vector<Vertex> vertexBuffer =
|
|
||||||
{
|
|
||||||
{ { dim, dim, 0.0f },{ 1.0f, 1.0f } },
|
|
||||||
{ { -dim, dim, 0.0f },{ 0.0f, 1.0f } },
|
|
||||||
{ { -dim, -dim, 0.0f },{ 0.0f, 0.0f } },
|
|
||||||
{ { dim, -dim, 0.0f },{ 1.0f, 0.0f } }
|
|
||||||
};
|
|
||||||
#undef dim
|
|
||||||
*/
|
|
||||||
std::vector<Vertex> vertexBuffer;
|
std::vector<Vertex> vertexBuffer;
|
||||||
std::vector<uint32_t> indexBuffer;
|
std::vector<uint32_t> indexBuffer;
|
||||||
uint32_t indexOffset = 0;
|
uint32_t indexOffset = 0;
|
||||||
|
|
||||||
std::string text = "Vulkan";
|
|
||||||
|
|
||||||
float w = textures.fontSDF.width;
|
float w = textures.fontSDF.width;
|
||||||
|
|
||||||
float posx = 0.0f;
|
float posx = 0.0f;
|
||||||
|
|
@ -365,6 +349,7 @@ public:
|
||||||
float advance = ((float)(charInfo->xadvance) / 36.0f);
|
float advance = ((float)(charInfo->xadvance) / 36.0f);
|
||||||
posx += advance;
|
posx += advance;
|
||||||
}
|
}
|
||||||
|
indices.count = indexBuffer.size();
|
||||||
|
|
||||||
// Center
|
// Center
|
||||||
for (auto& v : vertexBuffer)
|
for (auto& v : vertexBuffer)
|
||||||
|
|
@ -373,23 +358,6 @@ public:
|
||||||
v.pos[1] -= 0.5f;
|
v.pos[1] -= 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
#define dim 1.0f
|
|
||||||
int charId = 'V';
|
|
||||||
float w = textures.fontSDF.width;
|
|
||||||
float sstart = fontChars[charId].x / w;
|
|
||||||
float send = (fontChars[charId].x + fontChars[charId].width) / w;
|
|
||||||
float tstart = fontChars[charId].y / w;
|
|
||||||
float tend = (fontChars[charId].y + fontChars[charId].height) / w;
|
|
||||||
std::vector<Vertex> vertexBuffer =
|
|
||||||
{
|
|
||||||
{ { dim, dim, 0.0f },{ send, tend } },
|
|
||||||
{ { -dim, dim, 0.0f },{ sstart, tend } },
|
|
||||||
{ { -dim, -dim, 0.0f },{ sstart, tstart } },
|
|
||||||
{ { dim, -dim, 0.0f },{ send, tstart } }
|
|
||||||
};
|
|
||||||
#undef dim
|
|
||||||
*/
|
|
||||||
createBuffer(
|
createBuffer(
|
||||||
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
|
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
|
||||||
vertexBuffer.size() * sizeof(Vertex),
|
vertexBuffer.size() * sizeof(Vertex),
|
||||||
|
|
@ -397,10 +365,6 @@ public:
|
||||||
&vertices.buf,
|
&vertices.buf,
|
||||||
&vertices.mem);
|
&vertices.mem);
|
||||||
|
|
||||||
// Setup indices
|
|
||||||
// std::vector<uint32_t> indexBuffer = { 0,1,2, 2,3,0 };
|
|
||||||
indices.count = indexBuffer.size();
|
|
||||||
|
|
||||||
createBuffer(
|
createBuffer(
|
||||||
VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
||||||
indexBuffer.size() * sizeof(uint32_t),
|
indexBuffer.size() * sizeof(uint32_t),
|
||||||
|
|
@ -720,7 +684,7 @@ public:
|
||||||
VulkanExampleBase::prepare();
|
VulkanExampleBase::prepare();
|
||||||
parsebmFont();
|
parsebmFont();
|
||||||
loadTextures();
|
loadTextures();
|
||||||
generateQuad();
|
generateText("Vulkan");
|
||||||
setupVertexDescriptions();
|
setupVertexDescriptions();
|
||||||
prepareUniformBuffers();
|
prepareUniformBuffers();
|
||||||
setupDescriptorSetLayout();
|
setupDescriptorSetLayout();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue