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: Mipmapping Problem

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    6

    Mipmapping Problem

    I'm using the following code to draw a 256x256 .tga texture and it works just fine:

    Code :
    ....
     
    for(int n = 0; n < 1; n++){
    LoadTGA(&amp;texture[n], texname[n]);
    glGenTextures(1, &amp;texture[n].texID);
    glBindTexture(GL_TEXTURE_2D, texture[n].texID);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texture[n].width, texture[n].height, GL_RGB, GL_UNSIGNED_BYTE, texture[n].imageData);}
     
    ....
     
    glBindTexture(GL_TEXTURE_2D, texture[0].texID);
    glBegin(GL_QUADS);
     
    int c[][3] = {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {1, 1, 0}, {0, 0, 1}, {1, 0, 1}, {0, 1, 1}, {1, 1, 1}};
    int p[][4] = {{4, 5, 7, 6}, {4, 6, 2, 0}, {7, 5, 1, 3}, {5, 4, 0, 1}, {6, 7, 3, 2}};
     
    for(int a = 0; a < 4; a++){
    glTexCoord2f(a%3 > 0, a < 2);
    glVertex3f((a%3 > 0)*256, c[p[0][a]][1]*256, 0);}
     
    glEnd();
     
    ....

    Now when I use a 220x204 texture (with glVertex3f((a%3 > 0)*220, c[p[0][a]][1]*204, 0); ), it comes out all blurry: see the attached pictures. My guess was that this is a mipmapping issue and that gluBuild2DMipmaps was supposed to fix it, but it doesn't.
    So what am I doing wrong? It's probably a simple mistake since I'm quite a newbie.
    Thanks in advance.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985

    Re: Mipmapping Problem

    As far as I know, gluBuild2DMipmaps doesn't work with non-power-of-two sized textures. You should rather use glGenerateMipmap.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    6

    Re: Mipmapping Problem

    That works; thank you!

Posting Permissions

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