Sorry to bring this back from the dead, but I’ve been trying to get a frame buffer object up and running in my world, but cannot manage it!
I have taken rolands OffscreenTexture class and kept it exactly the same except for the testDraw method. I changed that to this:
public void TestDraw() {
GL11.glLoadIdentity();
GL11.glColor4b((byte)255, (byte)100, (byte)100, (byte)255);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex3f(0, 0, 0);
GL11.glVertex3f(200, 0, 0);
GL11.glVertex3f(200, 200, 0);
GL11.glVertex3f(0, 200, 0);
GL11.glEnd();
}
Now, in the main game, an OffscreenTexture is created:
OffscreenTexture buffer = new OffscreenTexture(900, 500);
and this code is called once:
buffer.Bind();
buffer.TestDraw();
buffer.UnBind();
and later, every frame this code is executed:
private void renderGame() {
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, buffer.getTextureID());
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2i(0, 0);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2i(900, 0);
GL11.glTexCoord2f(1, 1);;
GL11.glVertex2i(900, 500);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2i(0, 500);
GL11.glEnd();
}
Is there a problem with the way I have used the opengl to draw everything rather than graphics, or is the problem somewhere else?