View Full Version : Texture coord problem...
M109uk
22-04-2005, 02:12 PM
Hi all,
I have yet another problem...
I have a simple quad, and i want to bind a texture to it.. nice and simple..
Textures.Bind('Path1');
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(0, 0.1, 128);
glTexCoord2f(1, 0);
glVertex3f(64, 0.1, 128);
glTexCoord2f(1, 1);
glVertex3f(64, 0.1, 192);
glTexCoord2f(0, 1);
glVertex3f(0, 0.1, 192);
glEnd;
how ever instead of the texture turning out like:
http://freepgs.com/m109uk/HRightStop.bmp
it turns out like:
http://freepgs.com/m109uk/ce_quadtcprob.jpg
Iv messed around with the texture coords and the only result that i get is with:
0, 0
1, 0
0, 1
-1, 1
But this messes the edges of my textures up..
Im not sure if its the way OpenGL draws quads, but it seems to render as a 2 triangles..
Is there any OpenGL function that will cause this kinda thing??
JSoftware
22-04-2005, 03:56 PM
try to load identity matrix into gl_texture matrix..
i've no ide if that may be the problem but the texture matrix can screw somethings up.
the code shows just fine when i fire it up in my engine
EDIT: if this doesn't solve it just switch the two texcoords in the middle so it becomes:
0,0
1,1
1,0
0,1
M109uk
22-04-2005, 05:22 PM
Ok, i think i have done it right:
glMatrixMode(GL_TEXTURE);
glLoadIdentity;
glMatrixMode(GL_MODELVIEW);
If so then it has no effect :s
I tried your tex coords, but that doesnt solve it either, it turns out worse :(
JSoftware
22-04-2005, 05:43 PM
that's pretty weird-- :?
have you tried:
0,0
1,0
0,1
1,1
if you're not able to get it right when altering the texcoords like this then i would bet that your bmp laoder code is the problem
M109uk
22-04-2005, 06:12 PM
I have no idea why its happening, im not accessing the texture matrix in any way, im creating new textures on the fly when i generate my terrain..
I am positive its not my texture loading, i have saved that particular texture in BMP,JPG,PNG and TGA and the same problem occours.. and i dont have the same problem in any of my other applications that use the textures.. I also have a function built in to extract a TBitmap from the texture (using the loaded data) and that looks right too...
I tried those coords too, and i had a similar effect as before...
I have a little maths involved when calculating where the tiles are in the terrain...
For i := 0 to 256-1 Do
For j := 0 To 256-1 Do
Begin
v1 := Vertex3f((64*i), 0, (64*j));
v2 := Vertex3f((64*i)+64, 0, (64*j));
v3 := Vertex3f((64*i)+64, 0, (64*j)+64);
v4 := Vertex3f((64*i), 0, (64*j)+64);
// Bind texture
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3fv(@v1);
glTexCoord2f(1, 0);
glVertex3fv(@v1);
glTexCoord2f(1, 1);
glVertex3fv(@v3);
glTexCoord2f(0, 1);
glVertex3fv(@v4);
glEnd;
I am fairly sure this gives the correct coords, and i am assuming that it shouldnt effect the texture coords?!?
Maybe i have the maths the wrong way around??
M109uk
22-04-2005, 08:44 PM
Ok i have solved it, was a really stupid mistake on my part..
It was the texture file itself it was supposed to be 128x128 but it was actually 119x119 :roll:
Thanx for your help :D
JSoftware
22-04-2005, 08:46 PM
hehe no problem. i've done precisely the same thing some time ago but i just couldn't remember what i did to solve it! :D
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.