[SDL] Not Response on Window Mode (on WindowsXP)

Bill Kendrick nbs at sonic.net
Fri Nov 11 17:47:24 PST 2005


On Sat, Nov 12, 2005 at 03:18:43AM +0700, Wutipong Wongsakuldej wrote:
> This problem is not found on Full-Screen Mode.
> 

You are doing SDL_Flip() a _lot_, even when nothing has changed
and it hasn't been "33" ms.  (e.g., if there were no events, it still
SDL_Flip()'s, which might be expensive, esp. in windowed / software surface
modes.)

Try only SDL_Flip()'ing when you actually do the SDL_BlitSurface() stuff.

-bill!


> Here is the rendering code :-
> 
> int UpdateScreen(void* data)
> {
>    static long exframe = SDL_GetTicks();
>    while(true)
>    {
>        //Delay each frame for approx 33ms
>        //SDL_Delay(33);
> 
>        //Start Render new Frame
>        SDL_LockMutex(mutex);
>        long now = SDL_GetTicks();
> 
>        if(now-exframe >=33)
>        {
>            exframe = now;
> 
>            //Clear Frame Buffer
>            SDL_FillRect(backBuffer,NULL,0xffffffff);
>            //Draw Text to Screen
>            SDL_BlitSurface(background,NULL,backBuffer,NULL);
>            box->Draw(backBuffer);
>            SDL_BlitSurface(messageBuffer,NULL,backBuffer,NULL);
>        }
>        //Do Event
>        SDL_Event event;
>        while(SDL_PollEvent(&event)==1)
>        {
>            box->ActionPerformed(event);
>        };
>        //Flip Frame Buffer
>        SDL_Flip(backBuffer);
>        SDL_UnlockMutex(mutex);
>        //Finish Render Frame
>    }
>    return 0;
> }

-bill!




More information about the SDL mailing list