Some SDL Issues

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Some SDL Issues

Post 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.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
programmerinprogress
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Wed Oct 29, 2008 7:31 am
Current Project: some crazy stuff, i'll tell soon :-)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++!
Location: The UK
Contact:

Re: Some SDL Issues

Post 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 1591 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.
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D

I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
Chaos Clown
ES Beta Backer
ES Beta Backer
Posts: 61
Joined: Sun Sep 21, 2008 4:46 am
Location: U.K.

Re: Some SDL Issues

Post 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?
¡Sí! ¡He dejado en libertad los prisioneros y ahora vengo por ti!
~El Pollo Diablo
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Some SDL Issues

Post 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.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Amarant
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Wed Nov 05, 2008 9:52 am

Re: Some SDL Issues

Post 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.
177
Chaos Clown
ES Beta Backer
ES Beta Backer
Posts: 61
Joined: Sun Sep 21, 2008 4:46 am
Location: U.K.

Re: Some SDL Issues

Post 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.
¡Sí! ¡He dejado en libertad los prisioneros y ahora vengo por ti!
~El Pollo Diablo
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Some SDL Issues

Post by MarauderIIC »

Try

sceDisplayWaitVblankStart();

before your SDL_Flip() call just for the heck of it
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
M_D_K
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1087
Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK

Re: Some SDL Issues

Post 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?
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Some SDL Issues

Post by MarauderIIC »

Probably. I'm not all here right now. I might have pasted the wrong thing. So nevermind.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Some SDL Issues

Post 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.
There's no place like ~/
User avatar
KuramaYoko10
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 55
Joined: Fri Oct 31, 2008 8:02 pm

Re: Some SDL Issues

Post 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 ;)
Type a message here!!
[b][color=#BF0000]MarauderIIC[/color][/b] wrote:"Never" is never true in programming.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Some SDL Issues

Post by MarauderIIC »

"And someone with a brain said..." ^
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Chaos Clown
ES Beta Backer
ES Beta Backer
Posts: 61
Joined: Sun Sep 21, 2008 4:46 am
Location: U.K.

Re: Some SDL Issues

Post 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?
¡Sí! ¡He dejado en libertad los prisioneros y ahora vengo por ti!
~El Pollo Diablo
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Some SDL Issues

Post 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.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
M_D_K
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1087
Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK

Re: Some SDL Issues

Post 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.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
Post Reply