I\'ve written a program using C++ and SDL2 which:
Try adding SDL_RENDERER_PRESENTVSYNC
to your renderer's flag (Proposed by someone here).
C++ seems to be the programming language you're using but for those looking for a fully working SDL2.0.8-based C program that does not use GetWindowSurface()
, please take a look here:
Mainly,
The SDL_GetWindowSurface()
header comment specifically prohibits using it with the SDL_Renderer functionality:
/**
* \brief Get the SDL surface associated with the window.
*
* \return The window's framebuffer surface, or NULL on error.
*
* A new surface will be created with the optimal format for the window,
* if necessary. This surface will be freed when the window is destroyed.
*
* \note You may not combine this with 3D or the rendering API on this window.
*
* \sa SDL_UpdateWindowSurface()
* \sa SDL_UpdateWindowSurfaceRects()
*/
extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window);
Use SDL_RENDERER_TARGETTEXTURE
& SDL_SetRenderTarget() if you want to capture SDL_Renderer output.
You can use SDL_GetRendererInfo() to query a compatible texture format. Or just blast ahead with SDL_PIXELFORMAT_ARGB8888
like testrendertarget.c does and hope for the best :)