WebGL Programming Guide: Interactive 3D Graphics With Guide
webgl_programming_guide
webgl_programming_guide
User Manual:
Open the PDF directly: View PDF
.
Page Count: 544
Praise for
WebGL Programming Guide
“WebGL provides one of the final features for creating applications that deliver ‘the desktop application experience’ in a web browser, and the WebGL Programming Guide leads the
way in creating those applications. Its coverage of all aspects of using WebGL—JavaScript,
OpenGL ES, and fundamental graphics techniques—delivers a thorough education on everything you need to get going. Web-based applications are the wave of the future, and this
book will get you ahead of the curve!”
Dave Shreiner, Coauthor of The OpenGL Programming Guide, Eighth Edition; Series Editor,
OpenGL Library (Addison Wesley)
“HTML5 is evolving the Web into a highly capable application platform supporting beautiful, engaging, and fully interactive applications that run portably across many diverse
systems. WebGL is a vital part of HTML5, as it enables web programmers to access the
full power and functionality of state-of-the-art 3D graphics acceleration. WebGL has been
designed to run securely on any web-capable system and will unleash a new wave of developer innovation in connected 3D web-content, applications, and user interfaces. This book
will enable web developers to fully understand this new wave of web functionality and
leverage the exciting opportunities it creates.”
Neil Trevett, Vice President Mobile Content, NVIDIA; President, The Khronos Group
“With clear explanations supported by beautiful 3D renderings, this book does wonders in
transforming a complex topic into something approachable and appealing. Even without
denying the sophistication of WebGL, it is an accessible resource that beginners should
consider picking up before anything else.”
Evan Burchard, Author, Web Game Developer’s Cookbook (Addison Wesley)
“Both authors have a strong OpenGL background and transfer this knowledge nicely over
to WebGL, resulting in an excellent guide for beginners as well as advanced readers.”
Daniel Haehn, Research Software Developer, Boston Children’s Hospital
“WebGL Programming Guide provides a straightforward and easy-to-follow look at the mechanics of building 3D applications for the Web without relying on bulky libraries or wrappers. A great resource for developers seeking an introduction to 3D development concepts
mixed with cutting-edge web technology.”
Brandon Jones, Software Engineer, Google
“This is more great work from a brilliant researcher. Kouichi Matsuda shows clear and concise steps to bring the novice along the path of understanding WebGL. This is a complex
topic, but he makes it possible for anyone to start using this exciting new web technology.
And he includes basic 3D concepts to lay the foundation for further learning. This will be a
great addition to any web designer’s library.”
Chris Marrin, WebGL Spec. Editor
“WebGL Programming Guide is a great way to go from a WebGL newbie to a WebGL expert.
WebGL, though simple in concept, requires a lot of 3D math knowledge, and WebGL Programming Guide helps you build this knowledge so you’ll be able to understand and apply
it to your programs. Even if you end up using some other WebGL 3D library, the knowledge learned in WebGL Programming Guide will help you understand what those libraries
are doing and therefore allow you to tame them to your application’s specific needs. Heck,
even if you eventually want to program desktop OpenGL and/or DirectX, WebGL Programming Guide is a great start as most 3D books are outdated relative to current 3D technology.
WebGL Programming Guide will give you the foundation for fully understanding modern 3D
graphics.”
Gregg Tavares, An Implementer of WebGL in Chrome
WebGL Programming
Guide
OpenGL Series
from Addison-Wesley
Visit informit.com/opengl for a complete list of available products.
T
he OpenGL graphics system is a software interface to graphics hardware.
(“GL” stands for “Graphics Library”.) It allows you to create interactive programs
that produce color images of moving, three-dimensional objects. With OpenGL,
you can control computer-graphics technology to produce realistic pictures, or
ones that depart from reality in imaginative ways.
The OpenGL Series from Addison-Wesley Professional comprises tutorial and
reference books that help programmers gain a practical understanding of OpenGL
standards, along with the insight needed to unlock OpenGL’s full potential.
Make sure to connect with us!
informit.com/socialconnect
WebGL
Programming
Guide:
Interactive 3D
Graphics Programming
with WebGL
Kouichi Matsuda
Rodger Lea
Upper Saddle River, NJ • Boston • Indianapolis • San Francisco
New York • Toronto • Montreal • London • Munich • Paris • Madrid
Cape Town • Sydney • Tokyo • Singapore • Mexico City
Many of the designations used by manufacturers and sellers to distinguish their
products are claimed as trademarks. Where those designations appear in this
book, and the publisher was aware of a trademark claim, the designations have
been printed with initial capital letters or in all capitals. OpenGL is a registered
trademark and the OpenGL ES logo is a trademark of Silicon Graphics Inc.
Khronos and WebGL are trademarks of the Khronos Group Inc. Google, Google
Chrome, and Android are trademarks of Google Inc. The Firefox web browser
is a registered trademark of the Mozilla Foundation. Apple, iPhone, Macintosh,
Safari and their logo are trademarks or registered trademarks of Apple Inc.
Microsoft, Microsoft Internet Explorer, Windows, Windows 7, and Windows 8
is a registered trademark of Microsoft Corporation. Nvidia and Nvidia Geforce
are trademarks of NVIDIA Corporation. AMD and Radeon are trademarks of
Advanced Micro Devices, Inc.
Editor-in-Chief
Mark Taub
The authors and publisher have taken care in the preparation of this book, but
make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or
programs contained herein.
Senior Indexer
Cheryl Lenser
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions
and/or custom covers and content particular to your business, training goals,
marketing focus, and branding interests. For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
corpsales@pearsontechgroup.com
For sales outside the United States, please contact:
International Sales
international@pearsoned.com
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2013936083
Copyright © 2013 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is
protected by copyright, and permission must be obtained from the publisher
prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this
work, please submit a written request to Pearson Education, Inc., Permissions
Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you
may fax your request to (201) 236-3290.
ISBN-13: 978-0-321-90292-4
ISBN-10: 0-321-90292-0
Text printed in the United States on recycled paper at Edwards Brothers Malloy
in Ann Arbor, Michigan
First printing: June 2013
Executive Editor
Laura Lewin
Development Editor
Sheri Cain
Managing Editor
Krista Hansing
Senior Project Editor
Lori Lyons
Copy Editor
Gill Editorial Services
Proofreader
Paula Lowell
Technical Reviewers
Jeff Gilbert
Daniel Haehn
Rick Rafey
Editorial Assistant
Olivia Basegio
Interior Designer
Mark Shirar
Cover Designer
Chuti Prasertsith
Senior Compositor
Gloria Schurick
Graphics
Laura Robbins
Manufacturing Buyer
Dan Uhrig
Thoughts are filled along with time, the distant days will not return,
and time passed is like a spiral of semiprecious stones...
—Kouichi Matsuda
To my wife, family, and friends—for making life fun.
—Rodger Lea
Contents
Preface
1.
Overview of WebGL
xvii
1
Advantages of WebGL ....................................................................................................3
You Can Start Developing 3D Graphics Applications Using Only a Text Editor .....3
Publishing Your 3D Graphics Applications Is Easy ...................................................4
You Can Leverage the Full Functionality of the Browser .........................................5
Learning and Using WebGL Is Easy...........................................................................5
Origins of WebGL ...........................................................................................................5
Structure of WebGL Applications ...................................................................................6
Summary ........................................................................................................................7
2.
Your First Step with WebGL
9
What Is a Canvas? ..........................................................................................................9
Using the