more than one texture with glDraw* ?

Started by
4 comments, last by saian 22 years ago
hello, i''ve a problem. i draw a model from 3DS with glDrawElement or glDrawRangeElement. this model has many textures and materials. i put all the datas into a display list. this is how i do glNewList for( int gr=0; gr< groupe_nb; gr++){ glPushMatrix(); glPushClientAttrib( color, texture, lighting); glMaterialfv... glBindTexture( gr); glDrawElement( GL_TRIANGLES, number, GL_UNSIGNED_INT, &index[...]); // i don''t remember all, sorry glPopClientAttrib(); glPopMatrix(); } glEndList(); all my model is drawn correctly, but i only have one texture for all !! does anyone know why ? thanx in advance
Educate the masses ! it's one behavior !
Advertisement
Use glDrawElements for each mesh in your model, a mesh being a series of triangles with one (or 2 if you use multitexturing) texture/material.

------------
- outRider -
that''s what i do (as I think in all cases).
But only one texture is drawn.

normally, if you specify a texture for a part of an array that you draw, and do so on for each time the texture change, does that let opengl change it normally ?

ie:

for all meshes do
glBindTexture( texid)
glDrawRangeElement...
end for

this must change the texture, mustn''t it ?

thanx

Educate the masses ! it's one behavior !
With multitexturing you first do glBind with the first texture unit active, then glBind again the new texture with the second texture unit active. Then glDrawElements.

Sorry, I just reread your problem. If you call glBind for each new textured set of triangles and you only get the first texture you glBinded then you're not passing a proper TexID to glBind. Either your texture was not properly created or something else went wrong.

------------
- outRider -

[edited by - outRider on March 27, 2002 11:06:33 PM]
what about an interleaved array
store the vertex and uv texturing coordinates in one array and render it
http://www.8ung.at/basiror/theironcross.html
thanx for replies.

that was my fault, i was making something absurd. now it works !
Educate the masses ! it's one behavior !

This topic is closed to new replies.

Advertisement