OpenGL and web services (need help)

Greetings,

I would like to implement web service that renders 3d objects and returns byte stream:

Bitmap test=new Bitmap(200,200);

//…
// drawing procedure

MemoryStream str=new MemoryStream();
test.Save(str,ImageFormat.Jpeg);
return str.ToArray();

I am programming in C#. Could anyone point me to a tutorial how I can do that? Can I use OpenGL for rendering and how do I intialize it? Any help would be appretiated.

Thank you,

Mr X

  1. How exactly is your question related to “advanced OpenGL” programming ?

  2. There is nothing OpenGL specific about your question either: The web client issues a request for
    something, the server is going to handle the request - in your case it “renders 3d objects”, stores the result in some byte array (or whatever), and returns a bytestream back to the client.

Dear glBug,

My question is if I can use OpenGL on server to render 3d geometry and then send image(Bitmap) of that rendered geometry back to client. And if it is possible, how can I implement it.

Regards,
Mr X

Of course you can use OpenGL for that. If I were you
I would google for something like “OpenGL render to texture”.

If your server supports the opengl rendering, you should be able to do this without problems. There are Tao bindings for OpenGL as part of the mono project(works for Windows on .net 1.1) and linux/unix. You can also look here: http://www.csharpopenglframework.com/ if you use .NET 2.0
Another headers for .net 2.0 are recently developed by myself but it will take while till they are ready.
If you are not familiar with OpenGL, you won’t be able to write such an application, of course, so you’ll have to get some thraining.
As glBug said: your question has nothing to do with advanced topics of opengl as you merely ask how to use it.
So long.

The question is a valid OpenGL question, he is asking how to render to an in memory bitmap and it’s probably not a “beginners” section question.

You need to be able to render to a pbuffer for this, it is definitely possible, you could alternatively use a pure software approach by linking to a software OpenGL implementation like Mesa ( www.mesa3d.org )and thereby perform the rendering on the server CPU. Accelerating this with a graphics card would obviously be desirable freeing up considerable server resources but requiring the use of pbuffer rendering or the equivalent.

Thank you dorbie. That is exactly what I thought too (not a “beginner” section question).
Now another question. How do I use pbuffer in this case (web services)? Web service is developed in C# (VS.NET (.NET 1.1)).
Client sends request with parameters for geometry and server responds with rendered bitmap (jpeg format).

Thank you all for your help.

Mr X

Well, I guess you should approach it like to any regular OpenGL application. First, get the tao headers here : http://www.mono-project.com/Tao

Then, when your ASP-script(or whatever) gets the request, you’ll have to create am OpenGL context(probably a window as well), render to an offscreen buffer(pbuffer), read the image back as bitmap, convert it to JPEG or whatever you wish and send it back to the user machine.

Actually it should be a usual OpenGL application with the particularity of running at server.
Hovewer, I must warn you: this would be REALLY slow.

You will be better of if you have a standalone .NET application running at server that performs the rendering, and let your ASP-script communicate with it. This way you would not have to create a new context(which can be really time-sonsuming) for every request.

I never developed something like this before, so this all are merely recomendations.

Hope it helps :slight_smile: