Problems with DGA driver and hardware video surface

When I set SDL_VIDEODRIVER to ‘dga’ and pass SDL_HWSURFACE and
SDL_DOUBLEBUF to SDL_SetVideoMode I have some problems:

  1. The mouse cursor is invisible. If you know where the cursor is you
    can still move the imaginary cursor about and click on things, you just
    can’t see it.

I’ve queried SDL_ShowCursor and it definitely is on. Specifically
setting a custom cursor doesn’t solve the problem, either.

However, if I turn off double buffering, the cursor becomes visible
again (albeit rather messily given the flicker that writing directly to
the video display causes).

Is double buffering overwriting the cursor image or something? If so,
how can I stop it from doing as such? I mean, I could manually blit the
cursor image to the cursor position each frame, but surely that’s not
necessary?

  1. Whilst the main menu of my game runs fine when I’m using a hardware
    video surface, with or without double buffering (the former minus a
    mouse cursor, the latter with rather a lot of flickering), the actual
    game itself crashes as soon as you click “new game” with a segmentation
    fault.

However, I can’t debug this because programs don’t like being
interrupted when they are in direct control of the video memory -
setting the debugger on it just causes the computer to freeze up.

If I change to using a software video buffer then I can use the
debugger, but then it doesn’t crash…

Thanks,

James

When I set SDL_VIDEODRIVER to ‘dga’ and pass SDL_HWSURFACE and
SDL_DOUBLEBUF to SDL_SetVideoMode I have some problems:

  1. The mouse cursor is invisible. If you know where the cursor is you
    can still move the imaginary cursor about and click on things, you just
    can’t see it.

I’ve queried SDL_ShowCursor and it definitely is on. Specifically
setting a custom cursor doesn’t solve the problem, either.

However, if I turn off double buffering, the cursor becomes visible
again (albeit rather messily given the flicker that writing directly to
the video display causes).

Is double buffering overwriting the cursor image or something? If so,
how can I stop it from doing as such? I mean, I could manually blit the
cursor image to the cursor position each frame, but surely that’s not
necessary?

  1. Whilst the main menu of my game runs fine when I’m using a hardware
    video surface, with or without double buffering (the former minus a
    mouse cursor, the latter with rather a lot of flickering), the actual
    game itself crashes as soon as you click “new game” with a segmentation
    fault.

Problem two I have solved via the incredibly time consuming method of
having the program write to stderr at different points and constantly
recompiling and running to find where the problem was. The problem was
that I was treating a surface’s pixels as a char* when actually the
pointer type depends on the pixel format.

Still need help with problem (1), though.

JamesOn Sun, 01 Feb 2004 19:13:05 +0000, James Gregory wrote:

When I set SDL_VIDEODRIVER to ‘dga’ and pass SDL_HWSURFACE and
SDL_DOUBLEBUF to SDL_SetVideoMode I have some problems:

  1. The mouse cursor is invisible. If you know where the cursor is you
    can still move the imaginary cursor about and click on things, you just
    can’t see it.

I’ve queried SDL_ShowCursor and it definitely is on. Specifically
setting a custom cursor doesn’t solve the problem, either.

However, if I turn off double buffering, the cursor becomes visible
again (albeit rather messily given the flicker that writing directly to
the video display causes).

Is double buffering overwriting the cursor image or something? If so,
how can I stop it from doing as such? I mean, I could manually blit the
cursor image to the cursor position each frame, but surely that’s not
necessary?

To make this a bit clearer:

  • Not using DGA driver (implying software surface and no double buffering):

no problems

  • Using DGA driver with software surface and no double buffering:

no problems

  • Using DGA driver with hardware surface and no double buffering:

whole screen flickers a lot, cursor also flickers a lot and is invisible
more often than not

  • Using DGA driver with hardware surface and double buffering:

mouse cursor is totally invisible

  • Using DGA driver with “software surface” and double buffering.
    I assume SDL automatically interprets the “use double buffering” as “use
    hardware surface as well” as it makes no sense to demand double buffering
    with a software surface. But I include this possiblity for completeness.

mouse cursor is totally invisible

JamesOn Sun, 01 Feb 2004 19:13:05 +0000, James Gregory wrote:

To make this a bit clearer:

  • Not using DGA driver (implying software surface and no double buffering):

no problems

  • Using DGA driver with software surface and no double buffering:

no problems

  • Using DGA driver with hardware surface and no double buffering:

whole screen flickers a lot, cursor also flickers a lot and is invisible
more often than not

  • Using DGA driver with hardware surface and double buffering:

mouse cursor is totally invisible

  • Using DGA driver with “software surface” and double buffering.
    I assume SDL automatically interprets the “use double buffering” as “use
    hardware surface as well” as it makes no sense to demand double buffering
    with a software surface. But I include this possiblity for completeness.

mouse cursor is totally invisible

OK, I now draw the mouse cursor with a manual blit each frame.

However, the mouse cursor is only travelling at half (and I’d hazard a
guess and say it’s probably exactly half) its usual speed.

There’s definitely some sort of issue with whatever it is that controls
the mouse getting confused by double buffering.

JamesOn Mon, 02 Feb 2004 17:44:24 +0000, James Gregory wrote:

La-la-la replying to myself.

According to some XFree86 guy the mouse cursor is not supposed to be
displayed in DGA mode.

Looking at the SDL source code it appears that SDL leaves drawing the
cursor to the window manager where possible, but includes code for drawing
it itself when the window manager isn’t doing it.

It appears that there is a problem with SDL’s “draw it myself”, however,
when DGA + page flipping enabled.

I don’t really have the requisite knowledge to patch the SDL source
myself - indeed the reason I use SDL is because it generally allows me not
to worry about the lower level implementation of displaying graphics.

Should I add this as a bug report somewhere? Or alternatively,
could there at least be a mention of this fact (SDL fails to display
a cursor in DGA mode with page flipping enabled) in the SDL documentation?

Plus I still don’t know what to do about the half-speed mouse motion…

JamesOn Tue, 03 Feb 2004 00:06:09 +0000, James Gregory wrote:

hey james, whats happening with the half speed mouse motion?

i missed that part in your earlier posts> ----- Original Message -----

From: jamesg@f2s.com (James Gregory)
To:
Sent: Monday, February 02, 2004 5:09 PM
Subject: [SDL] Re: Problems with DGA driver and hardware video surface

On Tue, 03 Feb 2004 00:06:09 +0000, James Gregory wrote:

La-la-la replying to myself.

According to some XFree86 guy the mouse cursor is not supposed to be
displayed in DGA mode.

Looking at the SDL source code it appears that SDL leaves drawing the
cursor to the window manager where possible, but includes code for drawing
it itself when the window manager isn’t doing it.

It appears that there is a problem with SDL’s “draw it myself”, however,
when DGA + page flipping enabled.

I don’t really have the requisite knowledge to patch the SDL source
myself - indeed the reason I use SDL is because it generally allows me not
to worry about the lower level implementation of displaying graphics.

Should I add this as a bug report somewhere? Or alternatively,
could there at least be a mention of this fact (SDL fails to display
a cursor in DGA mode with page flipping enabled) in the SDL documentation?

Plus I still don’t know what to do about the half-speed mouse motion…

James


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

hey james, whats happening with the half speed mouse motion?

i missed that part in your earlier posts

I’m now manually blitting a mouse cursor picture to the position
reported by SDL_GetMouseState each frame.

However, a given amount of mouse motion only moves the cursor half the
distance it travels when double buffering is turned off.

JamesOn Mon, 02 Feb 2004 18:43:29 -0800, Alan Wolfe wrote:

According to some XFree86 guy the mouse cursor is not supposed to be
displayed in DGA mode.

Looking at the SDL source code it appears that SDL leaves drawing the
cursor to the window manager where possible, but includes code for drawing
it itself when the window manager isn’t doing it.

It appears that there is a problem with SDL’s “draw it myself”, however,
when DGA + page flipping enabled.

That’s correct. When you’re drawing directly to video memory, SDL has no
way of drawing the mouse cursor without corrupting your image without your
knowledge. I haven’t found a really good way around this, so for now if
you get SDL_HWSURFACE, you’ll need to draw the cursor yourself. If this
isn’t in the FAQ, I need to add it.

Plus I still don’t know what to do about the half-speed mouse motion…

The X server tends to provide mouse acceleration which isn’t present when
you’re using the DGA driver. In DGA mode, the X server sends raw mouse
events without doing any post-processing (to modify speed, etc.)

We could query the X server for the mouse acceleration options and use
those to modify the DGA mouse events…

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

According to some XFree86 guy the mouse cursor is not supposed to be
displayed in DGA mode.

Looking at the SDL source code it appears that SDL leaves drawing the
cursor to the window manager where possible, but includes code for drawing
it itself when the window manager isn’t doing it.

It appears that there is a problem with SDL’s “draw it myself”, however,
when DGA + page flipping enabled.

That’s correct. When you’re drawing directly to video memory, SDL has no
way of drawing the mouse cursor without corrupting your image without your
knowledge.

OK…though it’s made more confusing by the fact that SDL nevertheless
draws a cursor when you are using a hardware surface but not using page
flipping. Though of course I can’t think of any reason why you’d ever want
to do that…

I haven’t found a really good way around this, so for now if
you get SDL_HWSURFACE,

Could it not be made such that the SDL_Flip function automatically calls
the SDL “Draw cursor” function when using a hardware surface?

you’ll need to draw the cursor yourself.

OK, am doing.

If this isn’t in the FAQ, I
need to add it.

OK, thanks…

Plus I still don’t know what to do about the half-speed mouse motion…

The X server tends to provide mouse acceleration which isn’t present
when you’re using the DGA driver. In DGA mode, the X server sends raw
mouse events without doing any post-processing (to modify speed, etc.)

Oh, I see.

We could query the X server for the mouse acceleration options and use
those to modify the DGA mouse events…

That’d be nice…

Thanks, and see ya,

JamesOn Tue, 03 Feb 2004 13:10:22 -0800, Sam Lantinga wrote: