Mobile 3D Graphics

with OpenGL ES and M3G


  • Kari Pulli
  • Tomi Aarnio
  • Ville Miettinen
  • Kimmo Roimela, Nokia Corporation, Finland
  • Jani Vaarala

Graphics and game developers must learn to program for mobility. This book will teach you how. "This book - written by some of the key technical experts...provides a comprehensive but practical and easily understood introduction for any software engineer seeking to delight the consumer with rich 3D interactive experiences on their phone. Like the OpenGL ES and M3G standards it covers, this book is destined to become an enduring standard for many years to come." - Lincoln Wallen, CTO, Electronic Arts, Mobile“This book is an escalator, which takes the field to new levels. This is especially true because the text ensures that the topic is easily accessible to everyone with some background in computer science...The foundations of this book are clear, and the authors are extremely knowledgeable about the subject.” - Tomas Akenine-Möller, bestselling author and Professor of Computer Science at Lund University "This book is an excellent introduction to M3G. The authors are all experienced M3G users and developers, and they do a great job of conveying that experience, as well as plenty of practical advice that has been proven in the field." - Sean Ellis, Consultant Graphics Engineer, ARM LtdThe exploding popularity of mobile computing is undeniable. From cell phones to portable gaming systems, the global demand for multifunctional mobile devices is driving amazing hardware and software developments. 3D graphics are becoming an integral part of these ubiquitous devices, and as a result, Mobile 3D Graphics is arguably the most rapidly advancing area of the computer graphics discipline. Mobile 3D Graphics is about writing real-time 3D graphics applications for mobile devices. The programming interfaces explained and demonstrated in this must-have reference enable dynamic 3D media on cell phones, GPS systems, portable gaming consoles and media players. The text begins by providing thorough coverage of background essentials, then presents detailed hands-on examples, including extensive working code in both of the dominant mobile APIs, OpenGL ES and M3G. C/C++ and Java Developers, graphic artists, students, and enthusiasts would do well to have a programmable mobile phone on hand to try out the techniques described in this book. The authors, industry experts who helped to develop the OpenGL ES and M3G standards, distill their years of accumulated knowledge within these pages, offering their insights into everything from sound mobile design principles and constraints, to efficient rendering, mixing 2D and 3D, lighting, texture mapping, skinning and morphing. Along the way, readers will benefit from the hundreds of included tips, tricks and caveats.
View full description


Mobile 3D graphics application developers (mainly programmers and technical leads in game development), graphic artists, producers, and students of mobile 3D graphics.


Book information

  • Published: November 2007
  • ISBN: 978-0-12-373727-4


"1.1 billion 3D-enabled handsets will be in use worldwide by 2011" -Computer Graphics Magazine

Table of Contents

ContentsPrefaceAbout the AuthorsCHAPTER 1. INTRODUCTION1.1 About This Book1.1.1 Typographic Conventions1.2 Graphics on Handheld Devices1.2.1 Device Categories1.2.2 Display Technology1.2.3 Processing Power1.2.4 Graphics Hardware1.2.5 Execution Environments1.3 Mobile Graphics Standards1.3.1 Fighting the Fragmentation1.3.2 Design Principles1.3.3 OpenGL ES1.3.4 M3G1.3.5 Related StandardsPART I ANATOMY OF A GRAPHICS ENGINECHAPTER 2. LINEAR ALGEBRA FOR 3D GRAPHICS2.1 Coordinate Systems2.1.1 Vectors and Points2.1.2 Vector Products2.1.3 Homogeneous Coordinates2.2 Matrices2.2.1 Matrix Products2.2.2 Identity and Inverse2.2.3 Compound Transformations2.2.4 Transforming Normal Vectors2.3 Affine Transformations2.3.1 Types of Affine Transformations2.3.2 Transformation Around a Pivot2.3.3 Example: Hierarchical Modeling2.4 Eye Coordinate System2.5 Projections2.5.1 Near and Far Planes and the Depth Buffer2.5.2 A General View Frustum2.5.3 Parallel Projection2.6 Viewport and 2D Coordinate SystemsCHAPTER 3. LOW-LEVEL RENDERING3.1 Rendering Primitives3.1.1 Geometric Primitives3.1.2 Raster Primitives3.2 Lighting3.2.1 Color3.2.2 Normal Vectors3.2.3 Reflection Models and Materials3.2.4 Lights3.2.5 Full Lighting Equation3.3 Culling and Clipping3.3.1 Back-Face Culling3.3.2 Clipping and View-Frustum Culling3.4 Rasterization3.4.1 Texture Mapping3.4.2 Interpolating Gradients3.4.3 Texture-Based Lighting3.4.4 Fog3.4.5 Antialiasing3.5 Per-Fragment Operations3.5.1 Fragment Tests3.5.2 Blending3.5.3 Dithering, Logical Operations, and Masking3.6 Life Cycle of a Frame3.6.1 Single versus Double Buffering3.6.2 Complete Graphics System3.6.3 Synchronization PointsCHAPTER 4. ANIMATION 4.1 Keyframe Animation4.1.1 Interpolation4.1.2 Quaternions4.2 Deforming Meshes4.2.1 Morphing4.2.2 Skinning4.2.3 Other Dvnamic DeformationsCHAPTER 5. SCENE MANAGEMENT5.1 Triangle Meshes5.2 Scene Graphs5.2.1 Application Area5.2.2 Spatial Data Structure5.2.3 Content Creation5.2.4 Extensibility5.2.5 Class Hierarchy5.3 Retained Mode Rendering5.3.1 Setting Up the Camera and Lights5.3.2 Resolving Rendering Slate5.3.3 Finding Potentially Visible Objects5.3.4 Sorting and RenderingCHAPTER 6. PERFORMANCE AND SCALABILITY6.1 Scalability6.1.1 Special Effects6.1.2 Tuning Down the Details6.2 Performance Optimization6.2.1 Pixel Pipeline6.2.2 Vertex Pipeline6.2.3 Application Code6.2.4 Profiling OpenGL ES Based Applications6.2.5 Checklists6.3 Changing and Querying the State6.3.1 Optimizing State Changes6.4 Model Data6.4.1 Vertex Data6.4.2 Triangle Data6.5 Transformation Pipeline6.5.1 Object Hierarchies6.5.2 Rendering Order6.5.3 Culling6.6 Lighting6.6.1 Precomputed Illumination6.7 Textures6.7.1 Texture StoragePART II OPENGL ES AND EGL CHAPTER 7. INTRODUCING OPENGL ES 7.1 Khronos Group and OpenGL ES 7.2 Design Principles 7.3 Resources 7.3.1 Documentation 7.3.2 Technical Support 7.3.3 Implementations 7.4 API Overview 7.4.1 Profiles and Versions 7.4.2 OpenGL ES 1.0 in a Nutshell 7.4.3 New Features in OpenGL ES 1.1 7.4.4 Extension Mechanism 7.4.5 OpenGL ES Extension Pack 7.4.6 Utility APIs 7.4.7 Conventions 7.5 Hello, OpenGL ES! CHAPTER 8. OPENGL ES TRANSFORMATION AND LIGHTING8.1 Drawing Primitives8.1.1 Primitive Types8.1.2 Specifying Vertex Data8.1.3 Drawing the Primitives8.1.4 Vertex Buffer Objects8.2 Vertex Transformation Pipeline8.2.1 Matrices8.2.2 Transforming Normals8.2.3 Texture Coordinate Transformation8.2.4 Matrix Stacks8.2.5 Viewport Transformation8.2.6 User Clip Planes8.3 Colors and Lighting8.3.1 Specifying Colors and Materials8.3.2 Lights8.3.3 Two-Sided Lighting8.3.4 Shading8.3.5 Lighting ExampleCHAPTER 9. OPENGL ES RASTERIZATION AND FRAGMENT PROCESSING9.1 Back-Face Culling9.2 Texture Mapping9.2.1 Texture Objects9.2.2 Specifying Texture Data9.2.3 Texture Filtering9.2.4 Texture Wrap Modes9.2.5 Basic Texture Functions9.2.6 Multi-Texturing9.2.7 Texture Combiners9.2.8 Point Sprite Texturing9.2.9 Implementation Differences9.3 Fog9.4 Antialiasing9.4.1 Edge Antialiasing9.4.2 Multisampling9.4.3 Other Antialiasing Approaches9.5 Pixel Tests9.5.1 Scissoring9.5.2 Alpha Test9.5.3 Stencil Test9.5.4 Depth Testing9.6 Applying Fragments to the Color Buffer9.6.1 Blending9.6.2 Dithering9.6.3 Logic Ops9.6.4 Masking Frame Buffer ChannelsCHAPTER 10. MISCELLANEOUS OPENGL ES FEATURES10.1 Frame Buffer Operations10.1.1 Clearing the Buffers10.1.2 Reading Back the Color Buffer10.1.3 Flushing the Command Stream10.2 State Queries10.2.1 Static State10.2.2 Dynamic State Queries10.3 Hints10.4 Extensions10.4.1 Querying Extensions10.4.2 Query Matrix10.4.3 Matrix Palette10.4.4 Draw Texture10.4.5 Using ExtensionsCHAPTER 11. EGL 11.1 API Overview 11.2 Configuration 11.3 Surfaces 11.4 Contexts 11.5 Extensions 11.6 Rendering into Textures 11.7 Writing High-Performance EGL Code 11.8 Mixing OpenGL ES and 2D Rendering 11.8.1 Method 1: Window Surface is in Control 11.8.2 Method 2: Pbuffer Surfaces and Bitmaps 11.8.3 Method 3: Pixmap Surfaces 11.9 Optimizing Power Usage 11.9.1 Power Management Implementations 11.9.2 Optimizing the Active Mode 11.9.3 Optimizing the Idle Mode 11.9.4 Measuring Power Usage 11.10 Example on EGL Configuration Selection PART III M3G CHAPTER 12. INTRODUCING M3G 12.1 Overview 12.1.1 Mobile Java 12.1.2 Features and Structure 12.1.3 Hello, World 12.2 Design Principles and Conventions I2.2.1 High Abstraction Level 12.2.2 No Events or Callbacks 12.2.3 Robust Arithmetic 12.2.4 Consistent Methods 12.2.5 Parameter Passing 12.2.6 Numeric Values 12.2.7 Enumerations 12.2.8 Error Handling 12.3 M3G 1.1 12.3.1 Pure 3D Rendering 12.3.2 Rotation Interpolation 12.3.3 PNG and JPEG Loading12.3.4 New Getters 12.3.5 Other ChangesCHAPTER 13. BASIC M3G CONCEPTS13.1 Graphics3D13.1.1 Render Targets13.1.2 Viewport13.1.3 Rendering13.1.4 Static Properties13.2 Image2D13.3 Matrices and Transformations13.3.1 Transform13.3.2 Transformable13.4 Object3D13.4.1 Animating13.4.2 Iterating and Cloning13.4.3 Tags and Annotations13.5 Importing Content13.5.1 Loader13.5.2 The File FormatCHAPTER 14. LOW-LEVEL MODELING IN M3G14.1 Building meshes14.1.1 VertexArray14.1.2 VertexBuffer14.1.3 IndexBuffer and Rendering Primitives14.1.4 Example14.2 Adding Color and Light: Appearance14.2.1 PolygonMode14.2.2 Material14.2.3 Texture2D14.2.4 Fog14.2.5 CompositingMode14.3 Lights and Camera14.3.1 Camera14.3.2 Light14.4 2D Primitives14.4.1 Background14.4.2 Sprite3DCHAPTER 15. THE M3G SCENE GRAPH15.1 Scene Graph Basics: Node, Group, and World15.2 Mesh Objects15.3 Transforming Objects15.3.1 Camera, Light, and Viewing Transformations15.3.2 Node Alignment15.4 Layering and Multi-Pass Effects15.5 Picking15.6 Optimizing Performance15.6.1 Visibility Optimization15.6.2 Scope MasksCHAPTER 16. ANIMATION IN M3G16.1 Keyframe Animation: KeyframeSequence16.2 Animation Targets: AnimationTrack16.3 Timing and Speed: AnimationController16.4 Animation Execution16.5 Advanced Animation16.5.1 Deformable Meshes16.5.2 Animation Blending16.5.3 Creating Discontinuities16.5.4 Dynamic AnimationPART IV APPENDIXA FIXED-POINT MATHEMATICS A.1 Fixed-Point Methods in CA.1.1 Basic Operations A.1.2 Shared ExponentsA.1.3 Trigonometric OperationsA.2 Fixed-Point Methods in Assembly Language A.3 Fixed-Point Methods in JavaB JAVA PERFORMANCE TUNINGB.1 Virtual MachinesB.2 Bytecode OptimizationB.3 Garbage CollectionB.4 Memory AccessesB.5 Method CallsC GLOSSARYBibliography Index