Game Development Reference
In-Depth Information
WinRT components
Windows 8 provides a common API for applications developed in C++, C#, or Javas-
cript to work with. It would be a lot of work to rewrite the API, or create wrapper APIs
for each language, so instead of doing that the Windows team developed a system
where a component written in one of the languages can be exposed to the other lan-
guages through a minimal translation layer. As developers, we can use this to access
components written in other languages easily and with minimal performance impact.
These components exist with DLLs that act in a manner similar to .NET class librar-
ies; however, they can also be consumed by C++ and JavaScript.
To create one of these, you simply create a WinRT Component project in Visual Stu-
dio and write code using either C# or C++/CX. Only ref types in C++/CX will be ex-
posed to WinRT, so if you're writing a game or application in C# and want to use a C++
only library, you can write a basic wrapper that includes native code in your compon-
ent, and expose that through ref classes and Windows::Foundation namespace
types for use in C# or JavaScript.
Note
A wrapper is a simple method (or class) that exists to call another function. It al-
lows us to write code that connects systems together where previously that might
not have been possible. For example, a WinRT component can act as a wrapper
between (pure) native C/C++ code and managed code.
Search WWH ::




Custom Search