Mechazawa
Mechazawa

Reputation: 83

XNA 2D textures not rendering properly

For some reason my textures look strange when I try to render them. XNA grabs the bottom row of pixels and stretches them upwards.

Real image: The original image

What is rendered: The rendered image

I use this function to render my image

// NOTE: c is a instance of my control class that contains textures etc.

Rectangle rect = c.Texture.Bounds;
rect.Offset(Convert.ToInt16(c.position.X), Convert.ToInt16(c.position.Y));

spriteBatch.Draw(c.Texture, c.position, rect, Color.White, 0F, new Vector2(), 1F, SpriteEffects.None, 1F);

Can someone please tell me what I'm doing wrong?

Thanks in advance.

Upvotes: 0

Views: 209

Answers (1)

Mario
Mario

Reputation: 36537

Looks like you're somehow screwing up texture coordinates (i.e. the whole sprite using the lower border of the texture while also screwing up the horizontal scaling. What's your intention for the call to rect.Offset()? The rectangle describes what part of the texture to draw as a sprite, not where to draw that sprite. If that isn't the reason or solution, we need more information, e.g. what v.X or v.Y are.

Upvotes: 1

Related Questions