You are previewing iPhone 3D Programming.
O'Reilly logo
iPhone 3D Programming

Book Description

Do you have a great idea for a graphics-intensive iPhone application, but don't know how to bring it to life? This book offers the perfect solution: a crash course on the OpenGL graphics library with an overview of iPhone 3D development. Whether you're an experienced OpenGL developer looking to build iPhone apps for the first time, or an iPhone developer wanting to learn sophisticated graphics, iPhone 3D Programming brings both of these worlds together in one concise, easy-to-use guide.

Table of Contents

  1. iPhone 3D Programming
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Foreword
    4. Preface
      1. How to Read This Book
      2. Conventions Used in This Book
      3. Using Code Examples
      4. Safari® Books Online
      5. How to Contact Us
      6. Acknowledgments
    5. 1. Quick-Start Guide
      1. Transitioning to Apple Technology
        1. Objective-C
      2. A Brief History of OpenGL ES
      3. Choosing the Appropriate Version of OpenGL ES
      4. Getting Started
        1. Installing the iPhone SDK
        2. Building the OpenGL Template Application with Xcode
        3. Deploying to Your Real iPhone
      5. HelloArrow with Fixed Function
        1. Layering Your 3D Application
        2. Starting from Scratch
        3. Linking in the OpenGL and Quartz Libraries
        4. Subclassing UIView
        5. Hooking Up the Application Delegate
        6. Setting Up the Icons and Launch Image
        7. Dealing with the Status Bar
        8. Defining and Consuming the Rendering Engine Interface
        9. Implementing the Rendering Engine
        10. Handling Device Orientation
        11. Animating the Rotation
      6. HelloArrow with Shaders
        1. Shaders
        2. Frameworks
        3. GLView
        4. RenderingEngine Implementation
      7. Wrapping Up
    6. 2. Math and Metaphors
      1. The Assembly Line Metaphor
      2. Assembling Primitives from Vertices
      3. Associating Properties with Vertices
      4. The Life of a Vertex
      5. The Photography Metaphor
        1. Setting the Model Matrix
          1. Scale
          2. Translation
          3. Rotation
        2. Setting the View Transform
        3. Setting the Projection Transform
      6. Saving and Restoring Transforms with Matrix Stacks
      7. Animation
        1. Interpolation Techniques
        2. Animating Rotation with Quaternions
      8. Vector Beautification with C++
      9. HelloCone with Fixed Function
        1. RenderingEngine Declaration
        2. OpenGL Initialization and Cone Tessellation
        3. Smooth Rotation in Three Dimensions
        4. Render Method
      10. HelloCone with Shaders
      11. Wrapping Up
    7. 3. Vertices and Touch Points
      1. Reading the Touchscreen
      2. Saving Memory with Vertex Indexing
      3. Boosting Performance with Vertex Buffer Objects
      4. Creating a Wireframe Viewer
        1. Parametric Surfaces for Fun
        2. Designing the Interfaces
        3. Handling Trackball Rotation
        4. Implementing the Rendering Engine
        5. Poor Man’s Tab Bar
        6. Animating the Transition
      5. Wrapping Up
    8. 4. Adding Depth and Realism
      1. Examining the Depth Buffer
        1. Beware the Scourge of Depth Artifacts
      2. Creating and Using the Depth Buffer
      3. Filling the Wireframe with Triangles
      4. Surface Normals
        1. Feeding OpenGL with Normals
        2. The Math Behind Normals
        3. Normal Transforms Aren’t Normal
        4. Generating Normals from Parametric Surfaces
      5. Lighting Up
        1. Ho-Hum Ambiance
        2. Matte Paint with Diffuse Lighting
        3. Give It a Shine with Specular
        4. Adding Light to ModelViewer
        5. Using Light Properties
      6. Shaders Demystified
      7. Adding Shaders to ModelViewer
        1. New Rendering Engine
        2. Per-Pixel Lighting
        3. Toon Shading
      8. Better Wireframes Using Polygon Offset
      9. Loading Geometry from OBJ Files
        1. Managing Resource Files
        2. Implementing ISurface
      10. Wrapping Up
    9. 5. Textures and Image Capture
      1. Adding Textures to ModelViewer
        1. Enhancing IResourceManager
        2. Generating Texture Coordinates
        3. Enabling Textures with ES1::RenderingEngine
        4. Enabling Textures with ES2::RenderingEngine
      2. Texture Coordinates Revisited
      3. Fight Aliasing with Filtering
        1. Boosting Quality and Performance with Mipmaps
        2. Modifying ModelViewer to Support Mipmaps
      4. Texture Formats and Types
        1. Hands-On: Loading Various Formats
      5. Texture Compression with PVRTC
      6. The PowerVR SDK and Low-Precision Textures
      7. Generating and Transforming OpenGL Textures with Quartz
      8. Dealing with Size Constraints
        1. Scaling to POT
      9. Creating Textures with the Camera
        1. CameraTexture: Rendering Engine Implementation
      10. Wrapping Up
    10. 6. Blending and Augmented Reality
      1. Blending Recipe
      2. Wrangle Premultiplied Alpha
      3. Blending Caveats
      4. Blending Extensions and Their Uses
        1. Why Is Blending Configuration Useful?
      5. Shifting Texture Color with Per-Vertex Color
      6. Poor Man’s Reflection with the Stencil Buffer
        1. Rendering the Disk to Stencil Only
        2. Rendering the Reflected Object with Stencil Testing
        3. Rendering the “Real” Object
        4. Rendering the Disk with Front-to-Back Blending
      7. Stencil Alternatives for Older iPhones
      8. Anti-Aliasing Tricks with Offscreen FBOs
        1. A Super Simple Sample App for Supersampling
        2. Jittering
        3. Other FBO Effects
      9. Rendering Anti-Aliased Lines with Textures
      10. Holodeck Sample
        1. Application Skeleton
        2. Rendering the Dome, Clouds, and Text
        3. Handling the Heads-Up Display
        4. Replacing Buttons with Orientation Sensors
          1. Adding accelerometer support
          2. Adding compass support
        5. Overlaying with a Live Camera Image
      11. Wrapping Up
    11. 7. Sprites and Text
      1. Text Rendering 101: Drawing an FPS Counter
        1. Generating a Glyphs Texture with Python
        2. Rendering the FPS Text
          1. Stabilizing the counter with a low-pass filter
          2. Fleshing out the FpsRenderer class
      2. Simplify with glDrawTexOES
      3. Crisper Text with Distance Fields
        1. Generating Distance Fields with Python
        2. Use Distance Fields Under ES 1.1 with Alpha Testing
        3. Adding Text Effects with Fragment Shaders
        4. Smoothing and Derivatives
        5. Implementing Outline, Glow, and Shadow Effects
      4. Animation with Sprite Sheets
      5. Image Composition and a Taste of Multitexturing
      6. Mixing OpenGL ES and UIKit
      7. Rendering Confetti, Fireworks, and More: Point Sprites
      8. Chapter Finale: SpringyStars
        1. Physics Diversion: Mass-Spring System
        2. C++ Interfaces and GLView
        3. ApplicationEngine Implementation
        4. OpenGL ES 1.1 Rendering Engine and Additive Blending
        5. Point Sprites with OpenGL ES 2.0
      9. Wrapping Up
    12. 8. Advanced Lighting and Texturing
      1. Texture Environments under OpenGL ES 1.1
        1. Texture Combiners
      2. Bump Mapping and DOT3 Lighting
        1. Another Foray into Linear Algebra
        2. Generating Basis Vectors
        3. Normal Mapping with OpenGL ES 2.0
        4. Normal Mapping with OpenGL ES 1.1
        5. Generating Object-Space Normal Maps
      3. Reflections with Cube Maps
        1. Render to Cube Map
      4. Anisotropic Filtering: Textures on Steroids
      5. Image-Processing Example: Bloom
        1. Better Performance with a Hybrid Approach
        2. Sample Code for Gaussian Bloom
      6. Wrapping Up
    13. 9. Optimizing
      1. Instruments
      2. Understand the CPU/GPU Split
      3. Vertex Submission: Above and Beyond VBOs
        1. Batch, Batch, Batch
        2. Interleaved Vertex Attributes
        3. Optimize Your Vertex Format
        4. Use the Best Topology and Indexing
      4. Lighting Optimizations
        1. Object-Space Lighting
        2. DOT3 Lighting Revisited
        3. Baked Lighting
      5. Texturing Optimizations
      6. Culling and Clipping
        1. Polygon Winding
        2. User Clip Planes
        3. CPU-Based Clipping
      7. Shader Performance
        1. Conditionals
        2. Fragment Killing
        3. Texture Lookups Can Hurt!
      8. Optimizing Animation with Vertex Skinning
        1. Skinning: Common Code
        2. Skinning with OpenGL ES 2.0
        3. Skinning with OpenGL ES 1.1
        4. Generating Weights and Indices
        5. Watch Out for Pinching
      9. Further Reading
    14. A. C++ Vector Library
      1. Disclaimer Regarding Performance
      2. Vector.hpp
      3. Matrix.hpp
      4. Quaternion.hpp
    15. Index
    16. About the Author
    17. Colophon
    18. SPECIAL OFFER: Upgrade this ebook with O’Reilly