deepstone

diff src/test.c @ 3:0e781cc43178

adding textures
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 21 Nov 2011 10:16:09 +0200
parents 0b7f840afe4a
children c3e0bccd673e
line diff
     1.1 --- a/src/test.c	Mon Nov 21 10:15:37 2011 +0200
     1.2 +++ b/src/test.c	Mon Nov 21 10:16:09 2011 +0200
     1.3 @@ -25,6 +25,7 @@
     1.4  #include "timer.h"
     1.5  #include "mouse.h"
     1.6  #include "palman.h"
     1.7 +#include "texture.h"
     1.8  
     1.9  static int init(void);
    1.10  static void shutdown(void);
    1.11 @@ -39,6 +40,8 @@
    1.12  
    1.13  static unsigned char *fbuf;
    1.14  
    1.15 +static struct texture *tex;
    1.16 +
    1.17  static int white_base, red_base, green_base, blue_base;
    1.18  static int grad_range;
    1.19  
    1.20 @@ -145,6 +148,12 @@
    1.21  	mgl_load_identity();
    1.22  	mgl_perspective(45.0, 320.0 / 200.0, 0.5, 100.0);
    1.23  
    1.24 +	if(!(tex = tex_gen_checker(64, 64, 3, 3, red_base, blue_base))) {
    1.25 +		fprintf(stderr, "failed to generate texture\n");
    1.26 +		return -1;
    1.27 +	}
    1.28 +	mgl_teximage(tex->width, tex->height, tex->pixels);
    1.29 +
    1.30      return 0;
    1.31  }
    1.32  
    1.33 @@ -245,6 +254,22 @@
    1.34  	case 27:
    1.35  		return 0;
    1.36  
    1.37 +	case 's':
    1.38 +		if(mgl_isenabled(MGL_SMOOTH)) {
    1.39 +			mgl_disable(MGL_SMOOTH);
    1.40 +		} else {
    1.41 +			mgl_enable(MGL_SMOOTH);
    1.42 +		}
    1.43 +		break;
    1.44 +
    1.45 +	case 't':
    1.46 +		if(mgl_isenabled(MGL_TEXTURE_2D)) {
    1.47 +			mgl_disable(MGL_TEXTURE_2D);
    1.48 +		} else {
    1.49 +			mgl_enable(MGL_TEXTURE_2D);
    1.50 +		}
    1.51 +		break;
    1.52 +
    1.53  	case ' ':
    1.54  		auto_rotate = !auto_rotate;
    1.55  		break;