Rely on default state and disable/enable depth testing only for overlays
@@ -97,13 +97,6 @@ private void render(Iterable<EntityRef> floatingTextEntities) {
FloatingTextComponent floatingText = entity.getComponent(FloatingTextComponent.class);
- // If the FloatingTextComponent is meant to be occluded, enable depth tests
- if (floatingText.isOverlay) {
- glEnable(GL_DEPTH_TEST);
- } else {
- glDisable(GL_DEPTH_TEST);
- }
-
String[] linesOfText = floatingText.text.split("\n");
Color baseColor = floatingText.textColor;
Color shadowColor = floatingText.textShadowColor;
@@ -125,6 +118,11 @@ private void render(Iterable<EntityRef> floatingTextEntities) {
shadowColor, underline);
entityMeshCache.put(entity, meshMap);
}
+
+ if (floatingText.isOverlay) {
+ glDisable(GL_DEPTH_TEST);
+ }
+
glPushMatrix();
float scale = METER_PER_PIXEL * floatingText.scale;
@@ -146,9 +144,13 @@ private void render(Iterable<EntityRef> floatingTextEntities) {
}
glPopMatrix();
- }
+
+ // Revert to default state
+ if (floatingText.isOverlay) {
glEnable(GL_DEPTH_TEST);
}
+ }
+ }
private void diposeMeshMap(Map<Material, Mesh> meshMap) {
for (Map.Entry<Material, Mesh> meshMapEntry : meshMap.entrySet()) {
