Downloads
Interactive openGL Web server


On-line Interactive openGL

The server side scripting generate logically HTML and JavaScript content that is executed on the client side. To complete the picture we need logical image generator. It can be done with available tools such as ImageMagick, but I offer a programmatic way of image-on-the-fly generator as OpenGL plus PNG format wrapper. I offer a simple example of web server that shows 3D generated images in the browser, which does not use third party binaries or libraries and is as small as few thousand lines.

The picture below shows how the browser session looks like. The web server, that makes image, is running in the background. The set of parameters can be passed from the browser back to server, which interactively adjust the picture. The picture is generated in the memory, the web server is not using hard drive for any data. The whole web site with all frames is also created dinamically by web server.



The program is simple demo of technical capability. It clearly shows that it is not necessary to build giant projects that make logical charts and publish them on-line interactively. The core part of application is Web server that publish form and read parameters passed by user. When parameters are returned back to server it opens new window and build open GL image. When image is ready the pixels are read by the function glReadPixels(). The data then are passed to PNG formatter that convert pixel data into formatted image and pass data further to Web server that pass dynamically created image back to browser which submitted the form. The server is multithreaded. That means that several clients may request different images concurrently. For testing users may open different browser windows and pass different image parameters with time delay.

When openGL image is created it is published in separate window that pops up for a moment and disappear when image is read from the screen. During that moment black rectangular may appear on the monitor connected to computer that host Web server.



In order to get rid of that popping up black rectangular the program should be converted for off screen image rendering. I made these changes but this code will be published later in another version of the program. Opening this auxiliary window does not mean that Web host must have monitor connected to it. It works the same way even without monitor or with switched off monitor.

When Web server shows auxiliary black window it may remind you the famous piece of art of Kazimir Malevich that was painted in 1915 and represent a black square.



Some people say in order to understand deep eternal idea of the black square you have to watch it for hours. I did not try. My black square appear only for a moment so, I did not get any eternal idea from the picture.