grise: fixed artifact due to uninitialized guard-pand in backBuffer and
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Tue, 13 Sep 2016 07:09:51 +0000 (10:09 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Tue, 13 Sep 2016 07:09:51 +0000 (10:09 +0300)
increased the performance slightly by copying the backBuffer to
vmem_back, instead of fb_pixels.

src/grise.c

index 896b7c0..e6cd7ea 100644 (file)
@@ -99,7 +99,7 @@ static int init(void)
        int tmpBitmapW, tmpBitmapH;
 
        /* Allocate back buffer */
-       backBuffer = (unsigned short*) malloc(BB_SIZE * BB_SIZE * sizeof(unsigned short));
+       backBuffer = (unsigned short*) calloc(BB_SIZE * BB_SIZE, sizeof(unsigned short));
 
        /* grise.png contains the background (horizon), baked reflection and normalmap for displacement */
        if (!(background = img_load_pixels(BG_FILENAME, &backgroundW, &backgroundH, IMG_FMT_RGBA32))) {
@@ -206,14 +206,14 @@ static void draw(void)
 
        /* Blit effect to framebuffer */
        src = backBuffer + PIXEL_PADDING;
-       dst = fb_pixels;
+       dst = vmem_back;
        for (scanline = 0; scanline < fb_height; scanline++) {
                memcpy(dst, src, fb_width * 2);
                src += BB_SIZE; 
                dst += fb_width;
        }
 
-       swap_buffers(fb_pixels);
+       swap_buffers(0);
 }
 
 /* src and dst can be the same */
@@ -541,4 +541,4 @@ static void rleBlitScaleInv(unsigned short *dst, int dstW, int dstH, int dstStri
 
                dst -= dstStride;
        }
-}
\ No newline at end of file
+}