Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping Multiple Textures to a Cube's faces in Android

I have just began opengl programming in android and i am fairly new to opengl as well. I've been using nehe's opengl tutorials as well as insanitydesign's android ports. I successfully managed to create a cube with a single texture mapped to all its 6 faces. I even mapped multiple textures to different faces of the cube. But the way I did it was to create 6 faces seperately, have 6 seperate index and texture buffers and then using glBindTexture() with the selected texture for each face and then calling glDrawElements. Isn't there an efficient way around this. Should i use a cube map texture instead of a GL_TEXTURE_2D?

Any suggestions would be appreciated? Thanks

like image 940
chaitanya Avatar asked Aug 23 '26 23:08

chaitanya


1 Answers

A very efficient way is using a texture atlas, and adjusting texture coordinates of each cube face to match coordinates in the atlas.

like image 67
Dr. Snoopy Avatar answered Aug 25 '26 13:08

Dr. Snoopy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!