microsoft / Win2D

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for the Windows Universal Platform (UWP). It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.
http://microsoft.github.io/Win2D
Other
1.82k stars 287 forks source link

Spritebatch Transformation Matrix #604

Closed SeriousGeorge closed 6 years ago

SeriousGeorge commented 6 years ago

Hello there,

I was wondering if there is somewhere anything like the XNAs Spritebatch matrix and if not if there are any future plans to add it?

XNA Reference: https://msdn.microsoft.com/en-us/library/ff433701(v=xnagamestudio.40).aspx

Background: I'm wokring on a tile- and spritesheet based game with levelscrolling and slight cameramovement. There are object that should stick to background and others that should not, also those having a parallax effect depending on the camera movement.

Off course I can calculate each of it manually but it would be a great help to let this untouched and let this be done with a spritebatch-wide transformation (optional so to speak).

Best regards

shawnhar commented 6 years ago

https://microsoft.github.io/Win2D/html/P_Microsoft_Graphics_Canvas_CanvasDrawingSession_Transform.htm should do the trick.

SeriousGeorge commented 6 years ago

It did the trick indeed. Great. Thanks Shawn.

Just a quick followup question... we can't alter the DrawingSession Transform whilst being in a using of a spritebatch ( so let's say, for these sprites in the batch, take this ds.transform and for other sprites in the same batch, take the other ds.transform (or alter it))?

I just seperated some spritebatches and applied the required DrawingSessionTransform beforehand - so that's working fine anyway.

Best regards

shawnhar commented 6 years ago

we can't alter the DrawingSession Transform whilst being in a using of a spritebatch

Correct. The whole point of a batch of sprites is to gain efficiency from drawing them all in one go using the same set of state.