OpenGL ES 2 for Android
eBook - ePub

OpenGL ES 2 for Android

A Quick-Start Guide

  1. 346 pages
  2. English
  3. ePUB (mobile friendly)
  4. Only available on web
eBook - ePub

OpenGL ES 2 for Android

A Quick-Start Guide

Book details
Table of contents
Citations

About This Book

This book will teach you everything you need to know to create compelling graphics on Android. You'll learn the basics of OpenGL by building a simple game of air hockey, and along the way, you'll 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, you'll find out how to turn your idea into a live wallpaper that can run on the home screen. You'll learn about more advanced effects involving particles, lighting models, and the depth buffer. You'll understand what to look for when debugging your program, and what to watch out for when deploying to the market.

OpenGL can be somewhat of a dark art to the uninitiated. As you read this book, you'll learn each new concept from first principles. You won't just learn about a feature; you'll also understand how it works, and why it works the way it does. Everything you learn is forward-compatible with the just-released OpenGL ES 3, and you can even apply these techniques to other platforms, such as iOS or HTML5 WebGL.

What You Need

Preferably an Android phone or tablet that supports OpenGL ES 2.

Top Five OpenGL ES Tips

1) Avoid expensive operations on the UI and rendering threads.

To avoid frame rate stutters or the dreaded "Application not responding" dialog from appearing, expensive operations should be run asynchronously in a background thread. This is especially important when it comes to the rendering thread, as rendering at 30 frames per second means that each frame has to complete in about 33 milliseconds to avoid frame stutters.

Garbage collection is an expensive operation that happens non-deterministically and can cause rendering stalls, so to avoid this, you'll also want to minimize object allocation during a frame to reduce pressure on the garbage collector. You may even see benefits to doing a manual GC at certain points in the application.

2) Do expensive texture and shader loads during intermissions.

Some expensive operations need to be done on the rendering thread, such as texture loads and shader compilations. These operations can cause noticeable stuttering if they happen in the middle of rendering, so to avoid this, preload these resources at opportune times, such as when the game / application is loaded, or at the beginning of each level.

3) Take advantage of the libraries out there.

There are many libraries out there that support OpenGL ES 2.0 development without boxing you into a framework or a closed-source middleware solution. Libgdx is one of these libraries, and by using a library like libgdx, you can more easily port your code to other platforms, as well as take advantage of the library's math classes and asset loading management.

4) Read the documentation

The OpenGL specs and manuals are available for free from Khronos.org. Each GPU vendor also shares a wealth of free information on how to use their GPUs, and as you read the documentation, you'll find that they generally share a lot of advice in common, such as "minimize state switches" and "avoid discard in a fragment shader." Reading these documents and specs will give you a lot more insight into how the GPUs work at a lower level, and will help you understand what the pitfalls are, and how to avoid premature pessimization when writing your OpenGL code.

5) Focus on what will impress the end user

Sometimes it's easy to lose sight of the end goal, and to become focused on optimizing areas that won't make much of a difference to the end user. Does it matter if we get this shader to execute 2% faster? Or will we make much more of a visual impact by finding a better artist? Find out what the most important areas are, and then focus on improving those first.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access OpenGL ES 2 for Android by Kevin Brothaler in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Graphics. We have over one million books available in our catalogue for you to explore.

Information

Year
2013
ISBN
9781680504064

Table of contents

  1. OpenGL ES 2 for Android
  2. ​
  3. Table of Contents
  4. Early praise for OpenGL ES 2.0 for Android
  5. Foreword
  6. Acknowledgments
  7. Welcome to OpenGL ES for Android!
  8. Chapter 1: Getting Started
  9. Part 1: A Simple Game of Air Hockey
  10. Chapter 2: Defining Vertices and Shaders
  11. Chapter 3: Compiling Shaders and Drawing to the Screen
  12. Chapter 4: Adding Color and Shade
  13. Chapter 5: Adjusting to the Screen’s Aspect Ratio
  14. Chapter 6: Entering the Third Dimension
  15. Chapter 7: Adding Detail with Textures
  16. Chapter 8: Building Simple Objects
  17. Chapter 9: Adding Touch Feedback: Interacting with Our Air Hockey Game
  18. Part 2: Building a 3D World
  19. Chapter 10: Spicing Things Up with Particles
  20. Chapter 11: Adding a Skybox
  21. Chapter 12: Adding Terrain
  22. Chapter 13: Lighting Up the World
  23. Chapter 14: Creating a Live Wallpaper
  24. Chapter 15: Taking the Next Step
  25. Appendix 1: The Matrix Math Behind the Projections
  26. Appendix 2: Debugging
  27. Bibliography