reassign 565638 libsdl1.2debian 1.2.13-5
retitle 565638 libsdl1.2: SDL_SetGamma() is nonfunctional with xorg 7.5
thanks

This bug has meanwhile migrated to testing, apparently triggered by the
update of xorg in testing from 7.4 to 7.5 (with xserver-xorg-core
updated from 1.6.5 to 1.7.4).

I have written a small SDL program testing the SDL_SetGamma() function,
and it works on a system with xorg 7.4, but silently fails do adjust the
gamma with xorg 7.5, so this is a bug in either libsdl or xorg.

Test program is attached.  For now, I'm reassigning this bug to libsdl.

Nikolaus
/* A small test program, testing the SDL_SetGamma() function.  Loads a test
 * image test.png in full screen; after a few seconds, the test image should
 * become brighter.  Compile with
 *
 *   gcc -o sdlgamma sdlgamma.c -I/usr/include/SDL 
 *      -D_GNU_SOURCE=1 -D_REENTRANT -L/usr/lib -lSDL -lSDL_image
 */
#include "SDL.h"   /* All SDL apps need this */
#include <stdio.h>
#include <stdlib.h> /* for exit() */
#include <SDL_image.h>

void display_bmp(char *file_name, SDL_Surface *screen)
{
    SDL_Surface *image;

    /* Load the BMP file into a surface */
    image = IMG_Load(file_name);
    if (image == NULL) {
      fprintf(stderr, "Couldn't load %s: %sn", file_name, SDL_GetError());
      return;
    }

    /*
    * Palettized screen modes will have a default palette (a standard
    * 8*8*4 colour cube), but if the image is palettized as well we can
    * use that palette for a nicer colour matching
    */
    if (image->format->palette && screen->format->palette) {
        SDL_SetColors(screen, image->format->palette->colors, 0, image->format->palette->ncolors);
    }

    /* Blit onto the screen surface */
    if(SDL_BlitSurface(image, NULL, screen, NULL) < 0)
      fprintf(stderr, "BlitSurface error: %sn", SDL_GetError());

    SDL_UpdateRect(screen, 0, 0, image->w, image->h);

    /* Free the allocated BMP surface */
    SDL_FreeSurface(image);
}

int main(int argc, char** argv) {
    
    printf("Initializing SDL.\n");
    
    /* Initialize defaults, Video and Audio subsystems */
    if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) { 
        printf("Could not initialize SDL: %s.\n", SDL_GetError());
        exit(-1);
    }

    printf("SDL initialized.\n");

    /* NS: Set video mode. */
    SDL_Surface* myVideoSurface = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF|SDL_FULLSCREEN);
    if (myVideoSurface == NULL) {
        printf("Could not set video mode: %s.\n", SDL_GetError());
        exit(-1);
    }

    display_bmp("test.png", myVideoSurface);

    sleep(5);

    /* NS: Try to set gamma values. */
    puts("Trying to set gamma values.");
    if ((SDL_SetGamma(1.8, 1.8, 1.8) == -1)) {
        printf("Could not set gamma: %s.\n", SDL_GetError());
        exit(-1);
    }
    puts("gamma values set.");
    sleep(5);
    puts("Trying to restore gamma values.");
    if ((SDL_SetGamma(1.0, 1.0, 1.0) == -1)) {
        printf("Could not set gamma: %s.\n", SDL_GetError());
        exit(-1);
    }
    puts("gamma values restored.");

    printf("Quitting SDL.\n");
    
    /* Shutdown all subsystems */
    SDL_Quit();
    
    printf("Quitting...\n");

    exit(0);
}

Reply via email to