开发者

Android OpenGL 1.0 different texture for each face of the cube with texture atlas

开发者 https://www.devze.com 2023-04-13 10:07 出处:网络
I have a cube, I can assign for it one texture, but I would like to assign different texture for each face. I have a 512x512 texture atlas, with four tiles, each 256x256. I use the NeHe ports, so for

I have a cube, I can assign for it one texture, but I would like to assign different texture for each face. I have a 512x512 texture atlas, with four tiles, each 256x256. I use the NeHe ports, so for one texture the load is:

public void loadGLTexture(GL10 gl, Context context) {

InputStream is = context.getResources().openRawResource(R.drawable.test);
Bitmap bitmap = null;
try {
    bitmap = BitmapFactory.decodeStream(is);
} finally {
    try {
        is.close();
        is = null开发者_高级运维;
    } catch (IOException e) {
    }
}

I have tried to find solutions, but I was not able to find with texture atlas, only with loading as much texture as I want to use, then assign them to the faces, but because of the performance it's not really good for me. I hope someone can help me! Thanks in advance!

PS: Which is faster, creating a cube with the coordinates writing in the code, or loading a cube model from an .obj file?

0

精彩评论

暂无评论...
验证码 换一张
取 消