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

Loading textures using the Asset manager


I guess you need something more consistent than just changing the screen color! But before showing awesome graphics in our application, we need to load some external resources.

In this second part, we are going to load a texture into OpenGL ES thanks to the Android Asset manager, an API provided since NDK R5. It allows programmers to access any resources stored in the assets folder in their project. Assets stored there are then packaged into the final APK archive during application compilation. Asset resources are considered as raw binary files that your application needs to interpret and access using their filename relative to the assets folder (a file assets/mydir/myfile can be accessed with mydir/myfile path). Files are available in the read-only mode and might be compressed.

If you have already written some Java Android application, then you know that Android also provides resources accessible through compile-time generated IDs inside the res project...