[XNA] Drawing transformed vertices

Started by
2 comments, last by remigius 13 years, 11 months ago
Hello! Im kinda new to XNA (my first project). I used DirectX unmanaged in C++ before and am trying learn something new. A lot works already good but now im having a problem. I want to draw my user interface. I first just drawn it using a SpriteBatch and Texture2D. But there is a problem: My textures are optimized so that different elements of the element are in the same texture. So i need to specify texture coordinates for the points. Normally i would do that using the D3DFVF_XYZRHW to enter already transformed vertices to the vertexbuffer. So my question is basically: How do i draw vertices/textures on the manner i draw vertices in DirectX with D3DFVF_XYZRHW? Greetings Plerion
Advertisement
With SpriteBatch you can specify a source rectangle, which it will use to use to determine the texture coordinates for the quad.
Hey!

Thanks i already tried that but i seems to have no effect:
[sourcecode]            int yy = (int)(0.04f * textureUp.Texture.Height);            int yY = (int)(0.68f * textureUp.Texture.Height);            int xx = (int)(0.015f * textureUp.Texture.Width);            int xX = (int)(0.62f * textureUp.Texture.Width);            rect = new Rectangle(xx, yy, xX - xx, yY - yy);[/sourcecode]The values are the texturecoordinates i use in DirectX for the texture. If i set that rectangle as source to Draw the texture it looks exactly the same as if i dont set the rectangle.I do scale the texture to specified parameters. Do i need to specify the rectanble to that?GreetingsPlerion

Could you post your entire drawing code including spriteBatch.Draw? That way we can see if you're passing in the parameters correctly and what you mean by scaling the texture exactly.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement