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

This is a discussion on When I ask SDL for a hardware surface I don't get one within the Game Programming forums, part of the General Programming Boards category; So to test out SDL I tried compiling the hello world program here: http://cone3d.gamedev.net/cgi-bin/in...ls/gfxsdl/tut1 Made some changes for diagnostic reasons: ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    19

    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: http://cone3d.gamedev.net/cgi-bin/in...ls/gfxsdl/tut1

    Made some changes for diagnostic reasons:
    Code:
    SDL_Surface *screen;
    const SDL_VideoInfo* VideoInfo = SDL_GetVideoInfo();
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    screen = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN);
    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?
    Attached Files Attached Files

  2. #2
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    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
    Posts
    19
    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
    Location
    Canada
    Posts
    8,046
    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?
    Code:
    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. http://www.linuxdevcenter.com/pub/a/.../sdl_anim.html
    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__
    putenv("SDL_VIDEODRIVER=dga");
    #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.
    ]
    dwk

    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: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5

    Join Date
    May 2005
    Posts
    1,041
    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, 06: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, 06:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21