Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

texture binding with opengl

Options
  • 05-12-2003 5:01pm
    #1
    Closed Accounts Posts: 222 ✭✭


    I've hacked abit of code that was mean't to read in one file... and tried to make it read 7... now it compiles fine... but the textures don't display at all.... I tried stepping into it and got as far as ...return auxDIBImageLoad(Filename); ... but then it looks for image.c .... what is this and where is it hiding????
    I really just need an external viewpoint ... my head is adeled and I'd really appricate an opinion... cheers.



    AUX_RGBImageRec *LoadBMP(char *Filename)
    {
    FILE *File=NULL;
    if (!Filename)
    {
    return NULL;
    }
    File=fopen(Filename,"r");

    if (File)
    {
    fclose(File);
    return auxDIBImageLoad(Filename);
    }
    return NULL;
    }

    int LoadGLTextures()
    {
    int Status=FALSE;
    AUX_RGBImageRec *TextureImage[7];
    memset(TextureImage,0,sizeof(void *)*1);
    if ((TextureImage[0]=LoadBMP("blue.bmp"))
    &&(TextureImage[1]=LoadBMP("green.bmp"))
    &&(TextureImage[2]=LoadBMP("orange.bmp"))
    &&(TextureImage[3]=LoadBMP("red.bmp"))
    &&(TextureImage[4]=LoadBMP("yellow.bmp"))
    &&(TextureImage[5]=LoadBMP("white.bmp"))
    &&(TextureImage[6]=LoadBMP("black.bmp"))
    )
    {
    for(int i=0; i<7; i++)
    {

    Status=TRUE;
    glGenTextures(i+1, &texture);

    glBindTexture(GL_TEXTURE_2D, texture);
    glGenTextures(i+1, &texture);

    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, i+1, 3, TextureImage->sizeX,
    TextureImage->sizeY, i+1, GL_RGB, GL_UNSIGNED_BYTE,
    TextureImage->data);

    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

    if (TextureImage)
    {
    if (TextureImage->data)
    {
    free(TextureImage->data);
    }

    free(TextureImage);
    }
    }
    }
    return Status;
    }


Comments

  • Registered Users Posts: 1,481 ✭✭✭satchmo


    I don't have time to look at it properly, but there's 2 problems I can see at the moment.. the first parameter to glGenTextures() specifies the amount of texture IDs you want to generate. Since you're doing this in a loop then this should be 1, not i+1.

    The other problem (a likely candidate for why your texture isn't appearing) is the parameters for glTexImage2D are wrong. The second parameter specifies the mipmap level you're uploading, which should be 0 and not i+1 if you're just doing a normal texture without mipmapping, which you're probably are. That, and the 6th parameter specifies if you want a border around the texture, and should be 0 or 1 (You really have a hard-on for i+1 don't you?!).

    Oh and make sure your texture is square and a power of 2. (64x64, 128x128, 256x256 etc)


  • Closed Accounts Posts: 222 ✭✭The Second


    (You really have a hard-on for i+1 don't you?!).

    of course! its not as much fun with just i on my own!?!

    Jazz.. yet again you are the light at the end my my prgramming tunnel... it works fine now...

    THANK YOU :D


Advertisement