
52 IDiscovering
Bitmap bitmap ;
InputStream is = context . getResources().openRawResource( R.drawable . imageName );
try {
bitmap = BitmapFactory.decodeStream( is );
is. close ();
} catch ( Exception e ) {}
int[] glName = new int [];
gl . glGenTextures( 1, glName );
gl . glBindTexture( GL10.GL_TEXTURE_2D , glName [0] );
GLUtils . texImage2D( GL10 .GL_TEXTURE_2D , 0, bitmap , 0 );
bitmap .recycle (); // Release the image data
Listing 4.7. Android using Bitmap to load a texture.
In WebGL, texture loading is almost as easy as specifying an img tag in HTML
(see Listing 4.8). The main difference between OpenGL ES and WebGL is that
instead of creating an ID using ...