dos3d

diff src/mingl.c @ 9:bce78aaafc68

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 26 Nov 2011 03:59:48 +0200
parents 0e781cc43178
children 0909996838ff
line diff
     1.1 --- a/src/mingl.c	Mon Nov 21 12:45:18 2011 +0200
     1.2 +++ b/src/mingl.c	Sat Nov 26 03:59:48 2011 +0200
     1.3 @@ -84,8 +84,19 @@
     1.4  
     1.5  void mgl_free(void)
     1.6  {
     1.7 +	int i;
     1.8 +
     1.9  	mgl_rast_cleanup();
    1.10  	free(fb.pixels);
    1.11 +	fb.pixels = 0;
    1.12 +
    1.13 +	if(fb.zbuf) {
    1.14 +		for(i=0; i<fb.num_ztiles; i++) {
    1.15 +			free(fb.zbuf[i]);
    1.16 +		}
    1.17 +		free(fb.zbuf);
    1.18 +		fb.zbuf = 0;
    1.19 +	}
    1.20  }
    1.21  
    1.22  unsigned char *mgl_framebuffer(void)
    1.23 @@ -98,6 +109,34 @@
    1.24  	memset(fb.pixels, cidx, fb.width * fb.height);
    1.25  }
    1.26  
    1.27 +void mgl_clear_depth(void)
    1.28 +{
    1.29 +	int i;
    1.30 +
    1.31 +	if(!fb.zbuf) {
    1.32 +		long num_pixels = (long)fb.width * (long)fb.height;
    1.33 +		fb.num_ztiles = (num_pixels + ZTILE_SIZE - 1) / ZTILE_SIZE;
    1.34 +
    1.35 +		if(!(fb.zbuf = malloc(fb.num_ztiles * sizeof *fb.zbuf))) {
    1.36 +			fprintf(stderr, "failed to allocate ztile array\n");
    1.37 +			abort();
    1.38 +		}
    1.39 +
    1.40 +		for(i=0; i<fb.num_ztiles; i++) {
    1.41 +			if(!(fb.zbuf[i] = malloc(ZTILE_SIZE * 2))) {
    1.42 +				fprintf(stderr, "failed to allocate ztile %d\n", i);
    1.43 +				abort();
    1.44 +			}
    1.45 +			memset(fb.zbuf[i], 0xff, ZTILE_SIZE * 2);
    1.46 +		}
    1.47 +		return;
    1.48 +	}
    1.49 +
    1.50 +	for(i=0; i<fb.num_ztiles; i++) {
    1.51 +		memset(fb.zbuf[i], 0xff, ZTILE_SIZE * 2);
    1.52 +	}
    1.53 +}
    1.54 +
    1.55  void mgl_enable(unsigned int bit)
    1.56  {
    1.57  	st.flags |= bit;