Tuesday, November 12, 2013
Remote Graphics Diagnostics with Windows RT 8.1 and Visual Studio 2013

This blog post is a brief follow up to my What’s New in Graphics and Game Development in Visual Studio 2013 post on the MVP Award blog. While writing that post I was testing out various features to try to make sure everything worked as expected. I had some trouble getting Remote Graphics Diagnostics (a/k/a remote graphics debugging) working on my first generation Surface RT (upgraded to Windows RT 8.1). It was more strange since I could use remote debugging when doing CPU debugging; it was just graphics debugging that was causing trouble.

After some discussions with the great folks who work on the graphics tools in Visual Studio, they were able to repro the problem and recommend a solution. My Surface RT needed the ARM Kits policy installed on it. Once I followed the instructions on the previous link, I could successfully use Remote Graphics Diagnostics on my Surface RT. Please note that this requires Windows RT 8.1 RTM (i.e. not Preview) and that Remote Graphics Diagnostics on ARM only works when you are using Visual Studio 2013 as it is a new feature (it should work just fine using the Express for Windows version).

Also, when I installed the ARM Kits policy I needed to do two things to get it to work properly. First, when following the “How to install the Kits policy” instructions, I needed to copy the SecureBoot folder into Program Files on my Surface RT (specifically, I copied the SecureBoot folder to “C:\Program Files\Windows Kits\8.1\bin\arm\” on my Surface RT, creating any necessary directories). It may work if it’s in any system folder; I didn’t test any others after I got it working. I had initially put it in my Downloads folder and tried installing it from there. When the machine restarted it displayed a worrisome error message. I repeatedly pressed the button that would allow me to retry and eventually the machine rebooted and managed to recover itself to its previous state. Second, I needed to install it as an Administrator. The instructions say that this might be necessary. For me it was.

This is a Remote Graphics Diagnostics is a great new feature in Visual Studio 2013 so I definitely encourage all of you to check it out!

Posted On Tuesday, November 12, 2013 11:50 AM | Comments (0)
Saturday, April 6, 2013
Version 1.1 of the Windows Store DirectX Game Template is out!

Just a few minutes ago I uploaded version 1.1 of the Windows Store DirectX Game Template (WSDXGT) to the Visual Studio Gallery. If you already have it installed, it should show up as an update the next time you restart Visual Studio 2012 unless you’ve disabled update notifications (if it doesn’t show up but should, let me know; I forgot to keep a copy of VS 2012 with the 1.0 installed so I couldn’t test that myself this time).

This release is just a simple addition of several classes that make XAML data binding and using the MVVM pattern much easier. I plan to build on these to create a template that features a skeleton framework game state system (i.e. a main menu state, a game play state, etc.). The new classes are BindableBase (which should typically be the base class of any view model you create), UICommand (which implements the ICommand interface, allowing you to bind lambdas, member functions, and functions to any control that derives from ButtonBase (e.g. the Button control) thus helping with MVVM design), and a trio of IValueConverter implementations: BooleanNegationConverter, BooleanToVisibilityConverter, and MultipleConvertersConverter. The MultipleConvertersConverter lets you chain multiple IValueConverter converters together in XAML, which makes it much easier to create simple value converters and combine them together to compose more complex value conversion behavior. See the comments for the class in MultipleConvertersConverter.h for a XAML usage example snippet.

As always, comments, questions, feedback, and constructive criticism are all welcome, and if you like it please consider reviewing it in the Visual Studio Gallery (see the first link above)!

Posted On Saturday, April 6, 2013 8:54 PM | Comments (0)
Monday, April 1, 2013
I’m a Visual C++ MVP!

As many of you may have heard, Microsoft is in the process of retiring the XNA/DirectX MVP award over the next year. Though it is sad that the award category is going away, I understand Microsoft’s reason and it makes a lot of sense. They continue to have a deep commitment to gaming technologies and to game development, and they do still love indie developers (though at times that might not come through as clearly as we’d like).

My Microsoft MVP award period starts on April 1st (it’s not an April Fool’s Day joke, it’s just the beginning of a quarter) and runs for a year. Over the past two years I’ve been getting steadily more involved with the DirectX side of things since Microsoft decided not to support development of Windows Store games with XNA. This has meant getting back into C++ after many years away from it, which has been an exciting trip. With the release of the C++11 language standard and the incorporation of much of it into the Visual C++ compiler in Visual Studio 2012, most of the things I found frustrating about C++ more than a decade ago have disappeared. I won’t pretend that C++ is easier, faster, or better than C# but I also won’t pretend that C# is inherently easier, faster, or better than C++. For some things C++ is the better choice and for others C# is (and for some problems they’re fairly evenly matched (and then there are problems that completely different languages are best suited for)).

Anyway, I’ve been working more and more with C++ over the past two years and have been helping people more and more with it, e.g. by writing C++ Succinctly, by becoming more involved on the MSDN C++ forums and the DirectX forums on the Xbox LIVE Indie Games site, and by working on projects such as the Windows Store DirectX Game Template and samples based on that. For these and other contributions to the C++ community over the past year, I’m honored to say that Microsoft has presented me with a Visual C++ MVP award.

I remain very interested in helping new game developers learn game programming and in helping existing C#-based game developers explore the realm of DirectX and C++ (it’s not scary, just a little different). I shall continue to endeavor to help micro ISVs and other indie developers with the unique problems that we face and to make sure that Microsoft is aware of those challenges as it develops new products, new versions of existing products, and looks for ways to engage developers.

Thank you!

Posted On Monday, April 1, 2013 11:50 AM | Comments (0)
Thursday, March 28, 2013
Windows Store DirectX Game Template on the Visual Studio Gallery

I’ve at last finished converting the Windows Store DirectX C++ Sample Base (aka BaseWin8Direct3DApp) into a proper project template. Or, in this case, a multi-project project template. I then packaged that up into a VSIX file which I’ve posted to the Visual Studio Gallery as the Windows Store DirectX Game Template. Once installed (and yes, it works just fine with the free Visual Studio 2012 Express for Windows 8), you can create new projects based off of it to your hearts content.

See the Getting Started page for info about how to create and setup a new game project.

See the How To page for info about how to perform various tasks with the sample.

Good luck!

Posted On Thursday, March 28, 2013 11:41 PM | Comments (0)
Wednesday, February 27, 2013
Windows Store C++ DirectX Bloom Sample released (and other samples updated)

At long last, I’ve finished the Bloom sample. You can get it here:

It is a near replica of the XNA Bloom sample written in C++ using DirectXTK and my Windows Store DirectX C++ Sample base. It’s large (almost 15 MB) due to the TGA texture files that the tank model uses. This release includes the version of DirectXTK released February 22, 2013. As always, any questions, comments, suggestions, and bug reports are welcome and appreciated. The sample makes use of some XAML UI, including both on canvas controls to let you mess around with various bloom parameters and a bottom AppBar that lets you switch between the presets that the XNA sample defined. With a touch screen you just swipe up from the bottom to make the app bar appear; with a mouse you right click to show it.

The code in this sample also shows how to load and render a model using DirectXTK. We use the same tank model from the XNA sample along with the same background image so that you can compare them side by side if you are coming from C# and XNA and learning C++ and DirectX.

All three C++ samples have an updated version of the Camera class, which now provides for both left-handed and right-handed matrices so that whether you are using .CMO files or .sdkmesh files, you can work in the correct coordinate system with the same instance of the Camera class. I have removed the old ambiguous GetProjectionMatrix and GetViewMatrix member functions and replaced them with Get*MatrixLH and Get*MatrixRH versions.

I’ve also added a frame rate display to the samples. It’s really only useful for detecting if you’ve dropped below 60 fps. You will find it in DirectXPage.xaml.cpp.

Starting with this sample, I added the concept of game components. I have gone back and added them to the sample base and the pixel perfect collision sample as well. You do not need to use them, but they can be helpful and I intend to use them more in future samples.

There are three interfaces: IGameResourcesComponent, IGameUpdateComponent, and IGameRenderComponent. Each is a pure abstract class and their use demonstrates what I consider to be one of the good uses of multiple inheritance in C++. The BloomComponent implements IGameResourcesComponent and IGameRenderComponent. It has no need of IGameUpdateComponent so it does not implement it. The current mechanics of adding and (especially) removing game components will be a bit difficult for anyone not very familiar with how std::vector works in C++. It is sort of like .NET’s List<T> class but some member function have different names than their .NET counterparts and some things work a bit differently than you might expect.

I’m strongly considering making the next sample a XAML UI-based take on the XNA Game State Management sample. If so, this will flex and stress the game component system I’ve introduced. This may mean the addition of some helper functions or perhaps even some large, breaking changes in the game component system. Starting with the next sample (whatever it is), I will be documenting any breaking changes that I make to other samples by adding a changelog file to each solution. I’ll still describe any changes in the blog posts, but this should help you with tracking what has changed and me with remembering what I have changed (without needing to dig through my source control commit messages and file diffs). Hopefully breaking changes will begin slowing down.

The only things I’m anticipating presently are some modifications to the game component system (definitely some additive changes and perhaps some breaking ones) and (at some point in the indefinite future) adding an XAudio2-based music engine to complement the existing Media Foundation based music engine. XAudio2 provides lower latency and more control but support for using it to play WMAs and MP3s via Windows Phone 8 isn’t there currently and my goal initially with the AudioEngine class was to have it be usable both for Windows Store and Windows Phone 8 apps and games (which it did when I last tested it, though I never did test the final version in a WP8 project so it’s possible that it might need tweaking to work there).

Fairly soon the base sample should crystalize into a final form that will need few, if any, changes other than maintenance releases to update to newer versions of DirectXTK. That’s my hope anyway; we’ll see!

Posted On Wednesday, February 27, 2013 12:58 AM | Comments (1)
Wednesday, February 20, 2013
Pixel Perfect Collision Sample - Improved!

One part I wasn’t quite satisfied with in the original pixel perfect collision sample was the need to render the image in order to extract its data. Shawn Hargreaves suggested that I skip the middle man (at least for a few common formats), copy the data directly from the texture and perform CPU-side conversion to eliminate the render step and avoid spinning up the GPU rendering pipeline. I thought that was an excellent idea, so that’s what I’ve done. (Shawn just provided the idea; if the code has problems, that’s my fault!)

The new DX::GetTexture2DCollisionDataNoRender function operates on a texture with one of the following formats: DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R32G32B32A8_FLOAT, DXGI_FORMAT_BC1_UNORM (Dxt 1 in old terminology), or DXGI_FORMAT_BC3_UNORM (Dxt 5). Other formats may be added as time allows, though you can easily enough add your own formats if you need them. I should note that this function will produce minor discrepancies (up to 2/255ths difference in my testing) in color and alpha channels for formats where conversion beyond mere swizzling is required. The data from this function should be more accurate since it does not rely on any vagaries of driver implementations. (In my testing of the BC1 and BC3 formats, I observed that CPU-side conversions perfectly matched the color values that could be found by opening up the BC1/3 DDS texture files in Visual Studio 2012’s image editor and using its eye dropper tool to inspect individual pixel’s color values. The original rendering method produced different variations depending on the target hardware (e.g. my Surface RT vs. my developer laptop with an Intel CPU and AMD GPU) and the specifics of the texture data). So if you are relying on this data for more than simple transparent/opaque checks, you should prefer this function to the original DX::GetTexture2DCollisionData since you should get more consistent results with this new function.

I also fixed a few bugs in the original. Key among them was that the memcpy_s function call in DX::GetTexture2DCollisionData was improperly using the row pitch for destination offsets rather than the texture width * 4 (bytes in a B8G8R8A8 pixel). It happened that the row pitch for a B8G8R8A8 texture was the same as the byte width which is why no erroneous results were produced. But this is an implementation detail in D3D drivers, one which could change any time and which might not even be true for some graphics cards/drivers.

Lastly I moved most of the function definitions (i.e. the bodies of them) from CollisionDetection2D.h to a new file, CollisionDetection2D.cpp. This was done both to keep the header file clean and easy to understand and also to speed compilation times when a change needed to be made in one of the collision detection functions.

The link from the original post will now grab the updated project. For reference, here it is again: . I plan to move on from collision detection now. What’ll come next? We’ll see!

Posted On Wednesday, February 20, 2013 12:36 AM | Comments (2)
Thursday, February 14, 2013
C++ Pixel Perfect Collision Detection Sample (and Base Sample updated!)

One of the more popular series of samples for XNA was the collision detection series. Especially the 2D pixel perfect collision and transformed pixel perfect collision. So as my first sample, I’ve replicated them. But since I don’t want to maintain more samples than I need to, they are all in a single sample. Everything is heavily commented and power just went out here for some reason but I’m happy to respond to questions about the sample, so feel free to ask away in the comments and I’ll get to them as soon as I can.

The sample can be downloaded here: . The key parts of the collision detection are in CollisionDetection2D.h . I also show how to use DirectXMath’s XMMATRIX to scale, rotate, and translate images. The Game class’s CreateDeviceResources, Update, and Render member functions have been updated accordingly (in Update and Render, non-transformed pixel perfect translation code is present but commented out).

While creating this sample I found a few bugs in my Windows Store DirectX C++ Sample Base (the Present method wasn’t checking for a null swap chain RTV and DSV which could cause a crash if a tablet was rotated at the wrong time and the CreateDeviceResources code had the potential to create a cross-threading D3D crash due to the possibility of accessing the device context from multiple threads at the same time). I fixed those up both in this sample and in the original base sample code. The original base sample has been updated in place so the original download link will give you the latest code. While I was fixing those bugs I also made a few cleanups and improvements since I was changing things anyway.

I haven’t yet decided which old XNA sample I want to replicate next so if there’s something you want to see, let me know. Ultimately I’d like to port the Platformer sample, but that is a fairly large sample with a lot of parts so it’ll be a little while before I have the time to do that. I’d like to complete more of the smaller, technique-oriented samples first. And I’d also like to do a few sample showing how to work with XAML including something that shows how to do game state (along the lines of XNA’s Game State Management sample but not necessarily a direct port of it). But for now I’m going to settle in with a book and wait for power to return.


Posted On Thursday, February 14, 2013 6:21 PM | Comments (0)
Thursday, January 31, 2013
Windows Store DirectX C++ Sample Base

I’ve been working on this on and off for over a year now (having essentially restarted entirely in the latter half of 2012). At last it is finished. I give you a Windows Store DirectX C++ Sample Base. It’s something you could build a game on top of. It’s something you could build a sample on top of. It passes WACK testing (or did until I reverted to the default icons anyway) and runs properly on my Surface RT as well as my other x64-based computers. It handles rotation. Lets you choose a fixed back buffer size. Includes an audio engine class, a Texture2D class, and a RenderTarget2D class. Makes use of DirectXTK. Lets you do fancy things like mixing XAML and DirectX while still using multisampling. Has a custom settings pane with premade volume controls, a privacy settings pane (you need to supply the appropriate privacy policy and any other controls you need, if any), and even an about settings pane. Shows you the basics of using XInput. Shows you the basics of doing async in C++ using the ConcRT PPL Tasks library. And it even includes Shawn Hargreaves’ cat and a Cornflower Blue background!

I’d love to write more about it, but I’ve been burning the candle at both ends to try to finish it up before January ended. I made it just in time! The code is all very commented. Key things you’ll want to look at are App.xaml.cpp, DirectXPage.xaml.cpp, DirectXPage.xaml, and Game.cpp (which derives from DirectXBase, which you may also want to look at). Note that the descriptions of what functions do are all in the header (.H) files whereas the comments on how they do it tend to all be in the CPP files.

Let me know what you think if you try it out. If you have any problems or questions, let me know that too. I’ve created a thread over in the Off Topic forum in the XNA/DirectX forums to facilitate discussion and centralize questions and answers - Windows Store DirectX C++ Sample Base.

You can grab the sample here: . You need to be running Windows 8 and Visual Studio Express 2012 for Windows 8 or Visual Studio 2012 Professional or above. I hope to start creating samples using this as a base to build on very soon. I’d be thrilled if others did the same. I’ll also try to include some posts about developing for the Windows Store in general (helpful links, good blogs, etc.) and about using C++. If you are new (or returning) to C++, I encourage you to check out the free (reg. req’d) eBook I wrote for SyncFusion last summer, C++ Succinctly - . It has a 20 code samples that guide you through the important, tricky parts of C++.

Hopefully you will find it helpful!

Posted On Thursday, January 31, 2013 11:14 AM | Comments (4)
Saturday, December 29, 2012
Accessing your Xbox Cloud Storage save games when you can’t access Cloud Storage

So if cloud storage is down or your internet connection to your Xbox is down, in most cases you can still play games you saved to Cloud Storage.

Note: This only applies to the Xbox that you last played the game on since it is relying on cached data. If you try it on some other Xbox then it may not work at all or may present you with older data (e.g. you are only level 22 when you really had gotten up to level 24 and you don’t have all those cool items you found).

  1. From the dashboard, go to “Settings”.
  2. Choose “System”.
  3. Choose “Storage”.
  4. Choose “Cloud Saved Games” (yes it’ll say something like “Offline”, just ignore that text).
  5. Find the game you want to play (e.g. “Borderlands 2”) and choose it.
  6. For each item (many games only have one file per player but some have more than one file), choose it, then choose “Copy”, and then as a destination choose either your hard drive or a memory unit (e.g. a USB thumb drive that’s formatted for use with the Xbox 360). Make sure that you copy all of the items to the same location (i.e. all to the hard drive or all to the same memory unit).
  7. When you have finished copying all items for the game to another storage device, you can back up to step 5 and repeat steps 5 and 6 for as many games as you want. You do not need to do all games at the same time nor do you need to do all of them at once.
  8. When you are finished, back out to the dashboard and proceed to launch the game you want to play. When it asks you to choose a storage device, make sure you select the storage device that you copied the game’s save game data to (i.e. your hard drive or the appropriate memory unit).
  9. When the game has loaded, verify that you are at the same level you were last at and have the same items you had. (If not then if you want you can still proceed to play but understand that that progress and those items will be lost forever on this “new” save game path. This should only happen if you are playing on a different Xbox than you had last played the game on when you were still able to access cloud storage. If you have access to that other Xbox, you could copy the save game data onto a memory unit and then move the memory unit to the Xbox that you wish to play on.)
  10. Play the game.
  11. When you have access to cloud storage again, you can copy your save games back to cloud storage by following steps 1 through 7 again except in step 4 choose the storage device you have been playing from (hard drive or MU) and in step 6 choose “Cloud Saved Games”. Make sure to launch the game, choose Cloud Storage, and verify that your progress and items are correct.

The above instructions are provided “AS IS” with no warranties or guarantees. In other words, it works for me but its not my fault if it doesn’t work for you or if you accidentally copy an old save game over a newer save game and obliterate a whole bunch of progress or anything else. If you have any worries, just wait until you can access cloud storage again.

(n.b. Borderlands is a registered trademark of Gearbox Software, LLC.)

Posted On Saturday, December 29, 2012 4:45 PM | Comments (0)
Saturday, September 29, 2012
Nokia vs. The World

I’m looking forward to the launch of the Nokia Lumia 920. Why? Well, it stacks up better than the competition for one thing. Then there’s also that security problem that certain other phones have. Mostly, though, it’s because I love my Lumia 900 and the 920, with Windows Phone 8, will be even better.

Before I got my Lumia 900, I just took it as given that smart phone cameras couldn’t be good. The Lumia taught me that smart phone cameras can be good if the manufacturer treats them as an important component worth spending time and money on (rather than some thing that consumers expect such that they’d better throw one in). I’m extremely pleased with the quality of pictures that my Lumia 900 gives me as well as the range of settings it provides (you can delve in to tell it a film speed, an f-stop, and a whole range of other settings). And the image stabilization features in the Lumia 920 deliver far better results than the others.

Nokia has had great maps for a long time and they continue to improve. Even better, they made a deal that puts many of their excellent maps into Windows Phone 8 itself. There are still Nokia-exclusive features such as Nokia City Lens, of course. But by giving the core OS a great set of fundamental map data and technologies, they help ensure that customers know that buying a Windows Phone 8 will give them a great map experience no matter who made the phone. I’ll be getting a 920, myself, but the HTC and Samsung devices that have been announced have some compelling features, too, and it’s great to know that people who buy one of these won’t need to worry about where their maps might lead them.

I’m looking forward to the NFC capabilities and Qi wireless charging my Lumia 920 will have. With the availability of DirectX and C++ programming on Windows Phone 8, I’m also excited about all the great games that will be added to the Windows Phone environment.

I love my Xbox Phone. I love my Office phone. I love my Facebook phone. I love my GPS phone. I love my camera phone. I love my SkyDrive phone. In short, I love my Windows Phone!

Posted On Saturday, September 29, 2012 10:42 PM | Comments (0)
Bob Taco Industries is an ISV focused on game and app development for Microsoft platforms headed up by Michael B. McLaughlin. Mike is a Microsoft Visual C++ MVP (previously an XNA/DirectX MVP from 2011-2013), a developer, a writer, a consultant, and a retired lawyer. If you're a developer who is just getting started, consider checking out the BTI website's section for developers for links to code samples and other helpful sites.
Tag Cloud