I'm not sure if the 'b' in wb does this, but be certain you are opening the file in binary mode (and not text mode). |
|
Everything is set up right in OpenGL and the glut window is 800x600. The engine works, this is the code that doesn't work. GLUT is in RGB mode: |
|
I'm not sure if the 'b' in wb does this, but be certain you are opening the file in binary mode (and not text mode). |
|
I *think* because you've opened the file in "wb" (write binary) that the multiple fwrites at the bottom are overwritting each other |
|
(\_ _/)
(='.'=)
(")_(")
As far as I know fwrites don't overwrite each other. The "wb" style only overwrites the file if it already exists, each fwrite appends to that. "ab" opens a file that already exists and adds to it. |
|
try adding fflush after each write (this will commit the write to disk |
|
(\_ _/)
(='.'=)
(")_(")
the only other thing I can see, is the way you've stored the data size in the file header |
|
(\_ _/)
(='.'=)
(")_(")
Also, try changing |
|
Last edited by Ynot; 02-02-2008 at 06:07 PM.
(\_ _/)
(='.'=)
(")_(")
Yeah, append is actually going to break the file if the first run of the software wrote it correctly |
|
I tried both an "MB" and "BM" type header, neither one worked. |
|
Last edited by ninja9578; 02-02-2008 at 10:33 PM.
This will be useful for you: http://en.wikipedia.org/wiki/BMP_file_format |
|
I printed out the size of the information to be 1440056 and the Inspector says that the files are 1.4MB, so that checks out. |
|
Last edited by ninja9578; 02-03-2008 at 12:22 AM.
That's not good enough. |
|
|
|
Last edited by ninja9578; 02-03-2008 at 01:22 AM.
Don't just guess at it - look at your output file in a hex editor and figure out what's going on. Do it quick cause I'm getting antsy about knowing what happened |
|
I bet your int (bfSize) is what's misaligned. It comes after a short, so it probably wants to be off by 2 bytes. The rest works out fine. |
|
You were right about bfSize being offset by 2 bytes. To fix it I got rid of the struct and just used regular primatives, but it still didn't solve the problem. |
|
Probably because you don't have sizeof(bmpBuffer) in your code above |
|
In fact, here, I'll do it for you |
|
Whoops, that was something that I added later. My mistake. |
|
Last edited by ninja9578; 02-03-2008 at 07:39 PM.
Bookmarks