[SDL] SDL Hardware Acceleration on Linux

Abhishek Gupta enigma912in at gmail.com
Tue Apr 7 21:50:13 PDT 2009

Hi all,

I would like to be able to use SDL + OpenGL and get hardware rendering on
I believe there have been previous posts about this topic, but I cant seem
to be able to find a satisfactory answer.

According to the following posts, hardware rendering is not supported by SDL

(I tried using dga, but that resulted in SDL_Init(SDL_INIT_VIDEO) failing.)

And according to the following tutorial, SDL would use OpenGL's hardware
rendering, if I pass SDL_OPENGL as the flag in SDL_SetVideoMode:

So which is it? Can I get hardware acceleration with SDL or not?

I am using a Dell Inspiron 1525 laptop with Intel 965 express chipset
running Fedora 10.

Here is the output of lspci | grep -i vga:
00:02.0 VGA compatible controller: Intel Corporation Mobile GM965/GL960
Integrated Graphics Controller (rev 0c)

And here is the output of glxinfo | grep -i render:
direct rendering: Yes
OpenGL renderer string: Mesa DRI Intel(R) 965GM GEM 20080716 x86/MMX/SSE2

When I try to run the Nehe's SDL code (
http://nehe.gamedev.net/data/lessons/linuxsdl/lesson01.tar.gz), I get only a
software surface and hardware blits is  (blit_hw) is not available.
The relevant portion of code is shown below (I added the printfs to see what
is happening):

    videoInfo = SDL_GetVideoInfo( );

    if ( !videoInfo )
        fprintf( stderr, "Video query failed: %s\n",
             SDL_GetError( ) );
        Quit( 1 );

    /* the flags to pass to SDL_SetVideoMode */
    videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
    videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
    videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
    videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */

    /* This checks to see if surfaces can be stored in memory */
    if ( videoInfo->hw_available )
      printf("Hardware surface available\n");
    videoFlags |= SDL_HWSURFACE;
      printf("Software surface available\n");
    videoFlags |= SDL_SWSURFACE;

    /* This checks if hardware blits can be done */
    if ( videoInfo->blit_hw )
      printf("Hardware blits can be done\n");
    videoFlags |= SDL_HWACCEL;

And the output I get is:
Software surface available
973 frames in 5.001 seconds = 194.561 FPS

If I use the GLX version of the same tutorial (
http://nehe.gamedev.net/data/lessons/linuxglx/lesson01.tar.gz), I do get
hardware rendering
Relevant portion of the code:
if (glXIsDirect(GLWin.dpy, GLWin.ctx))
        printf("Congrats, you have Direct Rendering!\n");
        printf("Sorry, no Direct Rendering possible!\n");

I get the output "Congrats, you have Direct Rendering!\n" with this.

I would prefer to use SDL but I really want hardware acceleration.
Any help, pointers, tips are much appreciated.

Thanks and Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090408/f81556ab/attachment-0007.htm>

More information about the SDL mailing list