Problem with Hi Res bmp images

Hello to all,
I am currently trying to load a 800x600 24 bit bmp image. I have set up a C++ class for loading bmp file (taken from the openGL Game Programming Book by Dave Astle and Kevin Hawkins).
The code works fine for low res bmp files but for anything above 640x480, I get memory leak (illegal memory referencing error).
In my openGL part of code, I use glDrawPixel function. What is wrong here? Let me know Thanx in advance.

Try to have a deeper look at the code they provide. Personally, I didn’t like this book (but I don’t want to do polemics).
I’ve never loaded BMP images yet, so I’m not sure about what it could be. But I think they/you might allocate not enough memory.

Hope this helps.

Are you sure you haven’t typed anything wrong? I have the same book and have used their code for 2 years. I’ve even loaded a 1024x1024 earth texture. Maybe there’s an error I don’t remember. Google for the book’s website and check the errata. I don’t know if there was anything wrong in the cd code, I’ve typed the code looking from the book.

Sure I have used the code exactly from the book. I even used my bitmap with the book’s code but still get memory leaks.

Then maybe the error is not in there? Try checking all of your code. A few months ago I had trouble where if I added a variable in my class (which already had many variables and objects) I would get a compile error. The error was in the destructor of another class that I used. All I’m trying to say is double check the whole of your code. I don’t think there’s an error in the book’s code (at least as long as I can remember)

(Light bulb popping over moucard’s head)
Try loading your image in one of the examples in the book’s cd-rom. If the image loads then the error lies within your code. If not try checking with a debugger or print out if you read correctly the depth, the width, the height of the image etc.

Edit #2 Damn I hate when I don’t read the posts carefully. Scratch the first two sentences of my light bulb thing. The image loads properly with an image editing program?

Thanx Moucard for your help.
I have already tried loading the very image with the book source code but I get the same memory leak. I tried to diagnose the error my self and found out that every thing in my BMP class is working correctly no malloc errors. However in the opengl class, everything is smooth uptil the glDrawPixels function. The program is sort of crashing at that point. Strange indeed. :confused:
What I will do no is that I will provide the whole code here. See if you guys can point out any error or else there is something wrong with my PC???

Guys thanks for your help
The error has been sorted thanx to jide and moucard for help I decided to restructured the main opengl file and it worked. the compiler was buggy with it. The code in the book is spot on. I have made a utility class based on the code for handling bmp files. Thanks for the help and appologies for bothering :wink:

Don’t worry. Everybody had been in your place before. We all get cocky with our code, only to find out later on that it was really our fault. God knows how many times I’ve blamed Microsoft’s implementation of STL (from .NET 2003, which is really good). Starting to realize that in 99.999% of cases it’s really the programmer’s fault is a sign of growing up as a programmer.