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 2 of 2

Thread: problem with glTexImage2D()

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2002
    Posts
    12

    problem with glTexImage2D()

    Guys, i need your help on glTexImage2D()

    Here are my codes snipet to load .bmp textures:

    BitmapStruct TextureImage;
    bitmap(name, &TextureImage);

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glGenTextures(1, &texture[0]);

    glBindTexture(GL_TEXTURE_2D, texture[0]);

    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_NEAREST);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);

    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage.Width, TextureImage.Height, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.Pixels);

    if (TextureImage.Pixels)
    free(TextureImage.Pixels);

    Here is how i use the textures:
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture[0]);

    The codes above works fine. The textures apear as expected.
    But when i replace gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage.Width, TextureImage.Height, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.Pixels);
    with glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TextureImage.Width, TextureImage.Height, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.Pixels);
    because i do not want to do mipmapping, my objects does not have any textures. I just dunno what is wrong.

    [This message has been edited by dilectio (edited 11-21-2002).]

  2. #2
    Intern Newbie
    Join Date
    Jan 2002
    Posts
    32

    Re: problem with glTexImage2D()

    You also need to change
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_NEAREST);
    to
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

    to disable mipmapping.

Posting Permissions

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