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

Wutipong Wongsakuldej 9tawan at gmail.com
Sat Nov 12 06:51:28 PST 2005


Bill Kendrick wrote:
> 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!
>
>   
I've changed to this :-

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);
            //Flip Frame Buffer
            SDL_Flip(backBuffer);
            //Do Event
            SDL_Event event;
            while(SDL_PollEvent(&event)==1)
            {
                box->ActionPerformed(event);
            };
        }
        SDL_UnlockMutex(mutex);
        //Finish Render Frame
        SDL_Delay(0);
    }
    return 0;
}

And the result is still the same (I mean, window is not movable, and 
become not respond).
>   
>> Here is the rendering code :-
>>
>> <code snip>....
>>     
>
> -bill!
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
>   





More information about the SDL mailing list