PDA

View Full Version : Multiple textures for objects



Geespot
12-07-2002, 05:28 AM
Hi,

I have an object loaded into memory and the object has more than one texture for it. So some polygons have texture1 assign to it, and some polygons have texture2 assigned to it.

I have wrote up the code that draws the model and determines what polygon needs which texture but im having a problem.

At first, between my glBegin and glEnd, i looped through every polygon and drew it on screen, but it turns out i cant use glBindTexture between glBegin and glEnd to change the texture for the polygon.

The only way ive managed to get this working, is to put glBegin and glEnd just before and after a single polygon to be drawn, instead of the whole lot. Then i can glBindTexture to change the active texture to draw with.

Is that an effient way at doing that?
Is there any ther way i can do this?

Also, is it possible to put the object into a display list? with texture information for each polygon?

Thanks

*Aaron*
12-07-2002, 02:40 PM
Just sort the polygons by texture. Then do this:

Bind the first texture.
glBegin
Draw all polygons that need that texture.
glEnd
Bind the second texture.
glBegin
Draw the rest of the polygons.
glEnd

Sorting geometry by GL state is a pretty common technique.