Hw acceleration and x11

Hey all!

I’ve been trying to get my sdl program to use hw acceleration under X11
(redhat 7.3, Xfree 4.2.0, geforce3 with 64mb), and I have to admit I am a
bit confused. Please correct me if I’m wrong, but the way I understand
things you can’t have hw acceleration with x11 (which only gives you access
to sw surface), UNLESS you use other driver types, such as DGA. Now, the
downside of dga is that you need to be root (which, in terms of security,
makes sense, but is a real pain in the butt), and that I can’t get it to
work. Querying SDL tells me that it’s very happy to have hw acceleration and
64mb of mem to use, but some reason I cannot get a hw surface. The strange
thing being that if i use sw surface (that is i do not set
SDL_VIDEODRIVER=dga), it all works nicely. So, my question is: what am I
doing wrong?? and what kind of performance gains should I expect if I get
the hw accel to work (i.e: is the use of dga with its root access issue
worth all that effort?)?

Thanx a bunch for any help/pointers/sample code known to work with dga.

Cheers,

Yves

As a reference, here’s my pixel format function:

void SetupPixelFormat(void)
{
//////// SURFACE IS THE DRAWABLE PORTION OF AN SDL WINDOW \\\\*

cout << “Setting up the SDL config:” << endl;

/////////////  we set the common flags here
VideoFlags    = SDL_OPENGL;                         // it's an openGL

Window
VideoFlags |= SDL_HWPALETTE; // exclusive access
to hardware colour palette
VideoFlags |= SDL_RESIZABLE; // the window must
be resizeable

const SDL_VideoInfo * VideoInfo = SDL_GetVideoInfo();     // query SDL

for information about our video hardware

if(VideoInfo == NULL)                                     // if this

query fails
{
cerr << "Failed getting Video Info : " << SDL_GetError() << endl;
// report error
Quit(0);
}

///////////// we set the system dependant flags here
if(VideoInfo -> hw_available){                      // is it a hardware

surface
VideoFlags |= SDL_HWSURFACE;
cout << “good, we do have hw surface…” << endl;
// Blitting is fast copying / moving /swapping of contiguous sections of
memory
// for more about blitting check out :
http://www.csc.liv.ac.uk/~fish/HTML/blitzman/bm_blitter.html
if(VideoInfo -> blit_hw){ // is hardware
blitting available
VideoFlags |= SDL_HWACCEL;
cout << “we have hw blitting” << endl;
}else{
cout << “damn, we only have sw blitting…” << endl;
}

//cout << "Amount of available video memory: " << VideoInfo -> video_mem

<< endl;
printf(“Amount of available video memory (in KB): %u \n”, VideoInfo ->
video_mem);

SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );      // tell SDL that the

GL drawing is going to be double buffered
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, SCREEN_DEPTH); // size
of depth buffer
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); // we aren’t going
to use the stencil buffer
SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0); // this and the next
three lines set the bits allocated per pixel -
SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0); // - for the
accumulation buffer to 0
SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);

cout << "ahha, we are at the end of setuppixformat..." << endl;

}

now, once this is setup (and sofar happy to use DGA), I try to create my
window this way:

void CreateMyWindow(const char * strWindowName, int width, int height, int
VideoFlags)
{
MainWindow = SDL_SetVideoMode(width, height, SCREEN_DEPTH, VideoFlags);
// SCREEN_DEPTH is macro for bits per pixel

if( MainWindow == NULL )                            // if window

creation failed
{
cerr << "Failed to Create Window : " << SDL_GetError() << endl;
// report error <= this is where i exit
Quit(0);
}

SDL_WM_SetCaption(strWindowName, "BSP_LOADER");  // set the window

caption (first argument) and icon caption (2nd arg)

}

the thing is that SDL_SetVideoMode() returns NULL, which means that I do not
havea surface… and the subsequent SDL_GetError() doesn’t give anything.