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

Thread: Problem with SGIS_generate_mipmap

  1. #1
    Junior Member Newbie
    Join Date
    May 2002
    Location
    Iceland
    Posts
    15

    Problem with SGIS_generate_mipmap

    I'm having a little problem with this extension. The thing is that i doesn't seem to generate the alpha channels? Here's my code:

    Code :
    if(bGL_SGIS_generate_mipmap)
    {
    	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE );
    	if(bmpTexture->format->BytesPerPixel == 4)
    		glTexImage2D(GL_TEXTURE_2D, 0, (int)GL_RGBA, bmpTexture->w, bmpTexture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, bmpTexture->pixels);
    	else
    		glTexImage2D(GL_TEXTURE_2D, 0, (int)GL_RGB, bmpTexture->w, bmpTexture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, bmpTexture->pixels);
    }
    else
    {
    	if(bmpTexture->format->BytesPerPixel == 4)
    		gluBuild2DMipmaps(GL_TEXTURE_2D, (int)GL_RGBA, bmpTexture->w, bmpTexture->h, GL_RGBA, GL_UNSIGNED_BYTE, bmpTexture->pixels);
    	else
    		gluBuild2DMipmaps(GL_TEXTURE_2D, (int)GL_RGB, bmpTexture->w, bmpTexture->h, GL_RGB, GL_UNSIGNED_BYTE, bmpTexture->pixels);
    }
    If i just do the gluBuild2DMipmaps everything goes as expected! Any ideas?
    This is a damn cool signature

  2. #2
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,444

    Re: Problem with SGIS_generate_mipmap

    I don't think this is the problem, but I'd use

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, bmpTexture->w, bmpTexture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, bmpTexture->pixels);

    instead.

  3. #3
    Junior Member Newbie
    Join Date
    May 2002
    Location
    Iceland
    Posts
    15

    Re: Problem with SGIS_generate_mipmap

    Thanks for the reply although i noticed something.

    Dumb me didn't debug enough before i posted this and i found out that the alpha channel part is actually working, but it's the one that doesn't have an alpha channel (GL_RGB) that's not working. That texture just ends up grey?
    This is a damn cool signature

  4. #4
    Junior Member Newbie
    Join Date
    May 2002
    Location
    Iceland
    Posts
    15

    Re: Problem with SGIS_generate_mipmap

    Ok.. i tried running my demo with MESA and it still has the same problems, so the bug must be in my code.

    A can not imagine as to why gluBuild2DMipmaps works fine but glTexImage2D doesn't when they're using the exact same parameters. As before, the problems seems to appear with textures that have 3 bytes per pixel (RGB) but 4 bytes per pixel (RGBA) work perfectly fine.

    If anyone has any suggestions as to why this happens then please let me know.

    Thanks.
    This is a damn cool signature

  5. #5
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: Problem with SGIS_generate_mipmap

    What size is your rgb bmp image?

    The glubuild function will scale non power of two images.

  6. #6
    Junior Member Newbie
    Join Date
    May 2002
    Location
    Iceland
    Posts
    15

    Re: Problem with SGIS_generate_mipmap

    hmm.. it was 1000x500, which was the problem. I rescaled it to 1024x512 and it worked fine then.

    Thanks for the tip
    This is a damn cool signature

Posting Permissions

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