forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL vsync?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
cyberfish



Joined: 19 May 2008
Posts: 19

PostPosted: Wed May 21, 2008 2:59 pm    Post subject: SDL vsync? Reply with quote

Hi,
I have just started experimenting with SDL on the PSP a bit, and I can't seem to get rid of the tearing if the frame rate is high. For example, with something like this:
Code:

Uint32 colors[3];
   
colors[0] = SDL_MapRGB(screen->format, 0xFF, 0, 0);
colors[1] = SDL_MapRGB(screen->format, 0, 0xFF, 0);
colors[2] = SDL_MapRGB(screen->format, 0, 0, 0xFF);
   
int c = 0;
SDL_Event evt;
   
while (true) {
   if (SDL_PollEvent(&evt)) {
      switch (evt.type) {
         case SDL_KEYDOWN:
            break;
         case SDL_QUIT:
            exit(0);
      }
   }
   ++c;
   c = c % 3;
   SDL_FillRect(screen, NULL, colors[c]);
   SDL_Flip(screen);
   SDL_Delay(10);
}

It should flash the screen red, green, blue, red, green, blue... at a maximum of 100fps.
However, the result looks like 4 bands of colors flash really fast (tearing). I am guessing it's something to do with vsync, but I am not experienced at all in graphics programming.

If I change SDL_Delay(10) to SDL_Delay(100), all is well.

I am calling SDL_SetVideoMode with "SDL_SWSURFACE | SDL_DOUBLEBUF". Is there anything else I can do?

Thanks for your help
Back to top
View user's profile Send private message
Shapyi



Joined: 25 Apr 2005
Posts: 95

PostPosted: Wed May 21, 2008 3:02 pm    Post subject: Reply with quote

Code:
sceDisplayWaitVblankStart();


Add that before you call your flip function.
Back to top
View user's profile Send private message
cyberfish



Joined: 19 May 2008
Posts: 19

PostPosted: Wed May 21, 2008 3:11 pm    Post subject: Reply with quote

thanks! that fixed it.

Now I see a beautiful flashing white (which is what I expected).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group