Page 2 of 2

Re: Some SDL Issues

Posted: Tue Feb 03, 2009 2:54 pm
by MarauderIIC
I mean, I'm not sure you can draw to the front buffer (direct to the screen) when you're doublebuffering in SDL. If he can he would have had to make sure that he's not doing this.

Re: Some SDL Issues

Posted: Tue Feb 03, 2009 3:17 pm
by programmerinprogress
sparda wrote:Jesus. I was surprised as to how easy this SDL problem was to solve.

Here is the solution, thank me later :)
...Fail :lol:
Fail!
Fail!
error!.png (18.32 KiB) Viewed 1587 times
Click here to see the hidden message (It might contain spoilers)
SDL's site wouldn't do that :lol:


As for the flickering problem, I hope that gets sorted, i'm sure there's a simple enough explanation.
I've never bothered with doublebuffering though.

Re: Some SDL Issues

Posted: Tue Feb 03, 2009 3:59 pm
by Chaos Clown
AHA! Through the magic of camstudio, I caught the bugger in action! It is definitely screen-tearing, right?

Image

Also, I looked at it bit more closely, and it turns out that I was double-buffering the whole time. Would tripple-buffering help, or am I doomed to failure?

Re: Some SDL Issues

Posted: Tue Feb 03, 2009 4:58 pm
by MarauderIIC
SCREEN=SDL_SetVideoMode(SCREEN_W,SCREEN_H,0,SDL_DOUBLEBUF... ?

SDL_Flip(screen you were drawing to)?

Hm. Start posting relevant code sections, I think.

Re: Some SDL Issues

Posted: Tue Feb 03, 2009 5:24 pm
by Amarant
Chaos Clown wrote:AHA! Through the magic of camstudio, I caught the bugger in action! It is definitely screen-tearing, right?

Also, I looked at it bit more closely, and it turns out that I was double-buffering the whole time. Would tripple-buffering help, or am I doomed to failure?
That's weird, usually tearing only results in one visible tear.
Agrees with:
MarauderIIC wrote:Hm. Start posting relevant code sections, I think.

Re: Some SDL Issues

Posted: Wed Feb 04, 2009 1:15 am
by Chaos Clown

Code: Select all

void Init()
{
	SDL_Init(SDL_INIT_EVERYTHING);
	Screen = SDL_SetVideoMode(ScreenWidth, ScreenHeight, ScreenBPP, SDL_DOUBLEBUF);
	SDL_WM_SetCaption("Tile Test", NULL);
}

Code: Select all

void player::DisplayPlayer()
{
	if(Direction == left)
	{
		if(XVel == 0 && YVel ==0)
			ApplySurface(X-ScrollX, Y, LSprite, Screen);
		else if(YVel !=0)
			ApplySurface(X-ScrollX, Y, LJumpSprite, Screen);
		else
			ApplySurface(X-ScrollX, Y, lWalkAnimation[CurFrame], Screen);
	}
	else
	{
		if(XVel == 0 && YVel ==0)
			ApplySurface(X-ScrollX, Y, RSprite, Screen);
		else if(YVel !=0)
			ApplySurface(X-ScrollX, Y, RJumpSprite, Screen);
		else
			ApplySurface(X-ScrollX, Y, rWalkAnimation[CurFrame], Screen);
	}
}

Code: Select all

SDL_Flip(Screen);
I'm seriously starting to think this is my monitor, or I'm hallucinating, and that screenshot was just a camstudio glitch or something.

Re: Some SDL Issues

Posted: Wed Feb 04, 2009 6:51 pm
by MarauderIIC
Try

sceDisplayWaitVblankStart();

before your SDL_Flip() call just for the heck of it

Re: Some SDL Issues

Posted: Wed Feb 04, 2009 7:03 pm
by M_D_K
MarauderIIC wrote:Try

sceDisplayWaitVblankStart();

before your SDL_Flip() call just for the heck of it
Isn't sceDisplayWaitVblankStart() from the PSP SDK?

Re: Some SDL Issues

Posted: Wed Feb 04, 2009 8:05 pm
by MarauderIIC
Probably. I'm not all here right now. I might have pasted the wrong thing. So nevermind.

Re: Some SDL Issues

Posted: Thu Feb 05, 2009 12:29 am
by LeonBlade
M_D_K wrote:
MarauderIIC wrote:Try

sceDisplayWaitVblankStart();

before your SDL_Flip() call just for the heck of it
Isn't sceDisplayWaitVblankStart() from the PSP SDK?
LOL yeah it is.

Re: Some SDL Issues

Posted: Thu Feb 05, 2009 5:26 am
by KuramaYoko10
Try adding SDL_HWSURFACE....

Code: Select all

SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREENBPP, SDL_HWSURFACE | SDL_DOUBLEBUF); 
That is the way I always did because of a website that I started learning SDL, and here it is its explanation:
SDL_DOUBLEBUF - Enable hardware double buffering; only valid with SDL_HWSURFACE. Calling SDL_Flip will flip the buffers and update the screen. All drawing will take place on the surface that is not displayed at the moment. If double buffering could not be enabled then SDL_Flip will just perform a SDL_UpdateRect on the entire screen.
My recommendation: give it SDL_HWSURFACE|SDL_DOUBLEBUF and in case of an error try again with SDL_SWSURFACE.

Hope it works ;)

Re: Some SDL Issues

Posted: Thu Feb 05, 2009 8:19 am
by MarauderIIC
"And someone with a brain said..." ^

Re: Some SDL Issues

Posted: Thu Feb 05, 2009 12:53 pm
by Chaos Clown
Tried it with both SDL_HWSURFACE and SDL_SWSURFACE. Made no difference. I also tried calling SDL_FillRect(blah) every frame before I draw all everything to the screen. Still no dice.

IMPORTANT EDIT: Running it in fullscreen (SDL_FULLSCREEN) makes the flickering disappear. I think this is because SDL has automatic V-Synching in fullscreen mode. Is there any way I can replicate this in windowed mode?

Re: Some SDL Issues

Posted: Thu Feb 05, 2009 4:57 pm
by Ginto8
Chaos Clown wrote:Tried it with both SDL_HWSURFACE and SDL_SWSURFACE. Made no difference. I also tried calling SDL_FillRect(blah) every frame before I draw all everything to the screen. Still no dice.

IMPORTANT EDIT: Running it in fullscreen (SDL_FULLSCREEN) makes the flickering disappear. I think this is because SDL has automatic V-Synching in fullscreen mode. Is there any way I can replicate this in windowed mode?
:roll: I have no clue.

But in SFML, they have sf::Window::UseVerticalSync, which sets v-synching.

Re: Some SDL Issues

Posted: Thu Feb 05, 2009 5:20 pm
by M_D_K
V-sync in windowed mode is not supported on all platforms since in windowed mode the OS is in control of refresh rate.