Skip to main content
gamedev.net
🔒 Locked

Texture UV problems

Started by Laroche 7 replies 500+ views
Original Post
Laroche
Laroche
Whats wrong with these Texture UV''s? I think I may have gotten them backwords. It is for a quad made up of 2 triangles in clockwise order:
  
	Quad[0].Position.x = 0;
	Quad[0].Position.y = Size;
	Quad[0].TextureUV.x = 0;
	Quad[0].TextureUV.y = 1.0f;

	Quad[1].Position.x = 0;
	Quad[1].Position.y = 0;
	Quad[1].TextureUV.x = 0;
	Quad[1].TextureUV.y = 0;

	Quad[2].Position.x = Size;
	Quad[2].Position.y = Size;
	Quad[2].TextureUV.x = 1.0f;
	Quad[2].TextureUV.y = 1.0f;

	Quad[3].Position.x = Size;
	Quad[3].Position.y = Size;
	Quad[3].TextureUV.x = 1.0f;
	Quad[3].TextureUV.y = 1.0f;

	Quad[4].Position.x = 0;
	Quad[4].Position.y = 0;
	Quad[4].TextureUV.x = 0;
	Quad[4].TextureUV.y = 0;

	Quad[5].Position.x = Size;
	Quad[5].Position.y = 0;
	Quad[5].TextureUV.x = 1.0f;
	Quad[5].TextureUV.y = 0;
  
The texture is loading find and setting fine but all I see it black on the quad when it gets rendered. These are pre-transformed verts, and all the colors are pure white (renders as a white square with no texture).
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
aker_jus
aker_jus
Why dont you try to use this for creating your code?
pseudocode:
x[0] = x1;
y[0] = y1;
x[1] = x2;
y[1] = y1;
x[2] = x1;
y[2] = y2;
x[3] = x2;
y[3] = y2;

And render them as strips, I dont have time now and this is a very quick thinking of me, so I might be wrong. Play with your values.
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
Laroche
Laroche
Im using triangle lists in my program right now, and I'm not interested in switching to strips because of the way everything is set up to render in batches. I've done it that way before on a test program, however.

Ok, I've been fooling around the UV coords for a while now and still nothing shows up except a black quad. I've checked my Loading function and its working fine, SetTexture is working fine, what else could it be?

[edited by - laroche on January 10, 2003 4:45:24 PM]
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Laroche
Laroche
Texture loading code:


  
void CTexture::Load(char *Filename)
{
D3DXCreateTextureFromFileEx(pd3ddev, Filename, 0, 0, 0, 0,
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT,
D3DX_DEFAULT , 0, NULL, NULL, &pTexture);
}


And.. that''s it. I call SetTexture after it every frame, and then render. My normally white quad shows up as a black quad instead.
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Laroche
Laroche
noone knows?
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Laroche
Laroche
hmmm nothing at all... its really weird
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Laroche
Laroche
sorry if i seem pushy to bump, but I just cant figure this out, and it's such a silly problem i don't know why it isn't working. I've put error checking everywhere, and everything seems fine. The weird thing is that my quad apparently is drawing only the most top-left pixel in the texture. Why would it do that?

EDIT: I FIXED IT!!! I can't belive how stupid my error was, i was forgetting to copy my verts uv coordinates into the vertex buffer. How could I be so stupid? Anyway, thanks for the help anyway

[edited by - laroche on January 14, 2003 10:33:48 PM]
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content

Topic Locked

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

Sign in to reply to this topic.