I am currently drawing objects and it works perfectly, when i make x bigger the objects go right and when i make x lower they go left perfect, but when i make y bigger the object goes down and when i make y lower it goes up, i am having problems discovering the part of the code that is making y inverted.
This is the code that i use to initialize:
static public BitmapManager bitmapManager; static public Maze CurrentScene; static public Sound.Sound Sound; static public InputManager Input; static public Renderer renderer; static public Point WindowPosition; static public Size WindowSize; static public GameTime gameTime; static public float DeltaTime; static public Hierarchy hierarchy; static internal RenderForm form; static private Device device; static private SwapChain swapChain; static private Stopwatch stopwatch; static private Thread UpdateThread; static public void Initialize(Size size) { GC.Collect(); form = new RenderForm(); form.StartPosition = FormStartPosition.CenterScreen; form.ClientSize = new System.Drawing.Size((int)size.Width, (int)size.Height); form.MaximizeBox = false; form.FormBorderStyle = FormBorderStyle.FixedSingle; form.FormClosed += form_FormClosed; SwapChainDescription SCDescription = new SwapChainDescription() { BufferCount = 1, ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm), IsWindowed = true, OutputHandle = form.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, SCDescription, out device, out swapChain); Factory2D d2dFactory = new Factory2D(); Factory factory = swapChain.GetParent<Factory>(); factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll); Texture2D backBuffer = Texture2D.FromSwapChain<SharpDX.Direct3D11.Texture2D>(swapChain, 0); RenderTargetView RenderView = new RenderTargetView(device, backBuffer); Surface surface = backBuffer.QueryInterface<Surface>(); RenderTarget RenderTarget2D = new RenderTarget(d2dFactory, surface, new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied))); form.SizeChanged += Form_SizeChanged; form.GotFocus += Form_GetFocus; form.LostFocus += Form_LostFocus; form.Move += Form_Move; WindowPosition = new Point(form.Location.X + SystemInformation.FixedFrameBorderSize.Width + SystemInformation.DragSize.Width, form.Location.Y + SystemInformation.FixedFrameBorderSize.Height + SystemInformation.CaptionHeight + SystemInformation.DragSize.Height); WindowSize = size; renderer = new Renderer(RenderTarget2D); Input = new InputManager(); Sound = new Sound.Sound(); bitmapManager = new BitmapManager(RenderTarget2D); hierarchy = new Hierarchy(); gameTime = new GameTime(); stopwatch = new Stopwatch(); stopwatch.Start(); } and this is the code i use to render:
RawMatrix3x2 CurrentTransform = renderTarget.Transform; Sprite NewSprite = Component as Sprite; Bitmap Texture = Game.bitmapManager.GetTexture(NewSprite.texture.TexturePath); RawRectangleF PositionRectangle = new Rectangle(new Point(0, 0), 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(); Vector2 NewScale = (Vector2)Gameobject.transform.Scale; Matrix3x2 Translation = Matrix3x2.Translation((Vector2)Gameobject.transform.Position); Matrix3x2 Rotation = Matrix3x2.Rotation(Gameobject.transform.Rotation.X); Matrix3x2 Scale = Matrix3x2.Scaling((Vector2)Gameobject.transform.Scale); renderTarget.Transform = (Translation * Rotation * Scale).ToRawMatrix3x2(); renderTarget.DrawBitmap(Texture, PositionRectangle, Transparency, BitmapInterpolationMode.NearestNeighbor, ImageRectangle); renderTarget.Transform = CurrentTransform; If you need anything else please warn me