LWJGL - Drawing to a file.

Hey:)

As a brief side note before I say anything, I wasn’t too sure as to where I should place this topic? If it’s in the wrong place, feel free to move it:P

Anyway, I’m making a game in LWJGL which will include the ability to create your own custom levels and share them with other people.

I’ve created a java server, to receive uploaded data and spit it back out to the right clients. However, I would like the ability to add a thumbnail to the custom games people have made. This thumbnail is going to be a screenshot from inside the level.

Now, see, I don’t want to render the level on the client, save a screenshot then send that to the server for two reasons: Increased bandwidth usage (Which I think will be the bottleneck for server capacity), and the fact that people could rewrite the server to send any image they wanted. Last thing i want is a thousand levels displayed as male genitalia:P

So, what I want to do, is take the data of the level that I send to the server, and render it directly to an image file. I am unsure of how to do this server-side however, because when I eventually buy a server, it’ll be headless, so I think an exception will be thrown if I try to open a Display?

To be fair, I’m not too sure, but anyone’s input would be greatly appreciated:P

Thanks:)

EDIT:
I guess I could draw it with java2D onto a BufferedImage and save that instead? It’d be tricky to replicate the drawing though I guess!

I think that using OpenGL for this would make you run into threading issues when multipl users upload a level simultaneously.

One simple way could be to create a 2-dimensional array based on the level data, convert it to a BufferedImage and then save it to disk with ImageIO.write(…).

edit: maybe instead of a screenshot store a minimap-like-picture?

Ah, I didn’t think of threading issues, thanks for that.

By 2 dimensional array, you mean an array of pixels? I think that’d be hard to do, and possibly rather processor intensive? I’m not too sure, I don’t think I could manage to code something like that personally anyway:P

I believe a minimap would probably work best, yes, I’ll end up doing this I would image:P Thank you:)

[quote]Last thing i want is a thousand levels displayed as male genitalia:P
[/quote]
Well, you will probably not be able to keep anybody away from just creating a level like that will you?

I would just let the client upload an image. If your game gets popular enough for people to reverse engineer it, then penis pics will be a small problem. And you do not have to have large images as thumbnails. Keep it at say 64x64 or so.