high resolution screenshots

Hey, this may be a bit of a newbie question. I’d like to try to find a way to take high resolution, eg poster-sized screenshots of my Jogl app.

PBuffers work, but it looks like they’re limited by the video card’s maximum resolution. And I can’t rely on the currentness of my user base’s hardware - it sounds like older hardware may not support PBuffers.

It looks like Unix’s OpenGL has a software rendered PixMap method (GLX.glxCreatePixmap), and that there is a way to do a similar thing in Windows (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/oglport_286d.asp).

Is there a standard way in Jogl of doing software rendering that may have a higher maximum resolution than PBuffers allow?

Not directly. The standard technique for doing this is tiled rendering. The scene is rendered repeatedly, changing the view frustum each time to achieve non-overlapping pieces of the larger image. The overall image is then assembled afterward in an image editor. Here are a couple of links:

http://www.mesa3d.org/brianp/sig97/offscrn.htm (found with a Google search for “tiled rendering utility” – I assume you can find the source code somewhere)

http://croquetweak.blogspot.com/2005/03/print-quality-screenshots.html (found with a Google search for “opengl high resolution screenshot frustum”)

Either way you’ll need to port the tiled rendering code to Java, but this shouldn’t be too difficult.

[quote]Either way you’ll need to port the tiled rendering code to Java, but this shouldn’t be too difficult.
[/quote]
No you don’t, because I’ve already done it!

See here for the code.

Huh. The forum didn’t post my response.

Anyway, thanks a lot - that’s exactly what I need.

But I’m having difficulties with matrices now. I have both a gluPerspective (replaced with trPerspective outside the tiling loop as prescribed) and a gluLookAt() call in my drawing code. The matrix code isn’t mine, so I don’t understand it well.

Any guidance? I’ll try to read up on these matrix operations a bit more in the meantime.

Glad to see someone getting some use out of it :slight_smile:

re matrices: I’m a bit weak in this area too, but I’ll have a poke around in my own code and see if I can isolate what I did. I’m a bit busy at the moment though, so bear with me.

Excellent! Thanks. I’ve filed an RFE to incorporate this class into com.sun.opengl.util.

Ah, good, I got it working. Just some newbie issues.

  • I had to make sure that no matrix operations were being performed while gl.glMatrixMode(GL.GL_PROJECTION) was active. Operations on other matrices, like GL.GL_MODELVIEW do not affect the projection matrix.
  • Had to make sure that the tile size wasn’t larger than the current buffer I was displaying into. I’m using a GLCanvas inside a JPanel, so I just set the tile size to super.getHeight() and super.getWidth() for perfect results.

Also, to retrieve the image to a BufferedImage instead of a file, I took a tip from the new Screenshot class:

BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
ByteBuffer imageBuffer = ByteBuffer.wrap(((DataBufferByte) image.getRaster().getDataBuffer()).getData());

tr.setImageBuffer(GL.GL_BGR, gl.GL_UNSIGNED_BYTE, imageBuffer);

Thanks again for this contribution. The TileRenderer class has been incorporated into the com.sun.opengl.util package under BSD licensing terms with the permission of the author, Brian Paul, and a new demos.misc.TiledRendering demo has been added.

Huzzah! Immortalised at last! (sort of)