Advertisement

Lesson6 help needed, using GLUT

Started by July 04, 2008 05:10 AM
2 comments, last by lc_overlord 16 years, 7 months ago
Okey, so the glut code for the lesson is a bit... well, I could figure nice part of it by reading reference pages, (thus sending people to read reference pages in tutorial kinda nullifies the purpose, now doesn't it?) Im curious, what exactly does this sz = (((3*refimg->w+3)>>2)<<2)*refimg->h; refimg->data = new GLubyte [sz]; part of the code do? the first row, the second I understand. Im trying to modify the code for bmp files, and no, Im not going to use some library handed down for me. That isnt learning. Im going to use the 3rdy party library later, after I understand how things work. also, I quite didnt get why fsize == (long)sz; is so important? I get error if it isn't...
Would be nice if you could post the link to this lesson.
Quote:

sz = (((3*refimg->w+3)>>2)<<2)*refimg->h;


This codes modifies the reference images width by scaling and offseting and then it truncates least significant bits. I think it calculates the size of an rgb image in some weird way. Why the truncation is necessary i would have to play around with it a little bit.

Quote:
fsize == (long)sz;
is so important?
I get error if it isn't...

sz is the size of the image and as long as fsize (file size for writing the image?) is greater than the image size, everything is fine. Otherwise you get segmentation faults because of array out of bounds indexing.

h.
Advertisement
Okey, so (if I forgot to mention, lesson6, using GLUT, "Game GLUT" file)

the first bit could have been done in some less weird way?

and I why does the code, Im not going to quote it in whole here, http://nehe.gamedev.net/data/lessons/glut/lesson06.zip thats the link for the file, work for raw files, but not bmp's? someone said something about the difference between those files, but I quite didnt get it...

how are bmps and raws different?



also, I noticed that the code works for bmp's no broblem, as long as I set the fsize to be sz... I assume that that is not too good idea, but well, it works :P
Quote:
Original post by Sanzennin
how are bmps and raws different?

Bmp is a image format it contains all kinds of data about the image, like size, colordepth, palettes and other stuff.
Raw does not, it is usually just raw(as the name suggests)pixel data, but it could also contain a header that defines it, however it is not a standardized format, thus making a raw loader difficult to write.

My suggestion is, skip bmp and raw altogether and start with TGA directly, lessons 24 and 33.

This topic is closed to new replies.

Advertisement