Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best approach to use openGL in the web?

Tags:

opengl

I wrote a program in C++/OpenGL (using Dev-C++ compiler) for my calculus 2 class. The teacher liked the program and he requested me to somehow put it online so that instead of downloading the .exe I can just run it on the web browser. Kinda like java applets run on the browser.

The question is:

How if possible, can I display a C++/OpenGL program in a web browser? I am thinking of moving to JOGL which is a java interpretation of OpenGL but I rather stay in C++ since I am more familiar with it.

Also is there any other better and easier 3D web base API that I can consider?

like image 909
Y_Y Avatar asked Sep 03 '09 03:09

Y_Y


People also ask

Can OpenGL run on web?

WebGL enables web content to use an API based on OpenGL ES 2.0 to perform 2D and 3D rendering in an HTML canvas in browsers that support it without the use of plug-ins.

What do you use OpenGL for?

It is commonly used to make UI animations more responsive or to handle embedded video or to draw vector graphics – really any visual element you put on the screen is fair game for OpenGL. OpenGL is becoming increasingly ubiquitous and understanding how to leverage its incredible power is a must for developers.

Is WebGL as good as OpenGL?

WebGL is derived from OpenGL ES 2.0 (intended for mobile devices) which has less capabilities and is simpler to use. WebGL is also designed to run in a browser, and has therefore a few limitations more then OpenGL ES 2.0.


4 Answers

AFAIK, there's only 3 options:

  1. Java. it includes the whole OpenGL stack.

    • Google's Native Client (NaCL), essentially it's a plugin that let's you run executable x86 code. Just compile it and call it from HTML. Highly experimental, and nobody will have it already installed. Not sure if it gives you access to OpenGL libraries.

    • Canvas:3D. Another very experimental project. This is an accelerated 3D API accessible from JavaScript. AFAICT, it's only on experimental builds of Firefox.

I'd go for Java, if at all.

OTOH, if it's mostly vectorial works (without lots of textures and illumination/shadows), you might make it work on SVG simply by projecting your vectors from 3D to 2D. In that case, you can achieve cross-browser compatibility using SVGWeb, it's a simple JavaScript library that allows you to transparently use either the browser's native SVG support or a Flash-based SVG renderer.

like image 192
Javier Avatar answered Oct 13 '22 03:10

Javier


There is a lot activity recently with WebGL. It is a binding for Javascript to native OpenGL ES 2.0 implementations, designed as an extension of the canvas HTML5 element.

It is supported by the nightly builds of Firefox, Safari, Chrome and Opera.

Have a look at these tutorials, based on the well known NeHe OpenGL tutorials.

Several projects based on WebGL are emerging, most notably Scenegraphs APIs.

  • From Indie teams: SceneJS, GLGE, SpiderGL.
  • From Google: the team behind O3D plugin is trying to implement a pure WebGL backend (source) for the project, so that no plugin will be necessary.
  • From W3C/Web3D: There is an ongoing discussion to include X3D as part of any HTML5 DOM tree, much like SVG in HTML4. The X3DOM project was born last year to support this idea. Now it is using WebGL as its render backend, and is version 1.0 since March 2010.

I'm almost sure that WebGL is the way to go in the near future. Mozilla/Google/Apple/Opera are promoting it, and if the technology works and there is sufficient customer/developer demand, maybe Microsoft will implement it on IE (let's hope that there will be no "WebDX"!).

like image 40
Gabriel Cuvillier Avatar answered Oct 13 '22 03:10

Gabriel Cuvillier


Do you really have the time to rewrite it? I thought students were meant to be too busy for non-essential assignment work.

But if you really want to do it, perhaps a preview of it running as a flash movie is the easiest way. Then it's just a matter of doing that and you could provide a download link to the real application if people are interested.

like image 42
hookenz Avatar answered Oct 13 '22 03:10

hookenz


Outside of Java, in-browser OpenGL is really in its infancy. Google's launched a really cool API and plugin for it though. It's called O3D:

http://code.google.com/apis/o3d/

Article about the overall initiative: http://www.macworld.com/article/142079/2009/08/webgl.html

like image 42
brianreavis Avatar answered Oct 13 '22 03:10

brianreavis