Okay, everything is working now. Thanks!
However, I do have one remaining question. Basically, when I begin drawing to a texture, the starting point for the draw commands is offset in the Y direction, always, and by a predictable amount.
This is my code to start rendering to a texture:
public static boolean beginDrawingTo(Texture texture)
{
if(renderToTextureEnabled())
{
IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
EXTFramebufferObject.glGenFramebuffersEXT(buffer);
frameBuffersActive.push(buffer.get());
EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
frameBuffersActive.peek());
EXTFramebufferObject.glFramebufferTexture2DEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, texture.getTextureID(), 0);
checkFBO(frameBuffersActive.peek());
GL11.glPushMatrix();
GL11.glOrtho(0, texture.getImageWidth(), 0,-texture.getImageHeight(), -1, 1);
GL11.glLoadIdentity();
GL11.glTranslated(texture.getImageWidth() / 2, texture.getImageHeight() / 2, 0);
GL11.glScalef(1f, -1f, 1f);
return true;
}
return false;
}
If I place
GL11.glTranslated(0, WindowManager.getScreenHeight() - texture.getImageHeight(), 0);
right after glLoadIdentity(), everything works.
Why is this the case? I'm happy it's working, but a little confused.