Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ OpenGL application as a web service

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: 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?

like image 495
user62146 Avatar asked May 19 '09 16:05

user62146


2 Answers

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.

like image 73
Reed Copsey Avatar answered Sep 22 '22 15:09

Reed Copsey


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.

like image 29
Brian Gianforcaro Avatar answered Sep 18 '22 15:09

Brian Gianforcaro