[SDL] I'm losing detail with SDL_Image

Glenn McCord clari_player at paradise.net.nz
Mon Sep 4 05:37:04 PDT 2006

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_MIN_FILTER, 
        gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, temp->w, temp->h, 
GL_RGBA, GL_UNSIGNED_BYTE, temp->pixels);
        return 1;

    //free the temp surface if it was used

    return image;

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



More information about the SDL mailing list