Multiple textures

Started by
3 comments, last by lc_overlord 18 years ago
Hi I've been doing lesson 6 and want to apply multiple textures to an object, however I am finding it tricky. I have an object and have 3 texture maps to apply to it. I want to make sure I am heading in the right direction to begin with. Is this code correct? int textureID[] = new int[3]; gl.glGenTextures(3, textureID); gl.glBindTexture(GL.GL_TEXTURE_2D, textureID[0]); gl.glBindTexture(GL.GL_TEXTURE_2D, textureID[1]); gl.glBindTexture(GL.GL_TEXTURE_2D, textureID[2]); thanks
Advertisement
You can't just bind multiple textures one after another, in this case only the textureID[2] texture will be rendered.
you need to use the multitexture functions.
Thanks for your reply.

My object is a head made up of
1) face
2) inner mouth
3) rest of head

It is an object exported from FaceGen.

I have 3 images to apply as textures to the different parts. I am not overlaying textures or anything so I don't think I need to use multitexture functions do I?

I could get around this by spliting the object into 3, but I think this would be a bit silly.

So at the minute I am reading in all the vertices (inc tex coords) and applying one texture map to the head object, which obviously uses the same texture map for the 3parts which make up the head.

If I stored the texture data in 3 different arrays, how could I apply 3 textures to them?

Thanks

Hope this is clear enough, if not please let me know.

You will have to split the model into 3 parts, one way or another, since you need to know which verticles corespond to which texture. Then you would:

glBindTexture(GL_TEXTURE_2D, textureID[0]);//reder the verticles that use texture 0glBindTexture(GL_TEXTURE_2D, textureID[1]);//render the verticle that use texture 1//etc.


Alternatively, you could also make the model use a single texture, that is a combination of the 3 you use now.
it's now a bit more clear to me.
I can see now that you don't need multitexture for this.
But you do however need to know wich polygons needs wich texture, and if you have to split it up in 3 different objects then so be it.
Personally i would merge all the teturemaps into one big one and then adjust the uv map of the head to that.

This topic is closed to new replies.

Advertisement