Tutorial FAQ

Why don't you use Exceptions (try/catch)?

Why don't you use objects/classes?

The sample applications use 100% of my CPU, why don't you use a timer?

Why don't you use Exceptions (try/catch)?

I want to keep things as simple and clear as possible. Exceptions do not seem to be well known as a rule, so I made the decision to stick with simpler C-style error handling.

If you're comfortable with C++ Exceptions you should be able to add them in with little difficulty

Why don't you use objects/classes?

Again, I want to keep things simple. More importantly, I don't want to create a wrapper around Direct3D objects and then teach you how to use my wrapper. More advanced tutorials may use objects I've wrapped up in a class to make it easier to focus on the new concepts, but not until all of the underlying concepts have been taught in previous lessons.

Once you've understood the lessons, wrapping up some of the complexity in a basic class is not very difficult. You can consider it an exercise for the reader.

The sample applications use 100% of my CPU, why don't you use a timer?

The timers available through the Win32 API (WM_TIMER, etc) are low resolution and unreliable. You will not be able to reliably maintain a presentation rate of 60 frames per second using those timers.

Realistically, any running task that doesn't sleep will use all the available CPU time. That's the way it should work. All idle cycles are given to running tasks. Granted it may be hard to use your word processor while running my applications, but why would you want to do that anyway?

If you feel strongly about throttling your applications back, feel free to experiment with timers and add calls to Sleep().

NOTE: Using calls like GetTickCount or timeGetTime to wait until a certain amount of time has passed is just as bad since it busy waits. If you're going to use the cycles anyway, you might as well use them rendering rather than waiting. For "proper" waiting, use something like calls to Sleep or Win32 timers (WM_TIMER, etc).

Back