Archive for April, 2009
Adding Direct3D 10.1 support to a D3D10 application
Since my graphics card (ATI Radeon 4870×2) supports Direct3D 10.1, I thought I might quickly add support for Direct3D 10.1 to my in progress D3D10 engine. Using MSDN docs and a slide from the 2008 GDC, I found it was really easy to add D3D10.1 support, since the device simply inherits from the D3D10 device, and since 10.1 simply adds features, you can use it selectively for some nice techniques and/or performance gains.
MSDN suggests that if you are going to be using the device a lot, and already have some place holding the D3D10 device, you keep a pointer to it, so I will assume you have such a class.
First you must create the Direct3D 10 device as you normally would, however you must use the D3DX10CreateDevice() method instead (see below), this is outlined in the SDK and multiple tutorials online. I may write up how to do this at a later point, however it is outside the scope of this little article.
Once the device has been successfully created, we can try and get a Direct3D 10.1 device from it. To do this, we will be using the following methods:
- HRESULT D3DX10CreateDevice( IDXGIAdapter*, D3D10_DRIVER_TYPE, HMODULE, UINT, ID3D10Device** ); [This will create the D3D10 device, and makes it easier to do so and then create the 10.1 device.]
- HRESULT D3DX10GetFeatureLevel1( ID3D10Device*, ID3D10Device1** ); [This will create the 10.1 device.]
The second method will take the current D3D10 device and create a 10.1 device from that if possible.
After we have our D3D10 device using D3DX10CreateDevice(), we can then call D3DX10GetFeatureLevel1, passing in the pointer to the device we just created, and a pointer-to-the-pointer to our D3D 10.1 device. This method returns a HRESULT indicating if the operation was a success.
If so, we now have a D3D10.1 device we can use for the extra functionality. I personally also keep a BOOL inside my Graphics class to allow me to easily check if I have 10.1 support.
Now you can take advantage of the new features in Direct3D 10.1, and SM4.1!
[Review] Windows via C/C++, 5th Edition
Title: Windows via C/C++ 5th Edition
Authors: Jeffrey Richter & Christophe Nasarre
Overview
“Get the preeminent guide to programming application for Windows with C++. Programming Applications for Microsoft Windows is a classic book (formerly titled Advanced Windows, Third Edition) and is now fully updated for Windows Vista, including the latest information about Windows XP. In-depth and comprehensive, this essential reference covers the Windows operating system and how to program at the API level. Recognized experts provide an inside view of how Windows works and how to use its features in Visual C++ development tasks. Topics covered include processes, thread pooling, virtual memory, DLLs, file I/O, and message crackers. For systems-level programmers, this is a must-have title. Includes code samples in Visual C++.”
Review
Although the title of the book is slightly misleading, this book certainly accomplishes what the overview says. The authors provide a great wealth of information concerning Windows development topics like Threading, Process Management, working with memory, DLLs and many other areas.
Weighing in at 800+ pages, this is a extensive guide to working with Windows. The book presents the information at a rapid pace and ultimately works better as a reference book than something you sit down and read. For example I was working on a wrapper for the Windows API INI functions for a game, and whilst I have worked with strings before, I have not worked much with the Unicode strings that Windows uses. This book really helped me to understand the many different available functions, and realise that even if you use the ASCII versions, Windows will convert behind-the-scenes. (Which could have a detrimental effect on performance)
Whether it be working with strings, or working with DLLs, this book will provide a nice overview of the many different functions available to you in the Windows API, as well as short instructions on how to best make use of them.
The book is split into Strings, Processes/Threads, Memory Management, DLLs and exceptions, and each part has many sub-parts each containing a wealth of information on the topic. Each chapter is laid out with a summary of how you would accomplish the tasks in each area (Thread creation etc), and for each function and structure you may use (or group of functions/structures), there is a small summary of the best way to make use of the capabilities of the function, as well as tables describing each part of the structure or the parameters for the function.
The book not only covers the correct ways to accomplish a task, but also provides information on legacy equivalents in case you encounter them or have to use them. (Although it does strongly advise you use the newer forms)
For those doing Engineering at UTS, this book covers the Windows API equivalents of what you would learn in Real Time Operating systems, and includes all the information about inter-process communication and inter-thread communication. I am unsure what IT students do as an equivalent (if there is one).
You can find the table of contents in the book’s MSDN article here and there is also excerpts from two chapters so you can get a nice example of the structure and writing style, that way you can try before you buy.
This book is aimed at intermediate or advanced developers who already have an understanding of C++ and want to work in a Windows environment. Most of this book applies to both CLI and Win32 development, and could even be used in Game development, as long as it uses the Windows APIs. The book is also up to date with the changes for Vista.
I would say this is a must get for any C++ Windows developer’s reference library. It has many applications and the theory of how things work in Windows on a lower level can be taken into many other languages.
If you are still beginning C++ development, you should probably steer clear from this book for now, and pick it up later when you have a better grasp of the language. This book provides very short and concise code samples that generally only cover the correct way to use a feature instead of a complete sample application. It assumes that you have experience with working with C++ and all of the language specific features, and is best used to extend your knowledge into Windows specific areas.
Rating: 8/10
I am currently running a competition at www.utsmsp.com where I have cross posted this review. If you are a Student or Developer in Sydney or Melbourne, you might be able to win the 2nd copy I have, more details at the end of the review there. (http://www.utsmsp.com/2009/04/review-windows-via-cpp/) If you are not in Sydney or Melbourne, you can still win this, but will have to cover the postage from Sydney.