I need to use win2D in my cppwinrt project. Using the Win2D sample file as a model I’ve tried to mimic its setup, putting in the package file for win2d from that project, duplicating the custom build step, but I can’t get it to compile. I remember some talk about Win2D being added soon to the standard cppwinrt headers so that it could be accessed like others of these wonderful cppwinrt interfaces. Is this something that might happen soon? Or does anyone have some really specific instructions for using Win2D in the current Visual Studio 2017 environment? I’m in the Insider preview program but haven’t seen anything come up. Thanks.
Is Win2D yet available in C++/WinRT?
Once you have downloaded Win2D and assuming you have the latest RS4 Windows SDK installed, you can simply use cppwinrt to generate the Win2D headers for consumption:
cppwinrt -in lib\uap10.0\Microsoft.Graphics.Canvas.winmd -ref sdk
This will generate a winrt folder that contains the headers that you need to include in order to use Win2D. You will then need to add the parent folder to your include paths and ensure that the Win2D DLL is copied to your package or build output folder.
Kenny, I think I have downloaded Win2D - have at any rate more than one Win2D.uwp.1.21.0. Using the above command prompt produces an error 0x80070057: Could not resolve metadata specification: lib\uwp10.0\Microsoft.Graphics.Canvas.winmd. I've got the 1.21.0 win2d in packages, as it is in the WIn2D sample file, and the additional includes are set as in the WIn2D sample. I appreciate your suggestions above but they are general. Is there some place where I could find really specific detailed instructions for adding WIn2D capability in this environment? –
Cuyp
Make sure the path to the winmd is valid, e.g. the relative path is being resolve from the right location. That error message basically means "could not find file". We should have project template support soon that takes care of this for you. –
Excavator
Project template support! What great news. I may just leave the composition code until later with that hope before me. BTW, I think I have the header files - they were already present in your Win2D sample anyway. I just can't find a way to get them known to my app: #include can't find them, though I've put them in the winrt directory with the others. –
Cuyp
Kenny- I've been away for a few months completing a Mac App and am back to this project. I was hoping that by this time that project template support for c++/winrt would be appearing in VS but I don't see it in 15.9 Preview 2. Am I missing it or is it just not there yet? Thanks. –
Cuyp
Thanks - when open the sample using VS 15.9.0 Preview 2.0 I see "Project 'PhotoEditor' could not be loaded because it's missing install components. To fix this launch Visual Studio installer with the following selections: Microsoft.Windows.CppWinRT" But even with the latest VS Installer just downloaded I cannot find any mention of this component in the long list of install options - there must be something I'm missing (my experiences may be useful as a general guide to what happens with newbies to this system). –
Cuyp
Part of the problem is that the error message apparently refers to a component that has a completely different name in VS Installer. The solution I tried was to choose Modify again but reselecting the Universal Windows Platform Development group. Unfortunately the result is that now VS won't even run my existing project; saying that the project is missing install components and now I should run VS Installer and choose Universal Windows Platform Development. Which is how I got here. This is probably the wrong place to speak of this; I expect to get pounded by StackOverflow. –
Cuyp
If it's a help: on the advice of Felix Huang I set the system environment variable DoBundleInstallationChecks = false, and now I can open my own project again. But I still can't open Photo Editor, and with that variable set false I don't get any error message either - the project just does not load. Perhaps there is some naming clash regarding components? –
Cuyp
p.s Felix at VS2017 Community has been very helpful but he notes that he doesn't know anything about cppwinrt, so far can't get to the bottom of of this, and that is why I remain on this page adding so many comments and probably annoying the regular denizens. –
Cuyp
As of the recent update, using Newget to install Win2D into a C++/WinRT project will automatically generate the headers and install them in "GeneratedFiles\winrt\"
© 2022 - 2024 — McMap. All rights reserved.
cppwinrt
compiler is included in the Windows 10 Insider Preview SDKs. You can generate headers from the Win2D.winmd
file yourself. See this post – Japhawhere
in a Developer Command Prompt for VS 2017 works for me (C:\Program Files (x86)\Windows Kits\10\bin\10.0.17110.0\x86\cppwinrt.exe
), likely because I have the VS 2017 (15.7 update) Preview installed with the new SDK integration. – Japhacppwinrt.exe
on thewinmd
for any '3rd party' Windows Runtime things you want projections for. – Japha