01-19-2002, 02:51 PM
If I specify a texture coord of say;
Is that the top or the bottom of the texture.
Currently I assume it's the bottom, but thats because I dont invert my TGA's when I load them. Is the origin of OpenGL's textures the top left, and not the bottom left as I've been using?
01-19-2002, 03:09 PM
As I recall it's lower-left.
01-19-2002, 03:22 PM
Depends on what you've done to the texture matrix http://www.opengl.org/discussion_boards/ubb/wink.gif
01-19-2002, 04:03 PM
For me to remember the s and t coords i just think of the s as like the x axis and the t like the y. And i know that the tex coords go from 0 to 1 so if s = 0 and t = 1 then that is the top left for example. http://www.opengl.org/discussion_boards/ubb/smile.gif
01-20-2002, 03:26 AM
I'm not convinced it's lower left.
IF I make a 16x16 RGB texture like this.
//Blacken out all texture.
memset(data, 0, 16*16*3);
//Make top half white.
memset(data, 255, 16*8*3);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
So we have a texture, with the top half white, bottom half black. The top of the image, is the low address in memory. i.e. &data.
Now we render a quad like this. (Texture matrix is identity)
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glVertex3f(-1.0f, 1.0f, 0.0f);
As you can see, we start with the lower left coordinate and go round anti-clockwise.
Now, the texture coordinate specified at the bottom of the quad, (where Y = -1.0f) is 0.
Now if the origin of the texture in OpenGL is the lower left corner, this is black in the texture. However, the quad is rendered with white at the bottom and black at the top.
This suggests to me that OpenGL's texture origin is the top of the texture. i.e. a texcoord of 0 in T, would be the top of the image. (The low address)
Or am I completely mis-understanding something here?!?! http://www.opengl.org/discussion_boards/ubb/smile.gif
01-20-2002, 03:41 AM
Nevermind! I found the reason!
The first element corresponds to the lower left corner of the texture image. Subsequent elements progress left-to-right through the remaining texels in the lowest row of the texture image, and then in successively higher rows of the texture image. The final element corresponds to the upper right corner of the texture image.
from http://www.hp.com/workstations/support/d...TexImage2D.html (http://www.hp.com/workstations/support/documentation/manuals/user_guides/graphics/opengl/Reference/glTexImage2D.html)
Seems a bit crap that to me. Why not from the top and work down? Much simpler.. bah...
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.