2014-09-04 02:46:39 +04:00
|
|
|
# Win2D
|
2014-06-28 00:53:27 +04:00
|
|
|
|
2014-09-04 02:46:39 +04:00
|
|
|
Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics
|
2014-07-29 21:50:27 +04:00
|
|
|
rendering with GPU acceleration. It is available to C# and C++ developers writing
|
|
|
|
Windows Store apps for Windows 8.1 and Windows Phone 8.1. It utilizes the power of
|
|
|
|
Direct2D, and integrates seamlessly with XAML and ICoreWindow.
|
|
|
|
|
2014-09-04 02:46:39 +04:00
|
|
|
Win2D is work in progress and evolving rapidly. The goal of releasing this code
|
2014-07-29 21:50:27 +04:00
|
|
|
in an early, incomplete state is to solicit early developer feedback.
|
|
|
|
|
2014-09-04 02:46:39 +04:00
|
|
|
- [Features](http://github.com/Microsoft/Win2D/wiki/Features) - *what's implemented so far*
|
|
|
|
- [Backlog](http://github.com/Microsoft/Win2D/wiki/Backlog) - *what we plan to add next*
|
|
|
|
- [Documentation](http://microsoft.github.io/Win2D)
|
|
|
|
- [Team blog](http://blogs.msdn.com/b/win2d)
|
2014-08-27 21:56:08 +04:00
|
|
|
- [License](http://www.apache.org/licenses/LICENSE-2.0.html)
|
2014-09-04 02:46:39 +04:00
|
|
|
- [Contributing](http://github.com/Microsoft/Win2D/blob/master/CONTRIBUTING)
|
2014-08-27 21:56:08 +04:00
|
|
|
|
|
|
|
## Code Example
|
|
|
|
To give you a flavor of what the code looks like, here is a snippet of XAML:
|
|
|
|
```xml
|
|
|
|
xmlns:canvas="using:Microsoft.Graphics.Canvas"
|
|
|
|
|
|
|
|
<Grid>
|
|
|
|
<canvas:CanvasControl x:Name="canvasControl" />
|
|
|
|
</Grid>
|
|
|
|
```
|
|
|
|
and C#:
|
|
|
|
```cs
|
|
|
|
canvasControl.Draw += canvasControl_Draw;
|
|
|
|
```
|
|
|
|
```cs
|
|
|
|
void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
|
|
|
|
{
|
|
|
|
args.DrawingSession.Clear(Colors.BlueViolet);
|
|
|
|
}
|
|
|
|
```
|
2014-07-29 21:50:27 +04:00
|
|
|
|
|
|
|
## Setup
|
2014-08-27 21:56:08 +04:00
|
|
|
#### Visual Studio
|
2014-07-29 21:50:27 +04:00
|
|
|
- Download [here](http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx)
|
2014-08-27 21:56:08 +04:00
|
|
|
- Requires Visual Studio 2013 Update 2 or greater
|
|
|
|
- If using Visual Studio Express, requires the 'for Windows' version (not 'for Windows Desktop')
|
2014-07-29 21:50:27 +04:00
|
|
|
|
2014-08-27 21:56:08 +04:00
|
|
|
#### Clone Repository
|
2014-07-29 21:50:27 +04:00
|
|
|
- Go to 'View' -> 'Team Explorer' -> 'Local Git Repositories' -> 'Clone'
|
2014-09-04 02:46:39 +04:00
|
|
|
- Add the Win2D repository URL (https://github.com/Microsoft/Win2D.git) and hit 'Clone'
|
2014-07-29 21:50:27 +04:00
|
|
|
|
2014-08-27 21:56:08 +04:00
|
|
|
#### Build NuGet Packages
|
2014-07-29 21:50:27 +04:00
|
|
|
- In Windows search, type 'Visual Studio Tools', and select that folder to open it
|
|
|
|
- Launch 'Developer Command Prompt for VS2013'
|
2014-09-04 02:46:39 +04:00
|
|
|
- Change directory to your cloned Win2D repository and run 'build'
|
2014-07-29 21:50:27 +04:00
|
|
|
- Point Visual Studio at the resulting 'bin' directory:
|
|
|
|
- In Visual Studio, go to 'Tools' -> 'NuGet Package Manager' -> 'Package Manager Settings'
|
|
|
|
- Choose 'Package Sources'
|
|
|
|
- Click the '+' button to add a new source
|
2014-09-04 02:46:39 +04:00
|
|
|
- Set 'Name' to 'Win2D' (or a name of your choosing)
|
|
|
|
- Set 'Source' to the full path to the 'bin' directory (inside your cloned Win2D repository)
|
2014-07-29 21:50:27 +04:00
|
|
|
- Click the 'Update' button
|
|
|
|
- Click 'OK'
|
|
|
|
|
2014-08-27 21:56:08 +04:00
|
|
|
#### Quickstart
|
2014-07-29 21:50:27 +04:00
|
|
|
Follow the steps below to get started on writing your own apps.
|
|
|
|
|
|
|
|
- Go to 'File' -> 'New' -> 'Project...'
|
|
|
|
- Select 'Visual C#' -> 'Store Apps' -> 'Universal Apps'
|
|
|
|
- Create a 'Blank App (Universal Apps)'
|
|
|
|
- Set a 'Name' of your choosing
|
|
|
|
- Click 'OK'
|
|
|
|
- Go to 'Tools' -> 'NuGet Package Manager' -> 'Manage NuGet Packages for Solution...'
|
2014-09-04 02:46:39 +04:00
|
|
|
- Select 'Win2D' package and click 'Install'
|
2014-07-29 21:50:27 +04:00
|
|
|
- Click 'Close'
|
|
|
|
- Change Solution platform from 'Any CPU' to x86
|
|
|
|
- You are now ready to hit F5 (Build)
|
|
|
|
|
2014-08-27 21:56:08 +04:00
|
|
|
A working sample can be found in the Samples directory.
|
2014-07-02 21:14:14 +04:00
|
|
|
|
2014-08-27 21:56:08 +04:00
|
|
|
## Source Directory Structure
|
2014-07-02 21:14:14 +04:00
|
|
|
|
2014-08-27 21:56:08 +04:00
|
|
|
Note: For the bulk of interesting product code, go to /winrt/lib.
|
2014-07-02 21:14:14 +04:00
|
|
|
|
2014-07-29 21:50:27 +04:00
|
|
|
**/bin** - Binary files generated by the build
|
2014-07-02 21:14:14 +04:00
|
|
|
|
2014-07-29 21:50:27 +04:00
|
|
|
**/build** - Shared, build-related resources that are common across projects
|
|
|
|
- /Assets - Common Windows Store assets used for tests and samples
|
|
|
|
- /nuget - Resources needed for building the NuGet package
|
2014-06-28 00:53:27 +04:00
|
|
|
|
2014-08-27 21:56:08 +04:00
|
|
|
**/numerics** - Cross-platform vector and matrix math library. There are three implementations:
|
2014-07-29 21:50:27 +04:00
|
|
|
- /Cpp
|
|
|
|
- /DotNet
|
|
|
|
- /WinRT
|
2014-06-28 00:53:27 +04:00
|
|
|
|
2014-08-27 21:56:08 +04:00
|
|
|
**/obj** - Intermediate files generated by the build
|
2014-06-28 00:53:27 +04:00
|
|
|
|
2014-09-04 02:46:39 +04:00
|
|
|
**/samples** - Example projects showing how to use Win2D
|
2014-06-28 00:53:27 +04:00
|
|
|
|
2014-09-04 02:46:39 +04:00
|
|
|
**/tests** - Test projects that consume Win2D in a similar way to how an
|
2014-07-29 21:50:27 +04:00
|
|
|
external customer would. Each one is a Windows Store app. These tests are run for manual
|
|
|
|
verification.
|
2014-06-28 00:53:27 +04:00
|
|
|
|
2014-09-04 02:46:39 +04:00
|
|
|
**/tools** - Standalone utilities, separate from Win2D product code
|
|
|
|
- /codegen - Generates headers+IDL from XML resource files (you don't have to build this to build Win2D)
|
2014-07-29 21:50:27 +04:00
|
|
|
- /copyright - Verifies the right copyright banner appears at the top of each source file
|
2014-08-27 21:56:08 +04:00
|
|
|
- /docs - Tools and scripts for building API reference documentation
|
2014-06-28 00:53:27 +04:00
|
|
|
|
2014-09-04 02:46:39 +04:00
|
|
|
**/winrt** - Win2D product code and automated tests
|
2014-07-29 21:50:27 +04:00
|
|
|
- /dll - Build resources for the product dll
|
2014-08-27 21:56:08 +04:00
|
|
|
- /docsrc - Source files used to create the reference documentation
|
2014-07-29 21:50:27 +04:00
|
|
|
- /inc - Common includes
|
|
|
|
- /lib - All the projected IDL and runtime class implementations!
|
|
|
|
- /WinRTDirectX - projections for D3D/DXGI types
|
2014-08-27 21:56:08 +04:00
|
|
|
- /published - Headers that are included directly in the NuGet package for 3rd part consumption
|
2014-07-29 21:50:27 +04:00
|
|
|
- /test.external - Automated tests that use only the public WinRT interface
|
2014-08-27 21:56:08 +04:00
|
|
|
- /test.internal - Automated tests that link directly with winrt.lib to access internals of the implementation
|
|
|
|
- /test.managed - Automated tests written in C#
|
WinRT IVector<T> implementation
I could not find any existing implementations that were sufficiently complete,
high quality, supported collections of runtime types as well as interfaces and
value types, and were under a suitable open source license, so had to write my
own. Hopefully this Vector.h will fill that hole for others with similar needs
in future!
Features:
- Implements IVector<T> and IIterable<T>, but not IObservableVector<T>
- T can be interface, runtime class, or value type, and is factored such that
strings can easily be added if/when needed.
- Vectors may optionally be locked to a fixed size, in which case users can
change their elements but not add/remove elements.
- Vectors track a dirty flag so their owner can tell when their contents
changed. This is a lightweight internal-only mechanism rather than full
IObservableVector implementation to avoid complications with event handlers
causing circular refcount chains.
- By default vectors own their content data (internally using an STL
collection) but there is also an option to wrap them around some other source
so as to just provide a WinRT API surface on top of any other data.
- Provides an internal mechanism to get direct access to the STL container
inside a WinRT vector, so API implementations can work directly with this
rather than having to go through the overhead of WinRT vtable dispatch and
exception boundaries for every get/set/iterate operation.
2014-08-26 07:24:14 +04:00
|
|
|
- /test.nativecomponent - C++/CX component that exposes native functionality for use by test.managed
|