{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
GameDev.net - Game Programming 101 Part II Game Programming 101 Part II GameDev.net 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. http://www.gamedev.net/reference/articles/article1074.asp (1 of 6) [5/12/2001 5:45:20 PM]
Image of page 1

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

View Full Document Right Arrow Icon
GameDev.net - 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.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern