Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

texture binding with opengl

  • 05-12-2003 04: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, Registered Users 2 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