Skip to main content
gamedev.net
🔒 Locked

Texture coordinates

Started by sefSale Jul 31, 2006 at 4:36 PM 3 replies 1k views
Original Post
sefSale
sefSale
Hi. I'm having a problem with placing textures on textured quads. I load the texture I want to use, program compiles successfully, but the texture on the screen is deformed and some colors are missing. I'm using the custom vertex format: struct CUSTOMVERTEX { float x,y,z,u,v; }; I understand that u and v are texture coordinates and usually have the value of 0.0f or 1.0f. They seem to have effect on how the texture looks on screen, but I still can't get it right. I also tried to copy values from the tutorial I found on GD, but it didn't work. Any ideas?
treeway
treeway
Hi

UV coordinates are realy easy to understand once you get them. Essentially the 0 to 1 is the position on the 2d texture where the vertex is. 0,0 is the bottom left of the texture bitmap and 1,1 is the top right.
Calin
Calin
You have to set up UV coordiates for each vertex correctly. Post the code where you fill-in UV coordinates.
My project`s facebook page is “DreamLand Page”
sefSale
sefSale
OK, here goes. I forgot to mention there is another variable in struct, rhw.

CUSTOMVERTEX vertex[] {
//x______y______z___rhw__u____v
{ 100.0f, 100.0f, 0.5f, 1.0f, 0.0f, 0.0f },
{ 164.0f, 100.0f, 0.5f, 1.0f, 1.0f, 0.0f },
{ 164.0f, 164.0f, 0.5f, 1.0f, 1.0f, 1.0f },
{ 100.0f, 164.0f, 0.5f, 1.0f, 0.0f, 1.0f },
}

And the primitive is drawn as a D3DPT_TRIANGLESTRIP.
treeway
treeway
seems alright to me - whats does it actually look like? can you post a screenshot?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.