Some SDL Issues
Moderator: Coders of Rage
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Some SDL Issues
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.
- programmerinprogress
- 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
...Failsparda wrote:Jesus. I was surprised as to how easy this SDL problem was to solve.
Here is the solution, thank me later
Click here to see the hidden message (It might contain spoilers)
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
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
-
- ES Beta Backer
- Posts: 61
- Joined: Sun Sep 21, 2008 4:46 am
- Location: U.K.
Re: Some SDL Issues
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?
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
~El Pollo Diablo
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Some SDL Issues
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.
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.
Re: Some SDL Issues
That's weird, usually tearing only results in one visible tear.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?
Agrees with:
MarauderIIC wrote:Hm. Start posting relevant code sections, I think.
177
-
- ES Beta Backer
- Posts: 61
- Joined: Sun Sep 21, 2008 4:46 am
- Location: U.K.
Re: Some SDL Issues
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);
¡SÃ! ¡He dejado en libertad los prisioneros y ahora vengo por ti!
~El Pollo Diablo
~El Pollo Diablo
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Some SDL Issues
Try
sceDisplayWaitVblankStart();
before your SDL_Flip() call just for the heck of it
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.
- M_D_K
- 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
Isn't sceDisplayWaitVblankStart() from the PSP SDK?MarauderIIC wrote:Try
sceDisplayWaitVblankStart();
before your SDL_Flip() call just for the heck of it
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.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Some SDL Issues
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.
- LeonBlade
- 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
LOL yeah it is.M_D_K wrote:Isn't sceDisplayWaitVblankStart() from the PSP SDK?MarauderIIC wrote:Try
sceDisplayWaitVblankStart();
before your SDL_Flip() call just for the heck of it
There's no place like ~/
- KuramaYoko10
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Fri Oct 31, 2008 8:02 pm
Re: Some SDL Issues
Try adding SDL_HWSURFACE....
That is the way I always did because of a website that I started learning SDL, and here it is its explanation:
Hope it works
Code: Select all
SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREENBPP, SDL_HWSURFACE | SDL_DOUBLEBUF);
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.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Some SDL Issues
"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.
-
- ES Beta Backer
- Posts: 61
- Joined: Sun Sep 21, 2008 4:46 am
- Location: U.K.
Re: Some SDL Issues
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?
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
~El Pollo Diablo
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Some SDL Issues
I have no clue.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?
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.
- M_D_K
- 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
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.