ebook img

iPhone 3D Programming: Developing Graphical Applications with OpenGL ES PDF

440 Pages·2010·6.668 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview iPhone 3D Programming: Developing Graphical Applications with OpenGL ES

iPhone 3D Programming iPhone 3D Programming Developing Graphical Applications with OpenGL ES Philip Rideout foreword by Serban Porumbescu Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo iPhone 3D Programming by Philip Rideout Copyright © 2010 Philip Rideout. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected]. Editor: Brian Jepson Indexer: Ellen Troutman Zaig Production Editor: Loranah Dimant Cover Designer: Karen Montgomery Copyeditor: Kim Wimpsett Interior Designer: David Futato Proofreader: Teresa Barensfeld Illustrator: Robert Romano Production Services: Molly Sharp Printing History: May 2010: First Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. iPhone 3D Programming, the image of a grasshopper, and related trade dress are trademarks of O’Reilly Media, Inc. 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 O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein. TM This book uses RepKover™, a durable and flexible lay-flat binding. ISBN: 978-0-596-80482-4 [M] 1272645927 Frank and Doris Rideout 1916–1998 and 1919–2007 Table of Contents Foreword .................................................................. xiii Preface ..................................................................... xv 1. Quick-Start Guide ....................................................... 1 Transitioning to Apple Technology 3 Objective-C 3 A Brief History of OpenGL ES 4 Choosing the Appropriate Version of OpenGL ES 4 Getting Started 5 Installing the iPhone SDK 6 Building the OpenGL Template Application with Xcode 6 Deploying to Your Real iPhone 8 HelloArrow with Fixed Function 9 Layering Your 3D Application 9 Starting from Scratch 11 Linking in the OpenGL and Quartz Libraries 12 Subclassing UIView 13 Hooking Up the Application Delegate 19 Setting Up the Icons and Launch Image 21 Dealing with the Status Bar 22 Defining and Consuming the Rendering Engine Interface 22 Implementing the Rendering Engine 26 Handling Device Orientation 30 Animating the Rotation 31 HelloArrow with Shaders 34 Shaders 34 Frameworks 36 GLView 36 RenderingEngine Implementation 37 Wrapping Up 42 vii 2. Math and Metaphors ................................................... 43 The Assembly Line Metaphor 43 Assembling Primitives from Vertices 44 Associating Properties with Vertices 47 The Life of a Vertex 49 The Photography Metaphor 51 Setting the Model Matrix 55 Setting the View Transform 58 Setting the Projection Transform 59 Saving and Restoring Transforms with Matrix Stacks 62 Animation 64 Interpolation Techniques 64 Animating Rotation with Quaternions 65 Vector Beautification with C++ 66 HelloCone with Fixed Function 69 RenderingEngine Declaration 69 OpenGL Initialization and Cone Tessellation 71 Smooth Rotation in Three Dimensions 75 Render Method 77 HelloCone with Shaders 78 Wrapping Up 81 3. Vertices and Touch Points ............................................... 83 Reading the Touchscreen 83 Saving Memory with Vertex Indexing 89 Boosting Performance with Vertex Buffer Objects 94 Creating a Wireframe Viewer 98 Parametric Surfaces for Fun 100 Designing the Interfaces 104 Handling Trackball Rotation 106 Implementing the Rendering Engine 108 Poor Man’s Tab Bar 111 Animating the Transition 115 Wrapping Up 117 4. Adding Depth and Realism ............................................. 119 Examining the Depth Buffer 119 Beware the Scourge of Depth Artifacts 121 Creating and Using the Depth Buffer 123 Filling the Wireframe with Triangles 125 Surface Normals 128 Feeding OpenGL with Normals 128 The Math Behind Normals 129 viii | Table of Contents

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.