Win2D app building samples


Shortly before releasing Win2D version 1, the team downed tools and spent a week writing our own apps to validate Win2D end-to-end.  For better or worse, the results are available on github...

 

Harrydactyl: Cooper's silly game with dinosaurs

https://github.com/coopp/Harry

Fly a Pterodactyl named Harry across a world filled with dinosaurs and collect as many coins as you can! This game uses a simple FlappyBird-like flight mechanic with a point based coin pickup system.

Interesting features:

  • Shared projects and code between Windows 8.1, Windows Phone 8.1 and Windows 10
  • Game state management
  • Parallax scrolling backgrounds
  • Animated sprites
  • Day to night transitioning sky

 

 

 

Shawn's Terrific Universal App for photogRaph Tweaking

https://github.com/shawnhar/stuart

This is a simple, powerful, and contrivedly acronymed Windows 10 photo editing app.

Features:

  • Use a rich set of image effects to tweak your photos
  • Apply effects to the whole image or just selected parts of it
  • Feather selected regions for smooth transitions

 

 

 

Age and Gender Guesser

https://github.com/austinkinross/age-gender-guesser

Use this to find out somebody's age and gender! Simply take a photograph using your Windows 10 device's camera, and for each person in the photograph the app will guess their age and gender and draw it above their face. It is very similar to www.how-old.net.

This is a Windows 10 application written for the Universal Windows Platform. It uses the Project Oxford API for face recognition and age/gender guessing. It uses Win2D for its graphics rendering. It makes use of the new camera video effects added to Windows 10, and the interop available between the camera and Win2D.

 

 

 

Rubik’s Cube Solver (work-in-progress)

https://github.com/austinkinross/rubiks-cube-solver

Let this app solve a Rubik’s Cube for you! Hold it up to your device’s camera, and this app will analyze the colors and solve a virtual model of it on your screen.

The app is work-in-progress. Win2D and the new camera effects in Windows 10 were used to find the Rubik’s Cube in the camera feed (in realtime) and detect the colors.

 

 

 

SvgWin2D (work-in-progress)

https://github.com/damyanp/SvgWin2D

SvgWin2D is a prototype of an SVG renderer for Win2D.  It’s very much a work in progress, but it includes an app for comparing reference images from the SVG Test Suite with images produced by SvgWin2D as well as a simple SVG viewer.  It might work for SVG images you want to draw.  It probably doesn’t.  But, if you’re willing to file issues with sample SVG files that don’t load correctly then that would be awesome!


Comments (21)

  1. Anastasios-Antonios Toulkeridis says:

    THANK YOU!  Boy I love Win2D

  2. Anastasios-Antonios Toulkeridis says:

    why the hell did it have to be cpp ?  ūüôĀ

  3. We intentionally made a mixture of native and .NET apps, because Win2D supports both so properly testing it requires using both.

  4. Vitor António says:

    Guys a question, with Win2D can I try to render specific UI controls on my app? I mean can I do something like RenderTargetBitmap but using win2d for better performance results? I'm trying to figure it out but I'm a little stuck.

    Thanks!

  5. Vitor, I don't understand the question.  Are you asking how to capture the appearance of existing XAML controls for processing with WIn2D, or how to create new controls that render themselves using Win2D?

  6. Vitor António says:

    Hey Shawn, I'm asking about capturing the appearance yes. For example I have an existing regular XAML canvas (not Win2D), that contains other elements inside (some rectangles, images), and I want to render the canvas and its content into a single bitmap (the same effect like RenderTargetBitmap), but using Win2D.

    Thanks!

  7. Got it.  There's no direct way to capture arbitrary XAML content into Win2D.  RenderTargetBitmap is the only way to read back XAML rendering results, but that's' not a particularly efficient operation.

    You could use Win2D drawing calls to render equivalent rectangles, images, etc, instead of the XAML canvas.

  8. Vitor António says:

    Ah ok, so iterative through the child elements of the control to render and draw then in a Win2D canvas to later render everything. I'm even with the idea of having this mechanism to work in the background so when adding in the normal canvas it automatically adds to the Win2D canvas.

    Thanks for the help Shawn! Great job with Win2D!

  9. That would work, but for anything other than very complex shapes it's going to be complex to get the same rendering from Win2D and XAML.  Are you sure you really need to take on this complexity?  I'd question whether these shapes need to be represented in XAML at all – is it an option to move their rendering entirely across to Win2D?

  10. Vitor António says:

    My scenario is very specific and complex to be honest. It's an App that contains a lot of functionality, so carrying everything to work with the Win2D canvas will be quite some work. But me and my team will consider definitely using Win2D.

    Thanks for the help Shawn! It's good to see that you guys care so much about our feedback!

  11. Vitor António says:

    Another question (for another situation), is there any equivalent in Win2D of this line of Direct2D:

    m_d3dContext->CopyResource(m_currentBuffer.Get(), m_previousBuffer.Get());

    This piece of code is taken from the swapchainpanel from microsoft samples.

    Its possible to copy the buffer from a previous DrawingSession (of a SwapChain) to a new DrawingSession?

  12. > Its possible to copy the buffer from a previous DrawingSession (of a SwapChain) to a new DrawingSession?

    If you draw to a rendertarget you can use CopyPixelsFromBitmap, but Win2D does not expose any equivalent for the buffers within a swapchain.  If you particularly need this for swapchains rather than rendertargets, you could interop to native and use the D3D API.

  13. Vitor António says:

    Ok thanks for the reply Shawn!

  14. Roudoudou11 says:

    Bonjour tout le Monde.

    Excellent ,remplace  XNA….

    Continuez et bravo…encore plus d'exemples de jeux…plateforme…mario…pacman…

    Merci

    Cordialement.

  15. Roudoudou11 says:

    Bonjour tout le Monde.

    Quel Template utiliser dans Visual Studio 2015 pour concevoir Harrydactyl?

    Avez-vous un tutorial pour la conception de ce jeu?

    Merci beaucoup d'avance.

    Cordialement.

  16. Cooper Partin - MSFT says:

    Roudoudou11,

    Unfortunately there isn't a tutorial on how Harrydactyl was built.  That might be a good addition to the appweek process when we do another one.  A documented journey to the end result would be an interesting read.

    How was the Harrydactyl project setup done?

    First, I started with a default Windows 8.1 XAML project template. This template creates a shared project for you and supports both Windows 8.1 and Windows Phone 8.1.  I then moved my XAML mainpage into the shared project and removed the copies which lived in the other projects.  I did this step mainly because because I have very simple mainpage and wanted to share this page across all platforms. I am not sure this is the best approach for everyone, but it worked for my needs.  I added the Win2D NuGet package reference to my projects and some basic rendering calls for my mainpage.

    Next, I created a clean separate Universal Windows 10 project with the same name as my Windows 8.1 project. I did this on purpose because it simplifies the sharing of code via a shared project. Many default files and classes get created for you by the VS project system based based on the name of the project.  I renamed my new Universal project file (.vcxproj/.vcxproj.filters]) and added it to the solution that contains my Windows 8.1 projects.  I then added a reference to the shared project which was already present in the solution as well.  After doing that I had to resolve a few compilation errors involving duplicate files being referenced.  The App.xaml file lives in the shared project and was also present in the universal project.

    If you look at the Harrydactyl project you will notice that I did some extra renaming work on the directories and directory structure to make it look more organized and easier to find files.

    Doing this work made a full cross OS config for my game.  It is a very manual process to create such a setup and I am sure there is a more streamlined process out there somewhere.  I really like that I ended up with one solution with shared source that cleanly builds for 8.1 and 10.

  17. Roudoudou11 says:

    Bonjour tout le Monde

    Merci beaucoup  Cooper Partin de MSFT

    Cordialement

  18. Roudoudou11 says:

    Bonjour tout le Monde .

    Dans le jeu  Harry et dans "Utilities.h" nous avons √† la ligne 16 et 18 float2 ???

    je vous remercie d'avance

    Cordialement.

  19. Roudoudou11 says:

    Bonjour tout le Monde

    Harry compile tr√®s bien sous Visual Studio 2015 mais j'ai de tres nombreuses lignes de code soulign√©es en rouge….

    C'est vraiment dommage….

    Peut etre avez-vous une solution pour faire dispara√ģtre ces lignes rouges sous la plupart du code….

    je vous remercie beaucoup pour vos réponses et bonne chance.

    Cordialement.

  20. Roudoudou11 says:

    Bonjour tout le Monde

    J'ai toujours "float2" souligné en rouge dans le .h et le .cpp????

    Pourtant  la compilation se passe tres bien…

    Je suis avec Visual 2015.

    Ce n'est qu'un petit d√©tail mais g√©nant…

    Cordialement.

  21. Roudoudou11 says:

    Bonjours tout le Monde

    Ouf….j'ai trouv√© d'o√Ļ venaientt ces maudites lignes rouges…

    Elles apparaissent quand je suis en Debug ARM ,Debug Win32 et Debug x64…

    Elles n'apparaissent pas en Debug x86,donc tout va bien….

    Bon code à tout le monde

    Cordialement.

Skip to main content