I create the PBuffer:
pbuffer = canvas.createOffscreenDrawable(new GLCapabilities(), offscreenSize, offscreenSize);
Then I call pbuffer.display() from the display call in my renderer:
pbuffer.display();
In the pbuffers renderer, I render my offscreen texture, wait for the gl pipe to finish, then copy the data to my texture.
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0, width, height, 0, -1.0, 1.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glClearColor(0.5f, 0.5f, 0.5f, 0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
//
// Normal OpenGL rendering goes here
//
gl.glFinish();
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D, texture);
gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height);
gl.glDisable(GL.GL_TEXTURE_2D);
I render a quad with that texture in my “normal” (framebuffer) renderer.
This works fine on both windows and linux, but on macintosh, the texture is solid black.
If I make it render the offscreen texture to the framebuffer, it works everywhere, but has the problem of not working too well if the GLCanvas gets covered by another window.
Any hints? Thoughts?