Sign in to follow this  
Plerion

[XNA] Drawing transformed vertices

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Greetings
Plerion

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this