OpenGL ES 2 for Android: a quick-start guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Android is booming like never before, with millions of devices shipping every day. Its never been a better time to learn how to create your own 3D games and live wallpaper for Android. Youll find out all about shaders and the OpenGL pipeline, and discover the power of OpenGL ES 2.0, which is much more feature-rich than its predecessor. If you can program in Java and you have a creative vision that youd like to share with the world, then this is the book for you.
This book will teach you everything you need to know to create compelling graphics on Android. Youll learn the basics of OpenGL by building a simple game of air hockey, and along the way, youll see how to initialize OpenGL and program the graphics pipeline using shaders. Each lesson builds upon the one before it, as you add colors, shading, 3D projections, touch interaction, and more.
Then, youll find out how to turn your idea into a live wallpaper that can run on the home screen. Youll learn about more advanced effects involving particles, lighting models, and the depth buffer. Youll understand what to look for when debugging your program, and what to watch out for when deploying to the market.

Author(s): Kevin Brothaler
Series: Pragmatic programmers
Publisher: Pragmatic Bookshelf
Year: 2013

Language: English
Pages: 325
Tags: Библиотека;Компьютерная литература;OpenGL;

Cover......Page 1
Table of Contents......Page 7
Foreword......Page 11
Acknowledgments......Page 12
Welcome to OpenGL ES for Android!......Page 13
Who Should Read This book?......Page 14
Conventions......Page 15
Let's Get Started!......Page 16
Installing the Tools......Page 17
Creating Our First Program......Page 20
Initializing OpenGL......Page 22
Creating a Renderer Class......Page 27
Using Static Imports......Page 30
A Review......Page 31
Part I—A Simple Game of Air Hockey......Page 32
Why Air Hockey?......Page 33
Don't Start from Scratch......Page 35
Defining the Structure of Our Air Hockey Table......Page 36
Making the Data Accessible to OpenGL......Page 40
Introducing the OpenGL Pipeline......Page 42
The OpenGL Color Model......Page 48
A Review......Page 49
Loading Shaders......Page 51
Compiling Shaders......Page 53
Linking Shaders Together into an OpenGL Program......Page 58
Making the Final Connections......Page 60
Drawing to the Screen......Page 65
A Review......Page 71
Exercises......Page 72
4. Adding Color and Shade......Page 73
Smooth Shading......Page 74
Introducing Triangle Fans......Page 75
Adding a New Color Attribute......Page 77
Rendering with the New Color Attribute......Page 85
Exercises......Page 89
5. Adjusting to the Screen's Aspect Ratio......Page 90
We Have an Aspect Ratio Problem......Page 91
Working with a Virtual Coordinate Space......Page 93
Linear Algebra 101......Page 96
Defining an Orthographic Projection......Page 100
Adding an Orthographic Projection......Page 102
Exercises......Page 107
The Art of 3D......Page 108
Transforming a Coordinate from the Shader to the Screen......Page 109
Adding the W Component to Create Perspective......Page 112
Moving to a Perspective Projection......Page 114
Defining a Perspective Projection......Page 116
Creating a Projection Matrix in Our Code......Page 118
Switching to a Projection Matrix......Page 120
Adding Rotation......Page 124
Exercises......Page 127
7. Adding Detail with Textures......Page 128
Understanding Textures......Page 129
Loading Textures into OpenGL......Page 132
Creating a New Set of Shaders......Page 139
Creating a New Class Structure for Our Vertex Data......Page 140
Adding Classes for Our Shader Programs......Page 146
Drawing Our Texture......Page 150
Exercises......Page 152
8. Building Simple Objects......Page 153
Combining Triangle Strips and Triangle Fans......Page 154
Adding a Geometry Class......Page 155
Adding an Object Builder......Page 157
Updating Our Objects......Page 165
Updating Shaders......Page 167
Integrating Our Changes......Page 168
Exercises......Page 173
Adding Touch Support to Our Activity......Page 176
Adding Intersection Tests......Page 179
Moving Around an Object by Dragging......Page 188
Adding Collision Detection......Page 192
A Review and Wrap-Up......Page 196
Exercises......Page 197
Part II—Building a 3D World......Page 199
10. Spicing Things Up with Particles......Page 200
Creating a Set of Shaders for a Simple Particle System......Page 202
Adding the Particle System......Page 206
Drawing the Particle System......Page 210
Spreading Out the Particles......Page 213
Adding Gravity......Page 215
Mixing the Particles with Additive Blending......Page 217
Customizing the Appearance of Our Points......Page 218
Drawing Each Point as a Sprite......Page 220
Exercises......Page 223
11. Adding a Skybox......Page 225
Creating a Skybox......Page 226
Loading a Cube Map into OpenGL......Page 227
Creating a Cube......Page 229
Adding a Skybox Shader Program......Page 232
Adding the Skybox to Our Scene......Page 235
Panning the Camera Around the Scene......Page 236
Exercises......Page 240
Creating a Height Map......Page 241
Creating Vertex and Index Buffer Objects......Page 242
Loading in the Height Map......Page 245
Drawing the Height Map......Page 249
Occluding Hidden Objects......Page 253
A Review......Page 258
Exercises......Page 259
Simulating the Effects of Light......Page 260
Implementing a Directional Light with Lambertian Reflectance......Page 262
Adding Point Lights......Page 271
Exercises......Page 279
Implementing the Live Wallpaper Service......Page 282
Playing Nicely with the Rest of the System......Page 290
Exercises......Page 293
Looking Toward Other Platforms......Page 295
Learning About More Advanced Techniques......Page 297
Sharing Your Artistic Vision with the World......Page 301
The Math Behind Orthographic Projections......Page 303
The Math Behind Perspective Projections......Page 306
Debugging with glGetError......Page 310
Using Tracer for OpenGL ES......Page 311
Pitfalls to Watch Out For......Page 313
Bibliography......Page 316
– A –......Page 317
– C –......Page 318
– F –......Page 319
– I –......Page 320
– M –......Page 321
– P –......Page 322
– S –......Page 323
– U –......Page 324
– Z –......Page 325