I’ve been trying to do a very basic render to an offscreen renderbuffer and then blit it directly to the screen. It works … sorta. I can’t seem to figure out why I’ve got some bizarre numbers sent to glBlitFramebufferEXT and why resize to larger doesn’t work.
Expected on startup:
A colored quad with red, green, blue, and white corners covering the entire GLJPanel. I get this, but I have to specify some very odd numbers to the glBlitFramebufferEXT call to make this happen. I have to specify:
gl.glBlitFramebufferEXT(0, 0, 600, 400,
0, 112, 600, 512,
gl.GL_COLOR_BUFFER_BIT,
gl.GL_NEAREST);
when I expect to have to specify 0,0,600,400 for both lines
Expected on resize:
A colored quad with red, green, blue, and white corners covering the (0,0) - (600,400) portion of the GLJPanel with the portions outside that being color blue. The (0,0)-(600,400) portion should look like a window over the quad as the window resizes. I get completely random behavior.
It seems like I’m getting the renderbuffer right, but I’m missing something required to get the result to the screen.
Thanks for any help.
Here’s my display() function where I suspect the error to be:
public void display(GLAutoDrawable gad) {
System.out.println("display thread: " + Thread.currentThread().toString());
GL gl = gad.getGL();
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
{
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glClearColor(0, 0, 1, 0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
}
gl.glBindFramebufferEXT(gl.GL_READ_FRAMEBUFFER_EXT, fbIds[0]);
gl.glBindFramebufferEXT(gl.GL_DRAW_FRAMEBUFFER_EXT, 0);
gl.glBlitFramebufferEXT(0, 0, 600, 400,
0, 112, 600, 512,
gl.GL_COLOR_BUFFER_BIT,
gl.GL_NEAREST);
gl.glBindFramebufferEXT(gl.GL_READ_FRAMEBUFFER_EXT, 0);
gl.glBindFramebufferEXT(gl.GL_DRAW_FRAMEBUFFER_EXT, 0);
}