Search
 
SCRIPT & CODE EXAMPLE
 

CPP

opengl text rendering with 3d rendering

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);
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: linux x11 copy paste event 
Cpp :: how to implement binders and decorators on c++ lik python? 
Cpp :: friend class c++ 
C :: trie tableau c 
C :: csrf_exempt 
C :: powershell search files for string 
C :: Write a C program to print all unique elements in the array. 
C :: How to install npm in alpine linux 
C :: allow unrelated histories 
C :: arduino serial read write structure 
C :: zizag c 
C :: how to print boolean in c 
C :: line counter in c 
C :: how to open jupyter notebook in local disk D 
C :: c get random float 
C :: operators priority in c 
C :: strcasecmp in c 
C :: servo motor arduino 
C :: how to print the first character of a string in c 
C :: write a binary file c 
C :: how to scan in c 
C :: C Passing string to a Function 
C :: extract substring after certain character in flutter 
C :: initializa 2d array c 
C :: C first digit of integer 
C :: Write a 64-bit program in assembly that prints Hello, world in .asm 
C :: pointers to a function in c 
C :: millis() 
C :: C strlen implementation 
C :: implement crc using c language 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =