CONTENTS
Game and Graphics Programming for iOS and Android with OpenGL ES 2.0
This edition first published 2012
Copyright 2012 Romain Marucchi-Foino
Registered office
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom
For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our web site at www.wiley.com .
The right of the author to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.
All rights reserved. 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, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought.
978-1-119-97591-5
978-1-119-97626-4 (ebk)
978-1-119-97627-1 (ebk)
978-1-119-97628-8 (ebk)
ABOUT THE AUTHOR
ROMAIN MARUCCHI-FOINO is the original author and founder of the popular mobile game engine SIO2 ( http://sio2interactive.com ). Formerly a game engine developer, Romain has dedicated his efforts to build a state-of-the-art game engine for mobile devices using OpenGL ES since the arrival of the iPhone. He is currently working as the lead 3D programmer for sio2interactive.com , the official developer of the SIO2 Engine, which powers thousands of games and 3D applications throughout the App Store and the Android market. His experience in the mobile game industry has led him to contribute his work to many online communities, publications, and blogs.
ABOUT THE TECHNICAL EDITOR
EFFIE C. LEE is a self-employed game and graphics designer who has been working in the game industry for the last 4 years. With a bachelors degree in Computer Science and a real passion for electronic games and computer graphics, she has been involved in multiple mobile game productions. With her wide range of knowledge in the game development process, she has been professionally working as a 2D and 3D graphics designer, game programmer (scripting), and web designer for game sites, as well as managing game quality assurance and localization. If you would like to reach her, send an email to .
CREDITS
VP CONSUMER AND TECHNOLOGY PUBLISHING DIRECTOR
Michelle Leete
ASSOCIATE DIRECTORBOOK CONTENT MANAGEMENT
Martin Tribe
ASSOCIATE PUBLISHER
Chris Webb
SENIOR ACQUISITIONS EDITOR
Chris Katsaropoulos
ASSISTANT EDITOR
Ellie Scott
ASSOCIATE MARKETING DIRECTOR
Louise Breinholt
SENIOR MARKETING EXECUTIVE
Kate Parrett
EDITORIAL MANAGER
Jodi Jensen
SENIOR PROJECT EDITOR
Sara Shlaer
DEVELOPMENT AND COPY EDITOR
Kathryn Duggan
TECHNICAL EDITOR
Effie C. Lee
SENIOR PRODUCTION EDITOR
Debra Banninger
PROOFREADER
Nancy Carrasco
INDEXER
Robert Swanson
COVER DESIGNER
LeAndra Young
COVER IMAGE
iStock / Vladislav Ociacia
INTRODUCTION
WELCOME TO Game and Graphics Programming for iOS and Android with OpenGL ES 2.0 . This book is not your usual OpenGL Hello Triangle book its not meant to explain the why (Google is there for that), but rather, to show you the how. This book will strictly teach you what works and what doesnt when it comes to game and graphics programming.
Using more than 50 unique tutorials (which also include some full game frameworks), this book adopts a straightforward practical approach (probably never seen before) that only focuses on what you need to learn to insure that you will be able to create a game.
You will learn all the necessary elements in order to create a full-fledged game with rich 3D graphics. If you are looking for an aggressive teaching method that enables you to quickly move forward to create your dream game, this book is for you!
WHO THIS BOOK IS FOR
Be aware that this is not a beginner book. It is an intermediate-level book that assumes you are familiar with linear algebra (matrices, vectors, and quaternions), you have a strong C/C++ programming background, you have at least touched base with OpenGL or OpenGL ES, and you basically know how computer graphics work in general.
If you have this necessary knowledge, and want to make lightning-fast progress in game and graphics programming, then you have found the right publication. This book is written for people who want to learn the hardcore stuff fast in order to be able to create and push a full-fledged game on the App Store and the Android Market.
WHAT THIS BOOK COVERS
Basically everything you need to know in order to create a full game is included in this book. You will learn about all aspects of creating a game, such as loading 3D geometries and textures; how to handle materials, shaders, sounds, cameras, clipping, physics, AI, pathfinding, skeletal animations; and a lot more.
By the end of this book you will be able to apply the knowledge youve learned and combine the different tutorials youve completed to create your own state-of-the-art game.
HOW THIS BOOK IS STRUCTURED
This book is structured in such a way that pretty much all chapters depend on each other. Each chapter shows you progressively how to master the necessary techniques to be able to handle the next chapter.
Here is a list of all the chapters and what will be covered in each of them:
- Chapter 1, Getting Started You will learn how to set up your development environment, download this books SDK, import and re-compile the tutorials, and deal with the template project that you will be using throughout this publication.
- Chapter 2, Setting Up Your Graphic Projections Since you have a running template, I will show you how to set up the necessary projection matrix to be able to handle 2D, 2.5D, or 3D. You will also learn how to draw simple geometry onscreen and handle a camera matrix.
- Chapter 3, Dealing with Complex Geometry You will create a Wavefront OBJ viewer that will allow you to learn how to load complex geometry from disk. You will also learn how to load and create textures, deal with basic lighting, and respond to touch events.
- Chapter 4, Building a Scene This chapter will extend the knowledge that youve learned in Chapter 3 and will explain how to handle a more complex scene. You will learn about drawing sequences and how to create reusable shaders.
- Chapter 5, Optimization In this chapter, I will show you techniques that will allow you to optimize the performance of your drawing. You will touch base with texture compression and shader optimization, and learn how to convert triangles to triangle strips as well as other tips and tricks to get better FPS.