views:

578

answers:

8

Dear all,

Let me explain the situation: we have created an OpenGL application in C++ which visualizes some physical simulations. The basic application is contained within a DLL which is used by a simple GUI. It currently runs on a desktop PC, but we have the idea to turn it into a web service.

Since the simulations require dedicated hardware, the idea is that a user, through his/her browser can interact with our application as a service and this service then renders the result to an image (jpg or anything appropriate) that can then be displayed/updated in the browser.

My question: Having no idea about web development or web services myself I would like your opinion on how to tackle this problem. How can I "easily" turn a c++ application as described into a web-service that runs on some server so that I can approach it over the web? What kind of technologies/APIs should I look at? And are there any real-life examples that tackle a similar problem? I have searched for some answers myself, but the sheer amount of web-technologies is kind of daunting.

Any help or pointers would be appreciated.

Kind regards, Bart.

+5  A: 

This is possible, but one major difficulty you'll have is trying to use OpenGL from a web service. You'll need to port this to do 100% offscreen rendering and work without a windowing context. That would be my first step, and it's not always a trivial one.

Also, it is very difficult to maintain and manage your opengl contexts from a webservice correctly, and the overhead involved can be quite painful. Depending on the number and types of renderings, you may run into some issues there.

Reed Copsey
+1  A: 

If your user-interaction needs are simple, I'd just look at CGI. It should be pretty easy to understand.

As far as getting the output of the OpenGL program, I'd take a look at the framebuffer extension. That should make it easy for you to render into memory, which could then be fed into a JPEG compressor.

Jay Kominek
+3  A: 

If you need it to scale up well CGI would probably be kind of slow & hacky.

There are some C++ web frameworks out there, see this question.

As far as the OpenGL goes, you'll probably need to use the frame buffer extension as Jay said. You could then render your image to a texture, and use use glGetTexImage() to grab the pixel data. From there just save into what ever image format you want with the accompanying library.

Brian Gianforcaro
+1  A: 

I guess you already have access to some webserver, e.g. Apache or similar. In that case you could try out CppServ.

You just need to configure your webserver so it can communicate with CppServ. I'd then propose that you develop a servlet (check the documentation on the site) which in turn communicates with your already existing dll. Since the dll knows everything about OpenGL it should be no problem to create jpeg images etc.

Magnus Skog
+3  A: 

I had a similar project/question, that although it wasn't a web service, it required OpenGL rendering in a windows service. I had tons of problems getting it to work on Vista, although eventually it did work on XP with regular OpenGL.

I finally tried using Mesa, which I built to work as a private DLL for my service. It was a great decision because I could now actually step into the OpenGL calls and see where things were going wrong. It ran fine in software mode under the service, and while it wasn't hardware accelerated, it worked very well.

kevin42
+1  A: 

How about using something like Flex to create a web-enabled 'control interface', with a server backend that streams the opengl rendering as video? Basically, you are redirecting keyboard/mouse input via the Flex app, and using it to display 'realtime' 3D activity using a standard movie component.

The devil's in the details, of course....

Dan
A: 

You can try to use O3D API from google and don't do anysort of service, it would be much more simple.

Correct me if I'm wrong, but the problem with this is that everything would still run locally at the client-side, right? This is a "problem" because the simulations are quite heavy and we want to make them available to any user (maybe even mobile ones) on virtually any system with a browser.
Are you sure that you will be able to run such heavy service in a cost efficient way? Cleint side solutions accessable from the browser would be much cheaper for you.
A: 

Hi, This answer might sound very basic and elementary, have you tried this approach

a) Send the vector data from the server to the client or vice versa (just co-ordinates and so on) b) Render it on the client side.

This means that the server is only doing the calculations and the numbers are passed to and fro.

I agree that is not a trivial method of trying to vectorize every object/model and texture, but is very fast since instead of heavy graphical images going across, only vector data is being sent across.

Kiran VVN