Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Drawing 2D sprites


2D games are based on sprites, which are pieces of images composited onscreen. They can represent an object, a character, a static, or an animated element. Sprites can be displayed with a transparency effect using the alpha channel of an image. Typically, an image will contain several frames for a sprite, each frame representing a different animation step or different objects.

Tip

If you need a powerful multiplatform image editor, consider using GNU Image Manipulation Program (GIMP). This program is available on Windows, Linux, and Mac OS X, and is a powerful and open source. You can download it from http://www.gimp.org/.

Several techniques exist to draw sprites using OpenGL. One of these is called Sprite Batch. This is one of the most efficient ways to create 2D games with OpenGL ES 2. It is based on a vertex array (stored in main memory) that is regenerated during each frame with all the sprites to render. Rendering is performed with the help of a simple vertex shader that...