I'm losing detail with SDL_Image

I made these really nice looking .png images with shading and drop
shadows. I’m using them to make a menu for my application.

But when I texture map them with the help of SDL_Image I lose a lot of
detail. It’s quite pixelated and my drop shadows have disappeared. The
size of the textured objects on screen are fairly close to the actual
size of the image.

Is this just a limitation or is there a texturing technique that I’ve
missed? Nearest filtering and mipmapping give the same results.

GLuint loadTexture(char *fileName)
{
GLuint image;
SDL_Surface *temp; //Used for getting pixel data for the texture

//Begin creating the texture
if( (temp = IMG_Load(fileName)) )
{

    //check that the image's width is valid then check that the 

image’s width is a power of 2
if(temp->w < 1)
return 1;
else if( !((temp->w & (temp->w-1))==0) )
{
return 1;
}

    //Create the texture
    glGenTextures(1, &image);

    //Load the texture
    glBindTexture(GL_TEXTURE_2D, image);

    //Use mipmaps
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 

GL_NEAREST_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, temp->w, temp->h,
GL_RGBA, GL_UNSIGNED_BYTE, temp->pixels);

}
else
    return 1;

//free the temp surface if it was used
if(temp)
    SDL_FreeSurface(temp);

return image;

}

This is all very superficial but it doesn’t hurt to have an app that
looks pretty.

Cheers,

Glenn

Mipmapping could explain the pixelated part, but if you’ve really
ruled that out, I have no idea… Well, try not building the mipmaps
at all, just in case! Unless you’re actually using mipmapping, the
original texture should be all you need.

Are you sure the drop shadows and stuff are actually in the .png? Some
applications have somewhat strange default settings when exporting to
foreign file formats, so perhaps you’re losing some layers and/or the
alpha channel in the export process. I also have a faint memory of
some version of GIMP I used screwing up when exporting multilayered
images, so I had to manually merge down to a single layer first.

What’s the OpenGL blend function you’re using for rendering?

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Monday 04 September 2006 14:37, Glenn McCord wrote:

I made these really nice looking .png images with shading and drop
shadows. I’m using them to make a menu for my application.

But when I texture map them with the help of SDL_Image I lose a lot
of detail. It’s quite pixelated and my drop shadows have
disappeared. The size of the textured objects on screen are fairly
close to the actual size of the image.

Is this just a limitation or is there a texturing technique that
I’ve missed? Nearest filtering and mipmapping give the same results.

Thanks, David. You said the magic words “What’s the OpenGL blend
function you’re using for rendering?” and after some googling found

I was happy to find the following code because it took me ages to get
transparecy to work.
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);

but I should have been using

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

And now it is all sorted

Thanks,

Glenn

David Olofson wrote:>On Monday 04 September 2006 14:37, Glenn McCord wrote:

I made these really nice looking .png images with shading and drop
shadows. I’m using them to make a menu for my application.

But when I texture map them with the help of SDL_Image I lose a lot
of detail. It’s quite pixelated and my drop shadows have
disappeared. The size of the textured objects on screen are fairly
close to the actual size of the image.

Is this just a limitation or is there a texturing technique that
I’ve missed? Nearest filtering and mipmapping give the same results.

Mipmapping could explain the pixelated part, but if you’ve really
ruled that out, I have no idea… Well, try not building the mipmaps
at all, just in case! Unless you’re actually using mipmapping, the
original texture should be all you need.

Are you sure the drop shadows and stuff are actually in the .png? Some
applications have somewhat strange default settings when exporting to
foreign file formats, so perhaps you’re losing some layers and/or the
alpha channel in the export process. I also have a faint memory of
some version of GIMP I used screwing up when exporting multilayered
images, so I had to manually merge down to a single layer first.

What’s the OpenGL blend function you’re using for rendering?

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --’


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl