Skip to content

Commit

Permalink
UPBGE: Fix opengl state with text render.
Browse files Browse the repository at this point in the history
Previously as the text objects were possibly render between two mesh objects
the settings of the text objects was not properly undo.
The first setting not undo is for alpha blend but the issue is more deeper
and come from BLF. The only way found to fix it was to force alpha blend in
DisableForText and undo it a the end of RenderText3D.
The second setting not undo is the lighting and material capability. This
issue is fixed by calling ProcessLighting with uselights to false like a
regular mesh.
  • Loading branch information
panzergame committed Jul 17, 2016
1 parent 45e29fa commit 71827fa
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1796,14 +1796,11 @@ void RAS_OpenGLRasterizer::GetTransform(float *origmat, int objectdrawmode, floa

void RAS_OpenGLRasterizer::DisableForText()
{
SetAlphaBlend(GPU_BLEND_ALPHA);
SetLines(false); /* needed for texture fonts otherwise they render as wireframe */
SetFrontFace(true);

Disable(RAS_BLEND);
Disable(RAS_ALPHA_TEST);

Disable(RAS_LIGHTING);
Disable(RAS_COLOR_MATERIAL);
ProcessLighting(false, MT_Transform::Identity());

for (int i = 0; i < RAS_MAX_TEXCO; i++) {
glActiveTextureARB(GL_TEXTURE0_ARB + i);
Expand Down Expand Up @@ -1890,6 +1887,8 @@ void RAS_OpenGLRasterizer::RenderText3D(
BLF_draw(fontid, text, 65535);

BLF_disable(fontid, BLF_MATRIX | BLF_ASPECT);

SetAlphaBlend(GPU_BLEND_SOLID);
}

void RAS_OpenGLRasterizer::RenderText2D(
Expand Down

0 comments on commit 71827fa

Please sign in to comment.