Bitmap Problem
okay, can anyone help with a problem that's been driving me nuts for over a week now?
I sm learning C++, i have read Sams Teach Yourself C++ in 24 hours so i have a reasonable understanding of some of the basics and i am currently reading Beginning Games Programming by Michael Morrison. In Chapter 5 the author introduces a bitmap class that does 3 things, loads a bitmap from a file, loads a bitmap from a resource or creates a bitmap of a defined size and colour, it also has a couple of methods such as free memory and draw the bitmap.
If my understanding is correct you should simply simply create a pointer to a new bimap constructor to create a new bitmap object within the program.
The example program given in the book is simply a bitmap of a ufo which the user can move around the screen against a desert night sky background (also a bitmap). The program compiles and works fine on my pc using both DEVC++ and Visual express 2008 and i think i understand all the concepts involved.
My problem starts when i right my own program as i always think that if you can write your own programs using the examples in the book you will learn the concepts involved a lot more thoroughly. My idea was to write a version of the old Lunar Lander game. I have written the game and debugged it, eliminating all the bugs until it finally compiled without a hitch. When the program is run it just displays a blank window.
After a bit of searching there appears to be a problem with the bitmap class, specifically the lines:
HRSRC hResInfo = FindResource(hInstance, MAKEINTRESOURCE(uiResID), RT_BITMAP);
if (hResInfo == NULL)
return FALSE;
hResInfo always returns a null value and thus fails to load the bitmap, in the book example hResInfo always returns a value. I have not altered the Bitmap class in anyway for my program other than to add a message box notification when the bitmap can't be found. In my program in debug mode i can see the correct resource file value for uiResID and the correct value for hInstance which is passed into the object constructor via a global variable.I cannot understand why the program cannot find the bitmap, especially since the book example works absolutley fine using the same code. The same thing happens if i compile in DEVC++ or Visual Express 2008.
I have since stripped the program right down to just showing a window, loading and displaying a bitmap using the bitmap class and i still get the same problem.
Has anyone got any clue as to why this would be happening?
Chris
Quote:
I have written the game and debugged it, eliminating all the bugs until it finally compiled without a hitch.
Debugging/bugs entail much more than just getting the code to compile, that merely eliminates syntax error.
I am guessing this is a Windows resource problem, you may want to look at the .rc file that is included with the example. I don't know much about these at all because I tend to avoid them. I suggest you reread the chapter and look closely at resources.
[Edited by - Portmanteau on July 8, 2008 9:39:35 PM]
That´s not a very good book on game programming.
It´s confusing, the game engine created is weak and rigid rather than strong and flexible. I would suggest you drop the book and pick up Beginning Game Programming with DirectX by Johnatan Harbour.
It´s a simple book and teaches you one of the world´s most powerful library.
Well, that´s my opinion.
It´s confusing, the game engine created is weak and rigid rather than strong and flexible. I would suggest you drop the book and pick up Beginning Game Programming with DirectX by Johnatan Harbour.
It´s a simple book and teaches you one of the world´s most powerful library.
Well, that´s my opinion.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement