PDA

View Full Version : Texture Problem



Booba
04-23-2002, 07:19 AM
I want to know how can I do to apply different textures to a same object.
Because I load a map in ASE Format and I want to have a texture for the wall and

a another texture for the ground and a another for the sky etc...

I have done this :

const
nb_texture = 4;
arr_texture : array[0..NB_TEXTURE-1] of string =
(
'texture1.bmp', //id 1
'texture2.bmp', //id 2
'texture3.bmp', //id 3
'texture4.bmp', //id 4
);

a procedure which creates the texture with this array (which works correctly =)

and for example to apply the "texture2.bmp" to a cube :
BEGIN

glBindTexture( GL_TEXTURE_2D, 2);

glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0,1.0); glVertex3f(-150,+25,0);
glTexCoord2f(0.0,0.0); glVertex3f(-150,-25,0);
glTexCoord2f(1.0,1.0); glVertex3f(+150,+25,0);
glTexCoord2f(1.0,0.0); glVertex3f(+150,-25,0);
glEnd;

END

It's works perfectly to apply only one texture to an object, but what can I do to

apply different textures to different parts of an object.

With a map in ASE I want to apply different textures to the different *GEOMOBJECT

Thank you very much.

Azdo
04-23-2002, 08:07 AM
Originally posted by Booba:
I want to know how can I do to apply different textures to a same object.

I think you refer to change the texture you are using. This is made with

glBindTexture(GL_TEXTURE2D,number);

where 'number' is the ID of the texture you got by calling glGenTextures. You shouldn't type that ID directly in the function call, as you are doing in your code. You'd better use the variable you have passed to glGenTextures.

Azdo
04-24-2002, 09:15 AM
Texture coordinates are wrong. Try to flip your "u" coords to "v" and viceversa.



[This message has been edited by Azdo (edited 04-24-2002).]

Bob
04-24-2002, 11:23 AM
You shouldn't type that ID directly in the function call, as you are doing in your code.

There's nothing wrong with using your own texture IDs. glGenTextures always gives you an unused ID, but if you can make this guarantee yourself, then there's nothing wrong with that.

glGenTextures does nothing but returning a number to an unused texture ID, it does not "prepare" the use of the texture or anything like that, so you can safely use your own numbers.