tags:

views:

205

answers:

6

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 file and run it the web browser will run it automatically just like a java applet.

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?

+1  A: 

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.

Matt H
LOL I don't have that many hours of work so I spend most of my time studying so I thing I can spend the time. + LOL well I can do that but I dunno I am curious on how to do OpenGL in the web.
Y_Y
+2  A: 

AFAIK, there's only 3 options:

  1. Java. it includes the whole OpenGL stack.

  2. 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.

  3. 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.

Javier
Yeah I though the same thing. There aren't too many options about this. But thanks for the answer.
Y_Y
I'm also wandering how people came with RunScape the online game!.
Y_Y
NVM is java too
Y_Y
+2  A: 

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

brianreavis
NICE! thanks I'll check it out
Y_Y
A: 

It's not OpenGL, but the Web3D Consortium's X3D specification may be of interest.

Judge Maygarden
A: 

Two approaches:

  1. Switch to Java. However, your application will suffer from a loss of performance as a trade off for portability. But since Java is everywhere, this approach ensures that your code can be executed in most browsers.

  2. Use ActiveX, which allows you to run native binary code for Microsoft Windows. This is not recommended in production because activeX is well known as a potential security hole, but since your lecturer is the one viewing it, security doesn't seem to be a big deal. This is applicable for Microsoft platform (Windows+IE) only.

thoaionline
A: 

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"!).

Gabriel Cuvillier