DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

DirectX and XAML in Windows (Phone) 8: Part 0 of N

Toni Petrina user avatar by
Toni Petrina
·
Nov. 05, 12 · Interview
Like (0)
Save
Tweet
Share
6.84K Views

Join the DZone community and get the full member experience.

Join For Free

DirectX is a powerful beast that enables creation of stunning graphics oriented applications (not just games). On the other hand, XAML is used to quickly create basic application UI. Having both in a single application seems like an obvious choice. For example: when building a game, you can use XAML to create level selection screens, mode selection screen, options page, etc while leaving DirectX to power the game itself. It is only natural to combine the best of the two in a single application.

Since we now have both Windows 8 and Windows Phone 8 out in the wild, I will dedicate some time on this blog to describing how to combine XAML and DirectX on both platforms. This is the first blog post in the series and will provide some basic overview of future posts.

Since DirectX is exposed only in C++ project templates, first couple of posts will feature C++/CX only. Later on, I will describe how to bridge the gap to the managed world using SharpDX for Windows 8. All examples will be rather simplistic, but you can use your imaginations to build wonderful new things.

During the series, I will be using Microsoft Visual Studio 2012 Express for Windows 8 and Microsoft Visual Studio 2012 Express for Windows Phone, which you can download from the following links: Express for Windows 8 and Express for Windows Phone. All samples for Windows 8 can can also run on Windows RT since we are building a Windows Store app.

DirectX is a low level API for using the most out of your graphics cards. Since it is primarily used for games, it is not a part of the standard Windows UI stack. If you want to build an application using bothXAML and DirectX, you need to interoperate in a special way. There are three basic ways your application can use DirectX and XAML:

  1. Use DirectX surface as a part of the screen (e.g. simple modeler tool using XAML for properties and DX for visualiation)
  2. Use DirectX surface that is significantly larger than screen (e.g. maps, document viewers)
  3. Use DirectX surface in fullscreen mode and add little XAML for basic UI (e.g. games, simulations)

You can read more about these three modes on MSDN or on Windows 8 app developer blog. Note that for Windows Phone there is no XAML alternative for second scenario.

In the first and second case described above, you render on a target surface and then use that surface as a ImageBrush for your elements. The size and arrangement of the XAML element in first scenario is handled like any other XAML element. When you want full control of the drawing surface (e.g. for games), go for the third option and manage your own swap chain.

All source code will be available on github as the series progresses.

In the next blog post I will describe how to incorporate a simple DirectX surface in a XAML page.

DirectX Windows Phone

Published at DZone with permission of Toni Petrina, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • An Introduction to Data Mesh
  • Stream Processing vs. Batch Processing: What to Know
  • Quick Pattern-Matching Queries in PostgreSQL and YugabyteDB
  • What Is Policy-as-Code? An Introduction to Open Policy Agent

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: