Thread: When I ask SDL for a hardware surface I don't get one

  1. #1
    Registered User
    Join Date
    Dec 2006

    When I ask SDL for a hardware surface I don't get one

    So to test out SDL I tried compiling the hello world program here:

    Made some changes for diagnostic reasons:
    SDL_Surface *screen;
    const SDL_VideoInfo* VideoInfo = SDL_GetVideoInfo();
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    printf("%u\n%u\n", screen->flags, VideoInfo->hw_available);
    Now according to the output I'm not getting SDL is unable to make screen a double buffered hardware surface.

    Is there something wrong with my computer that it won't give SDL a double buffered hardware surface when it asks for one? Or am I making an elementary mistake?

  2. #2
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Are you using Linux? If so then it's a normal thing. Linux's X system can't get a hardware surface. If not, then your graphics card doesn't support it.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  3. #3
    Registered User
    Join Date
    Dec 2006
    I'm running windows on a very new laptop. I also sent the program to my brother who ran it with the same result, and a few of my friends all running windows.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Presumably your laptop has 32-bit colour?

    I'm not sure if the SDL_GL_SetAttribute call is affecting your code at all. What happens if you remove it?

    Instead of checking if a hardware surface is available, why not check if you actually got one?
    if((screen->flags & SDL_HWSURFACE) == 0)
        printf("Can't get hardware surface\n");
    [BTW, you can get hardware surfaces under Linux if you don't use the X driver, apparently.
    Selecting The Driver
    The first change I had to make was to add some Linux specific code just before the call to SDL_Init():

    #ifdef __linux__
    #endifSDL checks the value of the SDL_VIDEODRIVER environment variable to decide which driver to use. To get hardware surfaces while running on Linux under X, you have to specify which driver to use. I've chosen the DGA driver because the default X11 driver does not support hardware surfaces. The SDL FAQ has more information about selecting drivers on Linux and Windows. There is also a detailed list of SDL environment variables and their use. The number of different drivers that you have to choose from is staggering and shows the range of applications for which SDL could be used.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5

    Join Date
    May 2005
    It's a very new laptop? Where did you put the installation files for SDL? That sounds like it could be an improperly installed dll.
    I'm not immature, I'm refined in the opposite direction.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SDL + Keys
    By Livijn in forum Game Programming
    Replies: 24
    Last Post: 05-11-2007, 04:31 PM
  2. Please help with my game
    By jjj93421 in forum Game Programming
    Replies: 10
    Last Post: 04-12-2004, 11:38 PM
  3. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. Game update...
    By jdinger in forum Game Programming
    Replies: 14
    Last Post: 11-08-2002, 07:10 AM