Page 1 sur 1

double buffering avec nSDL

Message non luPosté: 23 Mai 2023, 17:59
de newprog_creator
Bonjour à tous,
Je suis actuellement en train d'apprendre à utiliser nSDL.
J'ai une question pour laquelle je ne trouve pas de réponse.
Je souhaiterai savoir comment désactiver le double buffering. En effet, la fonction sdl_flip() est très lente (50exec/sec) ainsi que la fonction updaterect() également.
Merci par avance pour vos retours...
Merci

Le code d'exemple de ndless (link) est le même que celui que j'utilise.... :
Code: Tout sélectionner
int sdlinit(void)
{
    ptr++;
    if(SDL_Init(SDL_INIT_VIDEO) == -1) {
        printf("Couldn't initialize SDL: %s\n", SDL_GetError());
        exit(EXIT_FAILURE);
    }
    screen = SDL_SetVideoMode(320, 240, has_colors ? 16 : 8, SDL_SWSURFACE);
    if(screen == NULL) {
        printf("Couldn't initialize display: %s\n", SDL_GetError());
        SDL_Quit();
        exit(EXIT_FAILURE);
    }
    SDL_ShowCursor(SDL_DISABLE);
    is_sdl_used=1;
    return screen;
}

Re: double buffering avec nSDL

Message non luPosté: 23 Mai 2023, 19:13
de Vogtinator
You can't disable double buffering. nSDL uses a framebuffer which it draws into and then calls lcd_blit at the end of updaterects.

However, there is no forced vsync or anything like that which would explain the 50fps. Maybe it's actually input handling which takes that long? Especially the touchpad scanning can take a while, but usually not that long.

Re: double buffering avec nSDL

Message non luPosté: 23 Mai 2023, 19:52
de newprog_creator
Thanks for your response.
Unfortunately, the low speed don't come from the input handling (i have disable it).
I will have to recode all graphics functions ....boring...
Thanks again for your response

Re: double buffering avec nSDL

Message non luPosté: 23 Mai 2023, 23:21
de newprog_creator
I come back,
I have some other points i want to ask for.
1- I love the SDL_getticks() function and want to implement an equivalent without using sdl. Is there an another way without nsdl ?
2- In addition, i have not found the way to use interrupts. Is there a mean to do that ?
3- Has someone the source code in c of the blit function with a good optimisation ? (Always without using sdl)

Thanks again by advance

Re: double buffering avec nSDL

Message non luPosté: 24 Mai 2023, 10:03
de Vogtinator
newprog_creator a écrit:I come back,
I have some other points i want to ask for.
1- I love the SDL_getticks() function and want to implement an equivalent without using sdl. Is there an another way without nsdl ?

Only by using timers directly.

2- In addition, i have not found the way to use interrupts. Is there a mean to do that ?

You can, you'll have to configure the hardware, write a handler and overwrite the handler of the OS.

3- Has someone the source code in c of the blit function with a good optimisation ? (Always without using sdl)

Thanks again by advance


You can look at the nSDL code: https://github.com/Vogtinator/nSDL

Alternatives are https://github.com/n2DLib/n2DLib/ or https://github.com/Vogtinator/nGL/blob/ ... etools.cpp

Re: double buffering avec nSDL

Message non luPosté: 24 Mai 2023, 16:00
de newprog_creator
Thanks for your response