[android-developers] How to transform not POT images into POT bitmaps to use them on textures for openGL?
Im doing my first steps on OpenGL-ES. Atm i can load Power of Two
(POT) textures on a square polygon that i can rotate and zoom on the
screen. If i try to load a non POT png, then, the texture appears
white.
What I need to do some trick to transform non POT textures into POT
bitmaps to fill the texture of my square polygon. How can i transform
them into POT bitmaps?
This is the actual code i have to load textures:
FROM ASSETS DIR:
String imagePath = "radiocd5.png";
AssetManager mngr = context.getAssets();
// Create an input stream to read from the asset folder
InputStream is=null;
try {
is = mngr.open(imagePath);
} catch (IOException e1) { e1.printStackTrace(); }
//Get the texture from the Android resource directory
InputStream is =
context.getResources().openRawResource(R.drawable.radiocd5);
Bitmap bitmap = BitmapFactory.decodeStream(is);
//Use the Android GLUtils to specify a two-dimensional texture
image from our bitmap
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
FROM RES/DRAWABLE:
//Get the texture from the Android resource directory
InputStream is =
context.getResources().openRawResource(R.drawable.radiocd5);
Bitmap bitmap = BitmapFactory.decodeStream(is);
//Use the Android GLUtils to specify a two-dimensional texture
image from our bitmap
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home