Need a little help with texturing..

Started by
7 comments, last by B0necrack3R1 19 years, 1 month ago
Hello all.. I need some very basic help with texture mapping! As I follow by the NeHe tutorials of applying a texture on a quad for example, I meet some disabilities like using only 256*256 bmp textures, the textures stretch on all of the quad..(what if I want to apllly a Parket Floor texture?)... 1)I want to apply larger textures 2)I want to texture a floor by a lot of a 256*256 parket textures.. Hope you understood my problems! Waiting for answer! thnx
Advertisement
If the size of the quad is larger than the size of the image then it would defenelty strech it out. A little code would be quit help to know exactly what you are doing and accordingly give suggestions.

If you want to repeat the same texture on the entire quad, better the break the quad into smaller quads that match the size of the texture.

(or)

Create a tiled image so that it is the size of the original quad. Each tile being the same 256x256 image.

Hope this helps!
What does it mean tiled image?

btw here's the code:

<code>AUX_RGBImageRec *wall[1];
memset(t,0,sizeof(void *)*1);
if (wall[1]=LoadBMP("gfx/wall.bmp"))
{
Status=TRUE;
glGenTextures(1, &texture[2]); // Create The Texture

// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[2]);
// Generate The Texture
glTexImage2D(GL_TEXTURE_2D, 0, 3, wall[1]->sizeX, wall[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, wall[1]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
}
if (wall[1]) // If Texture Exists
{
if (wall[1]->data) // If Texture Image Exists
{
free(wall[1]->data); // Free The Texture Image Memory
}

free(wall[1]); // Free The Image Structure
}</code>

in the Render() scene I use: glBindTexture(GL_TEXTURE_2D, texture[1]);


hope it'll help!
what about the wrapping modes along the S & T direction ?
What does it mean ? I ma sorry but i didnt understand any termin..
I a very beginner so I dont know any techniqes..
Please explain and an example of code will be realy great!
The S and T dimensionx talks about are axes in texture space. You know you specify texture coordinates with glTextureCoord...(or whatever)? The x and y in texture space are often referred to as S and T or U and V in computer graphics literature.

The wrapping he refers to is set with glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) and this controls how texture coordinates outside of the 0.0-1.0 range are handled - so for example you can repeat the smae texture over and over again on one surface.

To answer your original questions: you should be able to load any 'power of 2' sized texture with the nehe code - 32x32, 64x64, 128x128, 512x512 and so on. The is an extension to GL allowing non power of 2 textures, but I'd avoid extensions for the time being if I were you - just until you understand the basics a bit better.

Texturing a floor with lots of textures: well, theres 2 main ways to go here. You can either split the floor up into lots of pieces and give each one a different texture, or you can create a texture that has several of the parket textures in it and use that. Worth bearing in mind is the scales you are likely to see the textures at - theres no point in giving each tile a unique 256x256 texture if they will only ever fill 100x100 pixels on screen for example.

hope that's some help.
[size="1"]
thnx man! thats realy helped!
But how can I split a floor and give each other its texture?
Well, you know how to make one big quad right? so the little ones are just like that, but smaller and with different textures. Try drawing on some graph paper to work out how to tesselate your quad/s (hint: quads can always be split into 4 smaller quads, and they can be split into 4 smaller quads, etc).
[size="1"]
yeah, understood
but then I have to create a lot of quads.. (shitty work)

This topic is closed to new replies.

Advertisement