# Lesson6 help needed, using GLUT

This topic is 3734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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...

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
Quote:
 Original post by Sanzenninhow 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.

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 33
• ### Forum Statistics

• Total Topics
632631
• Total Posts
3007538
• ### Who's Online (See full list)

There are no registered users currently online

×