shithub: choc

Download patch

ref: f0b5b0bcb0e51b3f642725e55b16b2b6e0a56829
parent: c01da5e230d7b57085cbe1465364bed7abc895f4
author: Fabian Greffrath <[email protected]>
date: Thu Aug 6 14:22:08 EDT 2015

Revert "Video: Use intended function sequence to update "streaming" texture"

This reverts commit a61f85c35583c5e000698a8a6591d81e7b2787b5.

The explicit SDL_LockTexture()/memcpy()/SDL_UnlockTexture() sequence is
tedious and not a tad faster than the SDL_UpdateTexture() function.

Thanks @bradharding

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -160,8 +160,6 @@
 static SDL_Surface *rgbabuffer = NULL;
 static SDL_Surface *rgbabuffer_upscaled = NULL;
 static SDL_Texture *texture = NULL;
-static int pitch;
-static void *pixels;
 
 // palette
 
@@ -1111,12 +1109,10 @@
     SDL_BlitScaled(rgbabuffer, NULL, rgbabuffer_upscaled, NULL);
 
     // Update the texture with the content of the 32-bit RGBA buffer
+    // (the last argument is the pitch, i.e. 320 pixels of 4 RGBA-bytes)
 
-    if (!SDL_LockTexture(texture, NULL, &pixels, &pitch))
-    {
-	memcpy(pixels, rgbabuffer_upscaled->pixels, UPSCALE*SCREENHEIGHT*pitch);
-	SDL_UnlockTexture(texture);
-    }
+    SDL_UpdateTexture(texture, NULL, rgbabuffer_upscaled->pixels,
+                      UPSCALE * SCREENWIDTH * sizeof(Uint32));
 
     // Render the texture into the window