I’m developping an SDL app on win2K. It’s working quite nicely, but i’ve
been reported a strange bug : some flikker tends to appear on some
computers. I first thought that must be because i don’t refresh the screen
correctly and this bug appears on video cards that doesn’t support the
SDL_DOUBLEBUF flag. After investigating, i found that this bug appears
wether the SDL_DOUBLEBUF flag is set or not. After further investigation, i
found that this bug only appears when SDL uses the diectx driver, while it’s
ok in windib.
The bug also prevents the mouse cursor from being cleared at every frame ->
???
I guess most of the SDL apps running under windows uses the directx driver,
so i must have missed something.
Does any of you had this strange behavior? Is it a common mistake? how can i
fix it?
thx
Alex
Alexis wrote:
I’m developping an SDL app on win2K. It’s working quite nicely, but
i’ve been reported a strange bug : some flikker tends to appear on
some computers.
Are you sure you don’t just have VSYNC turned off in your display
driver?–
Kylotan
http://pages.eidosnet.co.uk/kylotan
Are you sure you don’t just have VSYNC turned off in your display
driver?
After further investigation, it seems this problem only occurs while using
the directx driver (it works fine with windib).
I’ve got the same problem described in http://sdldoc.csn.ul.ie/sdlflip.php
and don’t know how to fix it. I’d add that it doesn’t look better whether
the SDL_DOUBLEBUF flag is enabled or not.
On the other hand, i don’t know either how to “turn on VSYNC in my display
driver” and i can’t say to my user "go in the panel tab click on… etc. to
be able to run the app."
If there’s something to setup, my program should do it by itself and restore
the initial state before quitting.
any idea? thx
Alex
Alexis wrote:
Are you sure you don’t just have VSYNC turned off in your display
driver?
After further investigation, it seems this problem only occurs while
using the directx driver (it works fine with windib).
I’ve got the same problem described in
http://sdldoc.csn.ul.ie/sdlflip.php and don’t know how to fix it. I’d
add that it doesn’t look better whether the SDL_DOUBLEBUF flag is
enabled or not.
What about SDL_HWSURFACE - are you in hardware or software? And does it
matter?
On the other hand, i don’t know either how to “turn on VSYNC in my
display driver” and i can’t say to my user "go in the panel tab click
on… etc. to be able to run the app."
If there’s something to setup, my program should do it by itself and
restore the initial state before quitting.
The problem is that a lot of users - and some manufacturers, so I hear -
set their drivers to have Vsync off by default so that they get better
frame rates and benchmark scores. Waiting for the vsync slows the system
down to gain some image quality - ie. to avoid flickering or ‘tearing’.
Turning this back on - if indeed it is the problem - is probably not
something a user program like SDL can do, especially not on the more
recent versions of Windows that attempt some sort of rudimentary
security…–
Kylotan
http://pages.eidosnet.co.uk/kylotan
In order to solve this damn thing, i tried to find a solution with emailing
2 developers who had the same issue a few months ago. Here is their answer.> ----- Original Message -----
From: "Ephrim Khong"
To: "Alexis"
Sent: Wednesday, August 21, 2002 5:34 PM
Subject: Re: SDL VSYNC issue
Alexis schrieb:
I apologize for this little unsolicited email, but for once it’s NOT
spam! 
I’m developing an app using SDL, i’m having a serious issue with it
and running out of ideas i’ve decided to send you this message.
I found you address on the online SDL Doc Project, on the page :
http://sdldoc.csn.ul.ie/sdlflip.php
and it seems you both add a few mounths ago exactly the problem i’m
having with flickering and mouse cursor stuff in fullscreen mode using
the directx driver of SDL.
So my question is quite simple : How did you fix it?
Hi,
I didn’t fix it since then. In my game, fullscreen is only optional, it
usually runs in windowed mode.
About the mouse cursor:
If your game has a reasonable high framerate (>10 or 20 FPS) then try to
draw the cursor by yourself. Save the coordinates given by the last
SDL_MOUSEMOTION event in some variable, and blit the image of the cursor
on the screen right before SDL_Flip()'ing the buffers.
The drawback with this solution is that the cursor response becomes
"laggish" when the framerate is low (I have actually seen this behaviour
in some commercial games as well, like Warcraft3: my computer is slow,
and in a huge fight with less then 4 FPS its nearly impossible to find
the cursor and place it somewhere).
About the flickering:
Flickering usually occurs when blitting while your monitor is updating
the screen. You might want to look at your video driver preferences and
enable “wait for vsync” or sth. like that (depends on your
card/vendor/chipset). This will reduce the framerate in 3d-games (but I
think not much) but will probably disable that flickering. However, I’m
not 100% sure, just give it a try.
If you’ve got any beter solution to one of the problems then please let
me know.
good luck,
eph
What about SDL_HWSURFACE - are you in hardware or software? And does it
matter?
SDL_HWSURFACE and SDL_SWSURFACE flags, either set or unset do not change
anything…
Can it be caused by the fact that i did not compiled SDL correctly ?
(i’m using version 1.2.4 and VC said 0 error and 0 warning after compiling
and linking SDL.)
The problem is that a lot of users - and some manufacturers, so I hear -
set their drivers to have Vsync off by default so that they get better
frame rates and benchmark scores. Waiting for the vsync slows the system
down to gain some image quality - ie. to avoid flickering or ‘tearing’.
Turning this back on - if indeed it is the problem - is probably not
something a user program like SDL can do, especially not on the more
recent versions of Windows that attempt some sort of rudimentary
security…
D’oh!
In order to solve this damn thing, i tried to find a solution with emailing
2 developers who had the same issue a few months ago. Here is their answer.> ----- Original Message -----
From: "Sven Heyll"
To: "Alexis"
Sent: Wednesday, August 21, 2002 8:04 PM
Subject: Re: SDL VSYNC issue
Hi,
Well I have not really solved the cause of the problem, but I have used my
own mouse cursor drawing/handling routines, instead of using a real
mousecursor, I hide the cursor , and display a small picture with
transparency:
Here a code snippet:
[…]
SDL_Event _events;
// load the mouse cursor image
SDL_Surface*mousecursour=_M_image_provider->GetImageOriginal(“images/mouse_m
ain.png”);
SDL_Rect mousepos;
// this is the initial mouse position
mousepos.x = ScreenWidth/2 - mousecursour->w/2;
mousepos.y = ScreenHeight/2- mousecursour->h/2;
bool _M_exit = false;
while (!_M_exit) {
if (SDL_PollEvent(&_events)){
// get rid of useless events
SDL_Event old_ev;
do {
old_ev = _events;
} while ( SDL_PollEvent(&_events));
// Do the work here and draw everything
(except the mouse of course)
[....]
// now draw the mouse
int x,y;
SDL_GetMouseState(&x,&y);
mousepos.x =x- mousecursour->w/2;
mousepos.y =y- mousecursour->h/2;
SDL_BlitSurface(mousecursour, NULL,
_M_screen, &mousepos);
SDL_Flip(_M_screen);
}
}
You should make your own eventloop anyway …
Hope that helps.
with warm regards,
Sven Heyll