I’m having some strange problems with TextRendering still. Now I’ve added a debug mode where I can render grid coordinates into my scene:
http://www.whitehexagon.com/debug-grid.png
I was expecting white… sometimes there are even more colours being picked up from somewhere.
Rectangle2D textBounds = renderer.getBounds("(99,99)");
float textWidth = (float) textBounds.getWidth();
renderer.begin3DRendering();
for(int x=0; x<PP_LENGTH;x++){
for(int y=0; y<PP_WIDTH;y++){
String message = "("+x+","+y+")";
float effectX = (tileLength * x);
float effectY = (tileWidth * y);
renderer.setColor(1f, 1f, 1f, 1f);
renderer.draw3D(message,
effectX,
effectY,
1f,
BOX_WIDTH / textWidth);
}
}
renderer.end3DRendering();
I’m also seeing a second problem now where sometimes various text renderers are just not displaying, unless a certain piece of geometry is also being rendered. I suspect the OpenGL state is being corrupted somewhere, but is there any utility methods to do a state comparison between various parts of my rendering loop? Or any sugestion on how to track down this type of issue? The object that ‘allows’ the textRenderers to display is using the following code: (in this case the model is not textured)
public void render(final GL gl) {
if (hasTexture.get()) {
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_DECAL);
gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glBindTexture(GL.GL_TEXTURE_2D, tmo.textureID);
gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, textureFB);
} else {
gl.glDisable(GL.GL_TEXTURE_2D);
}
gl.glVertexPointer (3, GL.GL_FLOAT, 0, vertexFB);
gl.glNormalPointer ( GL.GL_FLOAT, 0, normalFB);
gl.glColorPointer (3, GL.GL_FLOAT, 0, colorFB);
gl.glDrawArrays(GL.GL_TRIANGLES, 0, vertextCount);
if (hasTexture.get()) {
gl.glTexEnvf( GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_BLEND);
gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
} else {
gl.glEnable(GL.GL_TEXTURE_2D);
}
}