Getting Started
My overall goal as mentioned in my last entry is to get Hieroglyph 3 operational in a Metro style app. In an ideal world, I would want to have the complete library running in both "Desktop" mode (i.e. Win32 applications) and also in "Metro" mode (i.e. WinRT applications). However, after my initial analysis, pulling this off will probably require changing the library to such an extent that it wouldn't be able to run on Windows 7 where the WinRT library functions aren't available. So at the moment, all of the changes that I make and describe in this mini-series of posts are done on a local copy of the Hieroglyph unless indicated otherwise. This may be the beginning of Hieroglyph 4, but if possible I would like to keep the main library in a single repository... We'll see how that goes sometime down the road.
The setup I am using for development is my netbook, which is a single core AMD Athlon II Neo @1.7GHz and with a AMD Radeon HD 4225. Since I'm targetting Metro style apps, I naturally am running on the Windows 8 Consumer Preview and using the Visual Studio 11 Beta, both of which you can get here.
Identifying What Needs To Be Done
Microsoft is doing a good job of making tutorials and samples available for the general public to get started on Metro development. However, the proof is in the pudding - the first step in converting Hieroglyph over to Metro capable is to get it to compile under VS11. On the first try, I just cloned the latest Hieroglyph 3 repository and loaded it up in VS11 and tried to compile. The first thing to notice is the six billion errors because of missing dependencies. Since Direct3D and all his friends are now part of the core Windows development setup, there is no DirectX SDK anymore.
In Visual Studio 2010, the specific directories that a project needs to include are inserted via a per-project property setting - typically using a system variable to identify where the DirectX SDK include files are. VS11 also has the same property setup, so I just changed the existing include references to point to the new location. On my machine, this was located in the {...} directory. After updating these, I tried compiling again, and had more of the files trying to compile - but still lots and lots of errors.
To determine everything that needs to be updated, I simply disabled and/or commented out the portions of the library that weren't compiling due to things that aren't available to Metro style apps. After about an hour of going through this process, I compiled the library successfully and produced quite a list of things that need to be updated. They can roughly be categorized into a few main topics, as described below:
- Shader Compilation / Reflection
- Texture Loading
- Matrix Functions
- Text Rendering
- Application Model
- Enumeration Updates
Each of these topics is going to take some time to get past, and I'll be writing about them as I go. However, I wanted to give a quick indication of what is behind each of these issues.
Shader Compilation / Reflection
For Metro style apps, you are not allowed to compile your shaders at runtime. This does indeed make sense, since the compilation of some shaders takes quite a bit of time, which can cause unnecessary delays to starting up your program and consuming power (which can become important in tablets / mobile devices). However, for the developer this kind of stinks - it more or less means that you have to pre-process your shaders, and if you are actively changing them to get them working, this may cause some problems. Even so, there are work arounds possible, which we will talk about in a dedicated post.
Texture Loading
In general, the super library D3DX has gone the way of the Dodo - it isn't available anymore for Metro apps. This has lots of implications, including the loss of its texture loading functions. Once again, all is not lost - there are other libraries available to do this, and we will talk about it in a future post. Specifically there is DirectXTex if you want to read ahead...
Matrix Functions
Also due to the removal of D3DX, many matrix functions that I used to use are not available anymore. Once again, there is a replacement library that can be used called DirectXMath.
Text Rendering
Hieroglyph 3 uses GDI+ for its glyph generation and text rendering solution. This library is apparently not available anymore for Metro apps, so I will finally have to bite the bullet and upgrade to Direct2D and DirectWrite... That will certainly be a topic for another day...
Application Model
Perhaps the most obvious area to update is the fact that Win32 isn't generally available to Metro apps. This includes the file IO, threading, and a few other areas which are inevitable to update when migrating to Metro compatibility.
Enumeration Updates
This final point appears to be the removal of some old enum values that were dual defined with both D3D10_XXX and generic D3D_XXX names. I checked the headers in the DXSDK, and the D3D_XXX versions were there already and I was just using the old names. This is probably due to the fact that I started on Hieroglyph 3 with the pre-release version of D3D11 and just never updated. So these corrections I will make in the main line of Hieroglyph 3 as well as my Metro port.
Wrapping Up
So with the library compiling, now it is time to fix and replace the items that I had to disable. It will be a long road to get something rendered into a window, but I am already having fun learning about all the new goodies that are available in Metro style apps. Once these areas have been addressed, we will also start exploring these new capabilities too. I hope you enjoy the ride as much as I am
I just want to check, for those of us that have little or no interest in Metro style apps, are you still going to continue developing and enhancing the Win32 version of Hieroglyph, or will you be parking that and focusing purely on the Metro version in future?
Thanks
Ben