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)

2
  • 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. 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. Commented Oct 27, 2013 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 may have already considered some of these issue. Commented Oct 28, 2013 at 10:33

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Maybe use node-webkit for something like that?
@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 or EnvJS, 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 stackoverflow.com/questions/2438201
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, as I said, I'm up to attempting a WebGL Canvas implementation, me thinks ;-)
As Sod's law would have it, I just came across this similar SO question outlining the WebGL architecture, and I notice that Gman put his tuppence in (cheers ;-) ).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.