Mobile 3D Graphics with OpenGL ES and M3G... Senior Production Editor Paul GottehrerMorgan Kaufmann Publishers is an imprint of Elsevier.. Designations used by companies to distinguish t
Trang 2Mobile 3D Graphics with OpenGL ES and M3G
Trang 4Mobile 3D Graphics
with OpenGL ES and M3G
Kari Pulli Tomi Aarnio Ville Miettinen Kimmo Roimela Jani Vaarala
AMSTERDAM • BOSTON • HEIDELBERG • LONDON
NEW YORK • OXFORD • PARIS • SAN DIEGO
SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO
Trang 5Senior Production Editor Paul Gottehrer
Morgan Kaufmann Publishers is an imprint of Elsevier
30 Corporate Drive, Suite 400, Burlington, MA 01803, USA
This book is printed on acid-free paper
c
2008 by Elsevier Inc All rights reserved.
Designations used by companies to distinguish their products are often claimed as trademarks or registered trademarks In all instances in which Morgan Kaufmann Publishers is aware of a claim, the product names appear in initial capital or all capital letters Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means—electronic, mechanical, photocopying, scanning, or otherwise—without prior written permission of the publisher
Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, E-mail: permissions@elsevier.com You may also complete your request online via the Elsevier homepage (http://elsevier.com), by selecting “Support
& Contact” then “Copyright and Permission” and then “Obtaining Permissions.”
Library of Congress Cataloging-in-Publication Data
Application submitted
ISBN: 978-0-12-373727-4
For information on all Morgan Kaufmann publications,
visit our Web site at www.mkp.com or www.books.elsevier.com
Printed in the United States of America
07 08 09 10 11 5 4 3 2 1
Trang 6CHAPTER 1 INTRODUCTION 1
1.1 About this Book 2
1.2 Graphics on Handheld Devices 3
1.3 Mobile Graphics Standards 12
CHAPTER 2 LINEAR ALGEBRA FOR 3D GRAPHICS 27
2.1 Coordinate Systems 27
Trang 72.3 Affine Transformations 35
2.4 Eye Coordinate System 42
2.5 Projections 44
2.5.1 Near and Far Planes and the Depth Buffer 45
2.6 Viewport and 2D Coordinate Systems 51
CHAPTER 3 LOW-LEVEL RENDERING 55
3.1 Rendering Primitives 57
3.3 Culling and Clipping 70
3.3.2 Clipping and View-Frustum Culling 71
3.4 Rasterization 73
3.5 Per-Fragment Operations 92
3.5.3 Dithering, Logical Operations, and Masking 99
3.6 Life Cycle of a Frame 100
3.6.1 Single versus Double Buffering 101
CHAPTER 4 ANIMATION 105
4.1 Keyframe Animation 105
Trang 84.2 Deforming Meshes 113
CHAPTER 5 SCENE MANAGEMENT 117
5.1 Triangle Meshes 118
5.2 Scene Graphs 120
5.3 Retained Mode Rendering 128
5.3.1 Setting Up the Camera and Lights 129
5.3.3 Finding Potentially Visible Objects 130
CHAPTER 6 PERFORMANCE AND SCALABILITY 133
6.1 Scalability 134
6.2 Performance Optimization 136
6.2.4 Profiling OpenGL ES Based Applications 141
6.3 Changing and Querying the State 145
6.4 Model Data 146
6.5 Transformation Pipeline 148
Trang 96.7 Textures 152
CHAPTER 7 INTRODUCING OPENGL ES 157
7.1 Khronos Group and OpenGL ES 157
7.2 Design Principles 158
7.3 Resources 159
7.4 API Overview 161
7.5 Hello, OpenGL ES! 170
CHAPTER 8 OPENGL ES TRANSFORMATION AND
8.1 Drawing Primitives 173
8.2 Vertex Transformation Pipeline 183
8.2.3 Texture Coordinate Transformation 186
8.3 Colors and Lighting 189
8.3.1 Specifying Colors and Materials 189
Trang 10CHAPTER 9 OPENGL ES RASTERIZATION AND
FRAGMENT PROCESSING 195
9.1 Back-Face Culling 195
9.2 Texture Mapping 196
9.4 Antialiasing 211
9.5 Pixel Tests 214
9.6 Applying Fragments to the Color Buffer 218
CHAPTER 10 MISCELLANEOUS OPENGL ES FEATURES 223
10.1 Frame Buffer Operations 223
10.1.2 Reading Back the Color Buffer 224
10.2 State Queries 225
10.4 Extensions 234