# texturing vertices and coordinates

Hello everyone!
I just registered here and start to post in the beginners forum, though I have some experience with opengl programming. But until today i didn’t need any textures in my scenes as simple coloring was enough. Now I’m struggling with Texturing. To start with the problem:

I didnt encounter any problem loading and texturing a single quad or triangle, as there are a lot of tutorials out there explaining many things. Now in my case i want to texture a plane consisting of many quads. The goal will be to transform the quads later on (kind of generating a terrain by lowering and lifting the quad coordinates). As transforming the quads later on, I want the texture to adjust to the new “shape”. So my idea was (and I don’t know if thats a good way to do it) to generate many quads and apply one texture to them stretched all over them.
So here comes a small code snippet:

``````
for(int x=0;x<256;x+=1) {
for(int y=0;y<256;y+=1) {
glTexCoord2d(x/256,y/256); glVertex3f(x,y,0);
glTexCoord2d((x+1)/256,y/256); glVertex3f(x+1,y,0);
glTexCoord2d((x+1)/256,(y+1)/256); glVertex3f(x+1,y+1,0);
glTexCoord2d(x/256,(y+1)/256); glVertex3f(x,y+1,0);
}
}
glEnd();
``````

My Texture is 256x256 pixels and the plane is of size 256x256 as you can see above. So as my texture is set to repeating I think I should use values of zero to one for my texture coordinates. I expected the code above to fill every quad with the corresponding pixel color from the texture. But actually it just doesn’t do anything (besides rendering my plane).

So it’s obvious that I’m doing something wrong - just can’t figure out what it is Just have this feeling to have missed something very obvious

So any help is appreciated!
Thank you very much in advance!

Best,
Caffeine

Using C/C++ ?
You have been hit by integer divide.
/grumpy mode on
AGAIN. Is that something people no longer learn basic programming stuff ???
/grumpy mode off

Try doing x/256.0 to force double floating point division.

Yes using c++.
Yes have been hit by integer divide.
Yes it was something obvious.
Yes I learned basic programming stuff.
No, it doesn’t prevent you from doing old mistakes again