sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.69k stars 641 forks source link

Direct3D11 How can i rotate a image? #986

Closed MazeThePlayer closed 6 years ago

MazeThePlayer commented 6 years ago

Hello could someone please tell me where sprite in Direct3D11? i have am currently rendering an image, i am can move it but i cant figure how i can rotate it and i cant find a solution anywhere. This is the code i am using: Sprite NewSprite = Component as Sprite; Bitmap Texture = Game.bitmapManager.GetTexture(NewSprite.texture.TexturePath); RawRectangleF PositionRectangle = new Rectangle(new Point(gameObject.transform.Position), new Size(NewSprite.texture.TextureSize * Zoom)).ToRawRectangleF(); float Transparency = NewSprite.Transparency; RawRectangleF ImageRectangle = new Rectangle(new Point(0,0), new Size(NewSprite.texture.TextureSize * Zoom)).ToRawRectangleF(); renderTarget.DrawBitmap(Texture, PositionRectangle, Transparency,BitmapInterpolationMode.NearestNeighbor, ImageRectangle); Sprite, Rectangle, Point and Size custom classes i made

Skyppid commented 6 years ago

Since you're using Sprite and stuff I assume you're using Direct2D to draw your image. If so, then you should check out this MSDN documentation. Basically you have to apply the transformation in form of a Matrix before you render your image.

MazeThePlayer commented 6 years ago

@Skyppid it is now working thank-you the documentation was very helpful.