Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Location
    Ontario, Canada
    Posts
    1,750

    Exclamation How to render 3D OpenGL stuff in a browser?

    I have a bunch of proprietary code written in C++ that uses OpenGL to render 3D scenes. I've been asked to port this over to allow users to view the 3D output in a browser. Ideally, the source would run on a server somewhere on the internet and the browser would act as your monitor/window to see what is going on.

    Does anyone have suggestions on how I can do this? If I'm not mistaken I believe you can write a browser plugin (ActiveX maybe?) that lets you output OpenGL to a browser?

    Does anyone know how the Unity engine allows it's 3D output to go to a browser?

    Oh BTW, converting all the C++ code to Unity is not an option for me. There is too much legacy code that is C++ specific.
    C++, 3D OpenGL and Game Programming video tutorials:
    www.MarekKnows.com
    Play my free games: Ghost Toast, Zing, Jewel Thief

  2. #2
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    unity is a proprietary plugin running native code. unless you want to write a plugin for every browser/platform combination out there, you don't want to go down that road.

    there are quite some interesting developments regarding 3d in browsers, but most of this stuff is still at an experimental stage, so don't expect too much.
    one of the more promising technologies is webgl, which allows 3d graphics through html5's canvas element. googlecode has some nice samples. naturally, you will need the newest browsers for this (and nerves of steel for the debugging ). programming is done through an opengl-ish api in javascript, so you will need some glue here.
    there are older, more established technologies (vrml), but they are quite horrible.

    as kind of a compromise between proprietary plugins and standards like webgl, you could use java. that of course would require people to have a java runtime installed and would require you to write an applet for graphics display, but at least the technology is a little more mature than webgl.
    Last edited by ComicSansMS; 03-24-2011 at 06:56 AM.

  3. #3
    Join Date
    Mar 2005
    Location
    Ontario, Canada
    Posts
    1,750
    How would the java route work? A java applet would run in a browser, but how do you render3D in Java? I'd also have to figure out a way to get the computations from C++ to go to Java ... I believe there is a bridge that does that already....can't remember the term for it right now.

    WebGL looks promising ... I'll have to look into this further. ... does that mean that I would have to re-write all my C++ code in JavaScript?
    C++, 3D OpenGL and Game Programming video tutorials:
    www.MarekKnows.com
    Play my free games: Ghost Toast, Zing, Jewel Thief

  4. #4
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by mmakrzem View Post
    How would the java route work? A java applet would run in a browser, but how do you render3D in Java?
    java has a library for that (java 3d). note though, that special restrictions apply when writing an applet, so you can't do everything you can do in a stand-alone java app.

    I'd also have to figure out a way to get the computations from C++ to go to Java ... I believe there is a bridge that does that already....can't remember the term for it right now.
    you will need some server-side glue. the simplest thing would be to write the data required for rendering to a txt file on the server from your c++ code and read that file from the java applet. a more flexible approach would be a render server communicating with both the browser applet and the c++ program through sockets.

    WebGL looks promising ... I'll have to look into this further. ... does that mean that I would have to re-write all my C++ code in JavaScript?
    no, just some glue code as above. e.g. you could export the vertex/index lists from c++ to a text file and then display those through a generic webgl renderer written in javascript.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •