Created
March 2, 2019 13:59
-
-
Save nikolas/f2200376e28183b5efb8384277e36ac1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void DrawSurfaceToScreen() | |
{ | |
int n = _num_dirty_rects; | |
if (n == 0) return; | |
_num_dirty_rects = 0; | |
if (n > MAX_DIRTY_RECTS) { | |
SDL_CALL SDL_UpdateTexture( | |
_sdl_texture, NULL, _sdl_surface->pixels, _sdl_surface->pitch); | |
SDL_CALL SDL_RenderClear(_sdl_renderer); | |
SDL_CALL SDL_RenderCopy(_sdl_renderer, _sdl_texture, NULL, NULL); | |
} else { | |
void *pixels; | |
int pitch; | |
SDL_CALL SDL_LockTexture(_sdl_texture, NULL, &pixels, &pitch); | |
memcpy( | |
pixels, _sdl_surface->pixels, | |
pitch * _sdl_surface->h); | |
SDL_CALL SDL_UnlockTexture(_sdl_texture); | |
for (int i = 0; i < n; i++) { | |
SDL_CALL SDL_RenderCopy( | |
_sdl_renderer, _sdl_texture, &_dirty_rects[i], &_dirty_rects[i]); | |
} | |
} | |
SDL_CALL SDL_RenderPresent(_sdl_renderer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment