Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

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

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    4

    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.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,213
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    4
    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
    Last edited by settra88; 10-23-2012 at 07:07 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •