Rendering to file. Stability problems

Hello JOGL Masters!

I’m developing an offscreen map server that glues map tiles and shows it on client computers as a flat image layer in GIS system. I’m using JOGL to glue tiles fast and add some vector information. My program creates a PBuffer context and render results to image with glReadPixels. The image is then send as a response to client request. Every client can request for map with a different resolution, so the size of PBuffer has to be changed (I know it can’t be changed of course so I create a new one). Unfortunately my solution is not stable. I’ve tested my solution with 10 emulated clients and server gives “Error making context current: 0” error after random number of seconds. I’ve read a lot about this problem and it seems to be ‘unfixable’, isn’t it?

Dear JOGL users: could You give me some hints of how to make the server stable?

Admittedly my knowledge on pbuffers and networked jogl is limited, but imo any reply to a question is always nice to get.
If you do your tests with emulated clients, are they all trying to get a tile immedietly or do add the client requests to a queue?
Since Jogl is by default single threaded for rendering to any context, even if there are multiple ones, if the requests weren’t queued up, it might not be possible for jogl to make the context current because it’s currently rendering to another one.

Another thing to keep in mind (perhaps you have, who knows?) If you’re creating a pbuffer each time, you get a new context I’m fairly sure and, if this is the case, then any resident structures on the previous context are inaccessible unless you are using context sharing on your server. Just something to keep in mind, and it probably won’t matter unless you have resident textures, VBO’s, or display lists.

Also creating a new context might incur serious overhead so there might be a better way to implement your rendering style to custom resolutions. I believe you could adjust the projection frustrum to get a specific corner of the image and then add multiple renderings of the various corners together into a single BufferedImage that has the correct dimensions.

lhkbob’s advice is good. Try reusing the pbuffer on the server by only expanding it and never shrinking it. Also take a look at the TileRenderer in the com.sun.opengl.util package, which implements the high-resolution tiled rendering scheme mentioned in his last paragraph.

I play up now with TileRenderer and it works fine for me! Thanks for advice!