Overview: I could not get the texture to show on the Droid Razr. But it would display on the Eclipse Emulator. The following code changes allowed me to display it on the Droid Razr.
Droid Razr: Android version 2.3.6 Eclipse Emulator: Android version 2.3.3 The following code is in OpenGL.GLCube.loadTexture.
Code#1 (New code not in the original) — OpenGL texture works on the Droid Razr if I use:
InputStream is = context.getResources().openRawResource(resource); Bitmap bmp = BitmapFactory.decodeStream(is);
Code#2 (Original from the book) — The texture fails to display if I use:
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), resource);
Notes: Code#1 required adding “import java.io.InputStream;” to GLCube.java The ‘resource’ (2130837504) converted to hex and viewed in R.drawable matches ‘android’ I call .getWidth, and .getHeight and output resource and the size results on LogCat: The android bitmap is 128x128 When I read it with Code#1 I get 128x128 when I read it with Code#2 I get 192x192 Both Code#1 and Code#2 work on the emulator.
Success (The Texture is displayed): Droid Razr: 04-13 09:52:09.189: D/GLCube(14937): Code#1 resource:2130837504 size(128x128) Emulator: 04-13 15:56:20.731: D/GLCube(334): Code#1 resource:2130837504 size(128x128) 04-13 15:58:16.841: D/GLCube(369): Code#2 resource:2130837504 size(192x192)
Failure on Droid Razr (The Cube is White with no Texture): 04-13 10:01:14.312: D/GLCube(15210): Code#2 resource:2130837504 size(192x192)
The following error message on LogCat probably means something – it occurs when running the Droid Razr not on the emulator: It shows up one line before my Log message that shows the bitmap size and shows up with both Code#1 and Code#2. 04-13 10:01:14.226: I/IMGSRV(15210): IMGeglCreateWindowSurface:2974 Warning: using custom HW EGL config with EGL_DEPTH_SIZE=16 When I googled the error message the only hits I got were people reporting the same error. Thank you.