0

OK, I've identified the possibility of writing my own WebGL implementation on top of an existing OpenGL 2.0/ES framework, this would allow the leveraging browser-based, WebGL development techniques onto both desktop and mobile platforms (so offering both rapid application development and cross-platform).

So, what would be the minimum WebGL-compatible emulation features I would need to implement (i.e. HTML5/WebGL canvas, HTML DOM access, specific HTML tags etc.)?

For example, I'm aware of WebGL's HTML Canvas implementation (for which I've found sevaral OSS function API definitions I can appropriate), however, I'm unaware of how much browser/DOM functionality I might also need to implement. I'll also be leveraging a JavaScript-capable interpreter and an embeddable browser implementation (all open-source).

I do realise this sounds very much like Ludei's CocoonJS, but I'd like to roll my own (free) implementation.

JFYI, my development will be undertaken in a Java/JVM language (e.g. Java, Scala or Groovy)

Big Rich
  • 5,864
  • 1
  • 40
  • 64
  • 1
    It would be more difficult than you think, because WebGL does more than layer on top of OpenGL ES 2.0. It actually has strict security rules that require WebGL implementations to detect buffer overruns, something normal GL drivers do not expose. There is a whole list of things you would have to do in addition to simply wrapping OpenGL ES 2.0 outlined [here](http://www.khronos.org/registry/webgl/specs/latest/1.0/#6). For that matter, most of what you have asked can be addressed in other parts of this document. You'll probably have to implement a subset of the spec. to make this manageable. – Andon M. Coleman Oct 27 '13 at 20:02
  • @AndonM.Coleman - Thank you for your input, there seems to be quite a few points I need to consider, outside of simply wrapping OpenGL, as you state. I can only hope that the frameworks I'll be leaning on for WebGL/Canvas knowledge, such as [GwtGL](https://code.google.com/p/gwtgl) may have already considered some of these issue. – Big Rich Oct 28 '13 at 10:33

1 Answers1

3

If you really want to implement it all then you're basically going to have to implement a browser. The only parts you can skip are the UI (URL bar, menus, extensions, etc...) the stuff that happens outside of the page.

To run any WebGL app some apps will use Canvas to make textures or to do 2d parts of the game. Others will use all of HTML including all the CSS, 3DCSS, etc. They'll use the WebAudio API, some will use WebSockets, WebRTC, WebComponents, Fonts, GeoLocation, FileAPI, LocalStorage, etc etc. They'll use the Image tag, Web Workers, Video, etc...

You can pick some subset but otherwise you're going to need pretty much an entire browser.

If it was me I'd look into seeing if it's possible to compile Blink, Chromium, or Firefox and removing the parts I don't need. Blink or Chromium had something called the "content shell" which is just the part that renders the page minus all the UI. That way, once I got it working, as new things were added to HTML5 I'd get those features for free.

gman
  • 100,619
  • 31
  • 269
  • 393
  • 1
    Maybe use [node-webkit](https://github.com/rogerwang/node-webkit) for something like that? – d13 Oct 28 '13 at 02:44
  • @gman I guessed some form of headless browser/DOM would be necessary, thanks for highlighting what might be necessary for a WebGL application to function correctly. I'm considering various embeddable browser implementations, or scrapers, such as [lobo](http://www.lobobrowser.org) or [EnvJS](http://www.envjs.com), however, I'm not sure their HTML[5] Canvas and CSS3 capabilities are up to scratch (I'd add WebGL canvas functionality myself). Hopefully, I'll find an embeddable OSS browser implementation/scraper which is up to the task and extendible. See http://stackoverflow.com/questions/2438201 – Big Rich Oct 28 '13 at 12:29
  • OK, not Lobo, great software, wrong license (GPL), EnvJS isn't being updated much, so I'm looking into using HTMLUnit (it's pure Java and is permissively licensed, which is a requirement). I'm now investigating the [2D canvas credentials of HTMLUnit in this SO question](http://stackoverflow.com/questions/19696932), as I said, I'm up to attempting a WebGL Canvas implementation, me thinks ;-) – Big Rich Oct 31 '13 at 01:44
  • As Sod's law would have it, I just came across this [similar SO question outlining the WebGL architecture](http://stackoverflow.com/questions/7328472/how-webgl-works), and I notice that Gman put his tuppence in (cheers ;-) ). – Big Rich Oct 31 '13 at 01:52