Game Programming 101 Part 2 - 2001

Game Programming 101 Part 2 - 2001 - - Game...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon - Game Programming 101 Part II Game Programming 101 Part II Game Programming 101 Part II by Bruno Sousa Introduction I’m back and I have some good news and some bad news. The bad news is that we will probably not work on the DirectDraw wrapper as I said in the last article. The thing is, we need some more (not-so) important skeletons to help us work with DirectX before we can start on the wrapper. One of them is a Win32 skeleton and another is an error handler. I think we need to build these two things first so that we can debug our DirectX application more easily. The good news is that we will have a complete program at the end of this article. It won’t do very much, but it will work (or so I hope). Enough said, let the coding begin. Error Handling Before we start on our Win32 skeleton we should create some kind of error visualization system. Since using GDI (graphical device interface) to display text in DirectX isn't very fast, we're going to make have our error routine log errors in a text file instead. We will also add an option to exit the game when an error occurs. We’ll create the class CError to handle all error routines. The prototype for our class will be the following: class CError { public: FILE *fErrorLog; bool bQuit; LPSTR lpzMessage; CError (LPSTR, bool); ~CError (); ProcessError (DWORD); }; Now for a brief explanation of each variable. fErrorLog is a pointer to the file where we will log all our errors. bQbuit is just a Boolean variable holding true or false to indicate whether the program should quit or not when an error occurs. lpzMessage is the actual error message. The size of the message will be dynamically allocated when an error occurs for best performance in terms of memory and customizability (that sounded weird). CError is the constructor for the class; it takes a string and a boolean as arguments. The string is the name of the file where the errors will be logged and the boolean sets whether or not the program will quit when an error occurs. The destructor will clean things up when we’re done. For the C programmers, a class is just like a struct with functions; they have more advanced features as well, but we will not use them. Just in case you don’t know, a constructor is called when an instance of the class is declared and the destructor is called when the instance is killed, either by the program termination, the variable going out of scope, etc. (1 of 6) [5/12/2001 5:45:20 PM]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon - Game Programming 101 Part II We will now start the actual code for the error handling routines. First we must code the constructor and destructor. CError::CError (LPSTR lpzFileName, bool bQuitOnError)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/08/2011 for the course CS 101 taught by Professor Jitenderkumarchhabra during the Summer '11 term at National Institute of Technology, Calicut.

Page1 / 6

Game Programming 101 Part 2 - 2001 - - Game...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online