Thread: Arrrg

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    55
    Rep Power
    12

    Arrrg


    I think the problem is with loading the file name into the image variable. Can anyone see why this won't load? (ie what I have to change about char image[] = { "C:/Documents and Settings/User/My Documents/My Pictures/aaliya.bmp" };
    -

    #define BITMAP_ID 0x4D42
    BITMAPINFOHEADER bitmapInfoHeader;
    unsigned char *bitmapData;
    unsigned int texture;
    unsigned char *LoadBitmapFile(char *filename, BITMAPINFOHEADER *bitmapInfoHeader);

    bool InitializeGL()
    {
    // Add to the status report that we are starting initialization. If
    // the program crashed here we would know this was the function that
    // caused a problem.
    cout << "Starting Initialization...\n\n";

    int PopUp;

    // I decided to place the texture image name in a variable. This
    // way if there was a problem with it (this is only useful if
    // there was more than one) the name of the texture will be printed
    // to the console screen along with a error message. I printed to
    // the console screen instead of using MessageBoxes because I think
    // its cooler.
    char image[] = { "C:/Documents and Settings/User/My Documents/My Pictures/aaliya.bmp" };
    // Enable texture mapping by sending GL_TEXTURE_2D to glEnable().
    glEnable(GL_TEXTURE_2D);

    // Now we load the image into memory.
    // The line below shows why I decided to place the texture image name in a variable.
    cout << "Loading image file " << image << " ...\n";

    // Load the bitmap image into our global variable bitmapData.
    bitmapData = LoadBitmapFile(image, &bitmapInfoHeader);

    // If there was any errors then print this error message to the console screen.
    if(!bitmapData)
    {
    cout << "Loading image " << image << " failed (check if file exist)...\n\n";
    free(bitmapData);
    return false;
    }

    // Next you must generate the texture in OpenGL.
    glGenTextures(1, &texture);

    // Lastly you bind the texture to the variable texture.
    glBindTexture(GL_TEXTURE_2D, texture);
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    What error message are you getting?

    Also, your subject title in unappropriate. You can refer to the sticky thread at the top of this forum for more information on how to post a question.

IMN logo majestic logo threadwatch logo seochat tools logo