Re: Some SDL Issues
Posted: Tue Feb 03, 2009 2:54 pm
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.
The Next Generation of 2D Roleplaying Games
http://elysianshadows.com/phpBB3/
...Failsparda wrote:Jesus. I was surprised as to how easy this SDL problem was to solve.
Here is the solution, thank me later
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?
MarauderIIC wrote:Hm. Start posting relevant code sections, I think.
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);
Isn't sceDisplayWaitVblankStart() from the PSP SDK?MarauderIIC wrote:Try
sceDisplayWaitVblankStart();
before your SDL_Flip() call just for the heck of it
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
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.
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?