<<

AFTERWORD

The Future of WebGL

What does the future hold for WebGL? In this afterword, we will discuss both what WebGL has going for it and some concerns, and speculate on its future. In order for WebGL to have a bright future and not fail like other past 3D browser attempts such as the Virtual Reality Markup Language (VRML), it needs the following: v Support v Adoption from the development community, especially game developers v Improvements and active development

Support Here we will look at support from browsers and devices.

Browser support As mentioned in the book introduction, Chrome and do a very good job of supporting WebGL. and are improving, and IE does not have plans to natively support WebGL anytime soon. While five years ago this could be a disaster, IE does not command the market share that it used to enjoy—Chrome has surpassed it and Firefox is not far behind.

Mobile Device support The level of mobile devices that currently support WebGL is small but will improve with each new device released and should be much higher in 2013. Right now, there are several mobile browsers that support WebGL: Firefox Mobile, Android Browser, (Android only), BlackBerry Playbook, and iOS Mobile Safari (supported for only iAd at the moment). The mobile market share is growing and is an important area in which to gain ground. As Adobe recently announced that it will be discontinuing mobile Flash support, WebGL has an even better opportunity to establish itself as the go-to technology for mobile 3D. The sitehttp://webglstats.com/ by Florian Boesch has some very interesting statistics on the current support of various WebGL metrics across browsers, devices, and operating systems.

299 AFTERWORD N THE FUTURE OF WEBGL Adoption As mentioned in this book, has used WebGL for its Body, Map, and Earth applications. We showed in Chapter 9 that Firefox is using WebGL for a new 3D debugging visualization of the (DOM). It is important to get support and usage from the big name companies, and this is happening with support from Google, , Apple and Opera. It is also important to get well-written frameworks that lower the bar to 3D coding. Frameworks such as Three.js are already easy to use and will continue to get better.

What WebGL Has Going for It

v No plugin needed. v The timing is right. 3D in the browser is more useful now than back when VRML tried. GPUs are more powerful. WebGL is part of the larger movement of HTML5 and related technologies, which adds many browser enhancements which are making it possible to create applications previously only possible on the desktop. “For a couple of decades, the web has been sipping that power through a straw but with WebGL, it’s as if the straw had been replaced by a fire hose when it comes to graphic processing power . . .” http://www.tnl.net/blog/2011/10/23/webgl-and-the-future- of-the-web/ v Web applications do not have platform compatibility issues or need to be installed. v WebGL frameworks are making it easier all the time to get started with WebGL. v For the experienced graphics , the ability to tweak WebGL at a low level is extremely useful. v Many awe-inspiring demos. v Transparent development of the specification. v Experience and existing developers. Khronos is also in charge of OpenGL and Collada. There are many current OpenGL and OpenGL ES developers who can fairly easily pick up/transition to the WebGL API.

Concerns WebGL is powerful and very promising. However it is a relatively new language and has some concerns which include these: v Lack of support. As mentioned previously, this is not as big a deal as it would have been when Microsoft dominated the browser demographic. Whether it is not supporting WebGL because of security concerns or because of interest in its own DirectX technology, only Microsoft can say for certain. v Security concerns. GPU blacklists, and newer graphics cards with improved security will help with GPU concerns. Other web security measures such as cross-origin resource sharing will enable flexibility while maintaining security. v Flash or other technology being used for 3D instead. As mentioned, Flash discontinuing mobile support helps alleviate this concern.

300 AFTERWORD N THE FUTURE OF WEBGL

v Performance issues with JavaScript . JavaScript is slow. Improvements have been made such as typed arrays, and more optimizations are being investigated. v Game developers need to get on board. This point will now be expanded upon.

Game Developers An excellent blog entry at http://codeflow.org/entries/2011/sep/11/webgl-and-html5-challenges-for- the-future/ by Florian Boesch explains how WebGL needs game developers to adopt it. In the entry several features that are needed by game developers are listed with those relating to WebGL specifically being: multiple render targets, geometry instancing, texture lookup in the vertex , and floating-point textures. Current support for these features by browser can be found at the webglstats.com link mentioned here.

Active Development The WebGL specification, future extensions, and owserbr implementations are all under active development.

Extensions The WebGL language has extensions to the core hatt are in development and can be viewed at http://www.khronos.org/registry/webgl/extensions/. Of the extensions currently listed, three in particular that will be useful are these: v Anisotropic filtering, which improves the quality of textures that are viewed at an oblique v Depth textures for shadow maps v Compressed textures Future features that could be added soon include these: v More extensions, such as cross-context sharing or multiple render targets. v Multithreading in web workers. This would allow uploading textures and data without blocking the main thread. v Asynchronous context creation and resource sharing between contexts.

The Final Word Nothing in technology is certain, but I firmly believe that WebGL is here to stay—or I wouldn’t have taken the time and energy to write this book. WebGL is a very promising technology being developed at the right time when browsers are under rapid release cycles and are supporting more advanced features daily. It is also a time when more and more powerful computers are being crammed into mobile devices everywhere. WebGL is already a very useable technology. Framework improvements will help lower the bar for new developers, more debug and utility tools will be created, and performance will continue to improve.

301 APPENDIX A

Essential HTML5 and JavaScript

There are many, many improvements and features that are either part of HTML5 or associated with it: geolocation, new input types, validation, local storage, and web sockets (to name a few). Covering everything new is both not feasible and not desired here—there are recent large books that do so in depth.

Essential HTML5 While you will not need to know everything new and great about HTML5 to follow along with this book, to maximize your understanding of the code samples we will present the relevant differences from HTML 4 that you need to be aware of.

Brevity First, HTML5 allows more compact writing of a document by standardizing the opening tags and having shorthand for scripts and styles. In HTML 4, you would have something like code Listing A-1 below:

Listing A-1. A minimalistic HTML 4 document Example

Some text

303 APPENDIX A N ESSENTIAL HTML5 AND JAVASCRIPT

With HTML5, the equivalent document is shorter and clearer to write, as shown in Listing A-2. You do not have to declare transitional or strict in your doctype, just the simple and clean . We can also leave out the type attribute for the style and script tags because JavaScript and CSS are the default.

Listing A-2. A minimalistic HTML5 document Example

Some text

Semantic Areas We just showed that HTML5 has some nice shorthand over HTML 4. HTML 5 also lets you outline your document in a more natural and expressive manner. In the past, if you wanted a header and footer area of your page, one way of styling would be to group the relevant content in a

with an appropriately expressive id attribute value such as that shown in Listing A-3.

Listing A-3. HTML 4 document with id used to mark major sections Example

Some text

304 APPENDIX A N ESSENTIAL HTML5 AND JAVASCRIPT

With HTML5, we have many new included tags such as

and