I initialize SDL with this code:
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* win = SDL_CreateWindow(
"SDL Window",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
WIDTH,
HEIGHT,
SDL_WINDOW_SHOWN
);
SDL_Renderer* ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_SOFTWARE);
SDL_GL_SetSwapInterval(1); // probably has no effect since it's not using GL
I then render with a non-SDL software renderer and present it to the window with this code:
SDL_UpdateTexture(screenBuffer, NULL, screenData, WIDTH*4);
SDL_RenderClear(ren);
SDL_RenderCopy(ren, screenBuffer, NULL, NULL);
SDL_RenderPresent(ren);
The framerate is completely uncapped, and I have no idea why.
Adding | SDL_RENDERER_PRESENTVSYNC
to the SDL_CreateRenderer flags simply makes the window a blank white screen. Though I need to use the SDL_RENDERER_SOFTWARE
flag (even though I'm not using SDL's software renderer other than to present the screen) or else will SDL_RenderPresent()
will stall for a very, very long time resulting in about 1 frame per second.
How can I make SDL_RenderPresent()
wait for vsync, or wait for it (accurately) myself?