added text widget parsing and rendering
This commit is contained in:
@@ -93,6 +93,14 @@ void App::init()
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
#endif
|
||||
|
||||
#if _WIN32
|
||||
const char* ttf = "C:\\Windows\\Fonts\\arial.ttf";
|
||||
#else
|
||||
const char* ttf = "/Library/Fonts/Arial.ttf";
|
||||
#endif
|
||||
FontManager::init();
|
||||
FontManager::load(kFont::Arial_11, ttf);
|
||||
|
||||
layout.load("data/layout.xml");
|
||||
//layout["main"].update(width, height);
|
||||
|
||||
@@ -106,13 +114,8 @@ void App::init()
|
||||
if (!tex.load("data/uvs.jpg"))
|
||||
printf("error loading image\n");
|
||||
|
||||
#if _WIN32
|
||||
const char* ttf = "C:\\Windows\\Fonts\\arial.ttf";
|
||||
#else
|
||||
const char* ttf = "/Library/Fonts/Arial.ttf";
|
||||
#endif
|
||||
FontManager::load(kFont::Arial_11, ttf);
|
||||
text.create();
|
||||
text.update(kFont::Arial_11, "hello font");
|
||||
plane.create<1>(400, 400);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
@@ -165,22 +168,10 @@ void App::update(float dt)
|
||||
glm::mat4 proj = glm::ortho(0.f, width, height, 0.f, -1.f, 1.f);
|
||||
glm::mat4 tran = glm::translate(glm::vec3(200, 200, 0));
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
font_tex.bind();
|
||||
sampler.bind(0);
|
||||
ShaderManager::use(kShader::Font);
|
||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, proj*tran);
|
||||
|
||||
// plane.draw_fill();
|
||||
glBindVertexArray(font_array);
|
||||
glDrawElements(GL_TRIANGLES, font_array_count, GL_UNSIGNED_SHORT, 0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
font_tex.unbind();
|
||||
sampler.unbind();
|
||||
|
||||
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, proj * tran);
|
||||
text.draw();
|
||||
/*
|
||||
static int i = 0;
|
||||
i = (i + 1) % 32;
|
||||
|
||||
Reference in New Issue
Block a user