Using TGA files as a map to create a 3d house

Hello everybody!

I have a question for you.
I have to make a program that takes a TGA image ( an house plan ) create with that image the house using the color information.

I allready have a way to read a TGA and I have a method( called pixels() ) that returns the pointer to the memory area that has the information on the pixels stored as an RGB.

The question is, how can I turn this info into the geometry?

Let’s say have the initialization method on wich I load the TGA file called img.

Than I probly will use the method img.pixels() to load the info about the RGB colors, something like this:

*punt = img.pixel();
array[0] = punt;
array[1] = (punt+1);
array[2] = (punt+2);
//every memory cell has his int(from 0 to 255) value and they are stored like this: RGBRGBRGBRGB…

The problem is that of course I don’t have this variable img declared on the display method tha I use to “draw”…

How can I handle this?

Thanks for your help and sorry for my english.

You need to ask your instructor for details on what he wants you to do. Sounds like he wants you to learn how to create the geometry for the house and texture it with the provided texture. But that’s not crystal clear from your description. Your instructor should be much more helpful.

Yes it’s like that.
I need to take the info from the tga file and for every pixel I must create a parallelepipedon if it is red, nothing if it is black ecc ecc…

Now I have another problem… I have something like this:

CGU::TGAImg img; //declared globally

img.load(“foo.tga”); //into the init method

and then into display method:
printf ("%i", *img.pixels());

that returns 00 but of course is not the value of the pixel…

Probably I need to use the glReadPixels but I’m not sure