Renderização de texto OpenGL com renderização 3D
void TextRenderer::RenderTextRenderer(const Shader& shader, const RenderingEngine& renderingEngine, const Camera& camera)
{
// Enable blending and set the blend function so that the text is rendered instead of the quads
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Disable the depth test since the text is being rendered in 2D
glDisable(GL_DEPTH_TEST);
this->TextShader.Bind();
this->TextShader.UpdateUniformsTextRenderer(renderingEngine);
/**
* NEW CODE
* Set the sampler named "H_text" to have index 0
* When glActiveTexture(GL_TEXTURE0) is called, and a texture is later bound,
* OpenGL is being told that the sampler named "H_text" should use that specific bound texture
*/
glUniform1i(glGetUniformLocation(TextShader.GetShaderData()->GetProgram(), "H_text"), 0);
RenderText("TEST testpqli", 20, 20, 1);
// Enable the depth test again so that the 3D rendering will be correctly rendered in the next frame
glEnable(GL_DEPTH_TEST);
/**
* Optionally disable the blending
* Can be removed since the 3D world might have some parts that needs to be rendered (semi-)transparent
*/
glDisable(GL_BLEND);
}
Fierce Fly