imtk

changeset 13:9c7987064bb0

- fixed the frame drawing a bit - added global alpha value and various drawing parameters - backported the checkbox check mark from glamtk - fixed progress bar drawing so that the bevels of the trough and the bar won't overlap
author John Tsiombikas <nuclear@siggraph.org>
date Mon, 18 Apr 2011 06:15:46 +0300
parents 17c9525b2e35
children df2bc9406561
files src/checkbox.c src/draw.c src/draw.h src/imtk.c src/imtk.h src/progress.c src/textbox.c test.c
diffstat 8 files changed, 173 insertions(+), 110 deletions(-) [+]
line diff
     1.1 --- a/src/checkbox.c	Sun Apr 17 18:20:23 2011 +0300
     1.2 +++ b/src/checkbox.c	Mon Apr 18 06:15:46 2011 +0300
     1.3 @@ -41,6 +41,21 @@
     1.4  static void draw_checkbox(int id, const char *label, int x, int y, int state, int over)
     1.5  {
     1.6  	static const int sz = CHECKBOX_SIZE;
     1.7 +	static float v[][2] = {
     1.8 +		{-0.2, 0.63},	/* 0 */
     1.9 +		{0.121, 0.325},	/* 1 */
    1.10 +		{0.15, 0.5},	/* 2 */
    1.11 +		{0.28, 0.125},	/* 3 */
    1.12 +		{0.38, 0.33},	/* 4 */
    1.13 +		{0.42, -0.122},	/* 5 */
    1.14 +		{0.58, 0.25},	/* 6 */
    1.15 +		{0.72, 0.52},	/* 7 */
    1.16 +		{0.625, 0.65},	/* 8 */
    1.17 +		{0.89, 0.78},	/* 9 */
    1.18 +		{0.875, 0.92},	/* 10 */
    1.19 +		{1.13, 1.145}	/* 11 */
    1.20 +	};
    1.21 +#define TRI(a, b, c)	(glVertex2fv(v[a]), glVertex2fv(v[b]), glVertex2fv(v[c]))
    1.22  
    1.23  	if(over) {
    1.24  		glColor4fv(imtk_get_color(IMTK_FOCUS_COLOR));
    1.25 @@ -53,19 +68,29 @@
    1.26  
    1.27  	glColor4fv(imtk_get_color(IMTK_TEXT_COLOR));
    1.28  	if(state) {
    1.29 -		glPushAttrib(GL_LINE_BIT);
    1.30 -		glLineWidth(2);
    1.31 +		glMatrixMode(GL_MODELVIEW);
    1.32 +		glPushMatrix();
    1.33 +		glTranslatef(x, y + sz, 0);
    1.34 +		glScalef(sz * 1.2, -sz * 1.3, 1);
    1.35  
    1.36 -		glBegin(GL_LINES);
    1.37 -		glVertex2f(x + 2, y + 2);
    1.38 -		glVertex2f(x + sz - 2, y + sz - 2);
    1.39 -		glVertex2f(x + sz - 2, y + 2);
    1.40 -		glVertex2f(x + 2, y + sz - 2);
    1.41 +		glBegin(GL_TRIANGLES);
    1.42 +		glColor4fv(imtk_get_color(IMTK_CHECK_COLOR));
    1.43 +		TRI(0, 1, 2);
    1.44 +		TRI(1, 3, 2);
    1.45 +		TRI(3, 4, 2);
    1.46 +		TRI(3, 5, 4);
    1.47 +		TRI(4, 5, 6);
    1.48 +		TRI(4, 6, 7);
    1.49 +		TRI(4, 7, 8);
    1.50 +		TRI(8, 7, 9);
    1.51 +		TRI(8, 9, 10);
    1.52 +		TRI(10, 9, 11);
    1.53  		glEnd();
    1.54  
    1.55 -		glPopAttrib();
    1.56 +		glPopMatrix();
    1.57  	}
    1.58  
    1.59 +	glColor4fv(imtk_get_color(IMTK_TEXT_COLOR));
    1.60  	imtk_draw_string(x + sz + 5, y + sz - 2, label);
    1.61  }
    1.62  
     2.1 --- a/src/draw.c	Sun Apr 17 18:20:23 2011 +0300
     2.2 +++ b/src/draw.c	Mon Apr 18 06:15:46 2011 +0300
     2.3 @@ -9,9 +9,15 @@
     2.4  	{0.7, 0.7, 0.7, 1.0},		/* base color */
     2.5  	{0.85, 0.85, 0.85, 1.0},	/* focus color */
     2.6  	{1.0, 1.0, 1.0, 1.0},		/* lit bevel */
     2.7 -	{0.3, 0.3, 0.3, 1.0}		/* shadowed bevel */
     2.8 +	{0.3, 0.3, 0.3, 1.0},		/* shadowed bevel */
     2.9 +	{0.8, 0.25, 0.18, 1.0},		/* cursor color */
    2.10 +	{0.4, 0.5, 0.9, 1.0},		/* selection color */
    2.11 +	{0.63, 0.078, 0.078, 1.0}	/* check color */
    2.12  };
    2.13  
    2.14 +static float alpha = 1.0;
    2.15 +static float bevel = 1.0;
    2.16 +
    2.17  void imtk_set_color(int col, float r, float g, float b, float a)
    2.18  {
    2.19  	assert(col >= 0 && col < sizeof colors / sizeof *colors);
    2.20 @@ -24,7 +30,30 @@
    2.21  
    2.22  float *imtk_get_color(int col)
    2.23  {
    2.24 -	return colors[col];
    2.25 +	static float ret[4];
    2.26 +	memcpy(ret, colors + col, sizeof ret);
    2.27 +	ret[3] *= alpha;
    2.28 +	return ret;
    2.29 +}
    2.30 +
    2.31 +void imtk_set_alpha(float a)
    2.32 +{
    2.33 +	alpha = a;
    2.34 +}
    2.35 +
    2.36 +float imtk_get_alpha(void)
    2.37 +{
    2.38 +	return alpha;
    2.39 +}
    2.40 +
    2.41 +void imtk_set_bevel_width(float b)
    2.42 +{
    2.43 +	bevel = b;
    2.44 +}
    2.45 +
    2.46 +float imtk_get_bevel_width(void)
    2.47 +{
    2.48 +	return bevel;
    2.49  }
    2.50  
    2.51  void imtk_draw_rect(int x, int y, int w, int h, float *color_rgba)
    2.52 @@ -43,20 +72,45 @@
    2.53  void imtk_draw_frame(int x, int y, int w, int h, int style)
    2.54  {
    2.55  	float tcol[4], bcol[4];
    2.56 +	float b = imtk_get_bevel_width();
    2.57  
    2.58  	switch(style) {
    2.59  	case FRAME_INSET:
    2.60 -		memcpy(tcol, colors[IMTK_BEVEL_SHAD_COLOR], sizeof tcol);
    2.61 -		memcpy(bcol, colors[IMTK_BEVEL_LIT_COLOR], sizeof bcol);
    2.62 +		memcpy(tcol, imtk_get_color(IMTK_BEVEL_SHAD_COLOR), sizeof tcol);
    2.63 +		memcpy(bcol, imtk_get_color(IMTK_BEVEL_LIT_COLOR), sizeof bcol);
    2.64  		break;
    2.65  
    2.66  	case FRAME_OUTSET:
    2.67  	default:
    2.68 -		memcpy(tcol, colors[IMTK_BEVEL_LIT_COLOR], sizeof tcol);
    2.69 -		memcpy(bcol, colors[IMTK_BEVEL_SHAD_COLOR], sizeof bcol);
    2.70 +		memcpy(tcol, imtk_get_color(IMTK_BEVEL_LIT_COLOR), sizeof tcol);
    2.71 +		memcpy(bcol, imtk_get_color(IMTK_BEVEL_SHAD_COLOR), sizeof bcol);
    2.72  	}
    2.73  
    2.74 -	glBegin(GL_LINES);
    2.75 +	glBegin(GL_QUADS);
    2.76 +	glColor4fv(tcol);
    2.77 +	glVertex2f(x, y);
    2.78 +	glVertex2f(x + b, y + b);
    2.79 +	glVertex2f(x + w - b, y + b);
    2.80 +	glVertex2f(x + w, y);
    2.81 +
    2.82 +	glVertex2f(x + b, y + b);
    2.83 +	glVertex2f(x, y);
    2.84 +	glVertex2f(x, y + h);
    2.85 +	glVertex2f(x + b, y + h - b);
    2.86 +
    2.87 +	glColor4fv(bcol);
    2.88 +	glVertex2f(x + b, y + h - b);
    2.89 +	glVertex2f(x + w - b, y + h - b);
    2.90 +	glVertex2f(x + w, y + h);
    2.91 +	glVertex2f(x, y + h);
    2.92 +
    2.93 +	glVertex2f(x + w - b, y + b);
    2.94 +	glVertex2f(x + w, y);
    2.95 +	glVertex2f(x + w, y + h);
    2.96 +	glVertex2f(x + w - b, y + h - b);
    2.97 +	glEnd();
    2.98 +
    2.99 +	/*glBegin(GL_LINES);
   2.100  	glColor4fv(tcol);
   2.101  	glVertex2f(x, y + h);
   2.102  	glVertex2f(x, y);
   2.103 @@ -67,7 +121,7 @@
   2.104  	glVertex2f(x + w, y + h);
   2.105  	glVertex2f(x + w, y + h);
   2.106  	glVertex2f(x, y + h);
   2.107 -	glEnd();
   2.108 +	glEnd();*/
   2.109  
   2.110  }
   2.111  
     3.1 --- a/src/draw.h	Sun Apr 17 18:20:23 2011 +0300
     3.2 +++ b/src/draw.h	Mon Apr 18 06:15:46 2011 +0300
     3.3 @@ -6,22 +6,14 @@
     3.4  #else
     3.5  #include <GLUT/glut.h>
     3.6  #endif
     3.7 -
     3.8 -enum {
     3.9 -	IMTK_TEXT_COLOR,
    3.10 -	IMTK_BASE_COLOR,
    3.11 -	IMTK_FOCUS_COLOR,
    3.12 -	IMTK_BEVEL_LIT_COLOR,
    3.13 -	IMTK_BEVEL_SHAD_COLOR
    3.14 -};
    3.15 -
    3.16 +#include "imtk.h"
    3.17  
    3.18  enum {
    3.19  	FRAME_OUTSET,
    3.20  	FRAME_INSET
    3.21  };
    3.22  
    3.23 -void imtk_set_color(int col, float r, float g, float b, float a);
    3.24 +/*void imtk_set_color(int col, float r, float g, float b, float a); in imtk.h */
    3.25  float *imtk_get_color(int col);
    3.26  void imtk_draw_rect(int x, int y, int w, int h, float *color_rgba);
    3.27  void imtk_draw_frame(int x, int y, int w, int h, int style);
     4.1 --- a/src/imtk.c	Sun Apr 17 18:20:23 2011 +0300
     4.2 +++ b/src/imtk.c	Mon Apr 18 06:15:46 2011 +0300
     4.3 @@ -2,7 +2,6 @@
     4.4  #include <stdlib.h>
     4.5  #include <string.h>
     4.6  #include <ctype.h>
     4.7 -#include <stdarg.h>
     4.8  #include <assert.h>
     4.9  #ifndef __APPLE__
    4.10  #include <GL/glut.h>
    4.11 @@ -11,8 +10,14 @@
    4.12  #endif
    4.13  #include "imtk.h"
    4.14  #include "state.h"
    4.15 +#include "draw.h"
    4.16  
    4.17  
    4.18 +void imtk_post_redisplay(void)
    4.19 +{
    4.20 +	glutPostRedisplay();
    4.21 +}
    4.22 +
    4.23  void imtk_begin(void)
    4.24  {
    4.25  	int width, height;
    4.26 @@ -33,6 +38,9 @@
    4.27  	glDisable(GL_DEPTH_TEST);
    4.28  	glDisable(GL_CULL_FACE);
    4.29  	glDisable(GL_LIGHTING);
    4.30 +	glEnable(GL_BLEND);
    4.31 +
    4.32 +	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    4.33  }
    4.34  
    4.35  void imtk_end(void)
    4.36 @@ -45,35 +53,14 @@
    4.37  	glPopMatrix();
    4.38  }
    4.39  
    4.40 -
    4.41 -void imtk_post_redisplay(void)
    4.42 +void imtk_label(const char *str, int x, int y)
    4.43  {
    4.44 -	glutPostRedisplay();
    4.45 +	glColor4fv(imtk_get_color(IMTK_TEXT_COLOR));
    4.46 +	imtk_draw_string(x, y, str);
    4.47  }
    4.48  
    4.49  
    4.50 -/*int imtk_listbox(int id, const char *list, int sel, int x, int y)
    4.51 -{
    4.52 -	int i;
    4.53 -	assert(id >= 0);
    4.54 -
    4.55 -	if(!list) {
    4.56 -		return -1;
    4.57 -	}
    4.58 -
    4.59 -	if(id & 1) {
    4.60 -		id++;
    4.61 -	}
    4.62 -
    4.63 -	for(i=0; *list; i++) {
    4.64 -		if(imtk_button(id + i * 2 + 1, list, x, y + i * 20)) {
    4.65 -			sel = i;
    4.66 -		}
    4.67 -		list += strlen(list) + 1;
    4.68 -	}
    4.69 -	return sel;
    4.70 -}
    4.71 -
    4.72 +/*
    4.73  int imtk_combobox(int id, char *textbuf, size_t buf_sz, const char *list, int sel, int x, int y)
    4.74  {
    4.75  	imtk_textbox(id + 1, textbuf, buf_sz, x, y);
    4.76 @@ -84,44 +71,4 @@
    4.77  	}
    4.78  	return sel;
    4.79  }
    4.80 -
    4.81 -char *imtk_create_list(const char *first, ...)
    4.82 -{
    4.83 -	int sz;
    4.84 -	char *buf, *item;
    4.85 -	va_list ap;
    4.86 -
    4.87 -	if(!first) {
    4.88 -		return 0;
    4.89 -	}
    4.90 -
    4.91 -	sz = strlen(first) + 2;
    4.92 -	if(!(buf = malloc(sz))) {
    4.93 -		return 0;
    4.94 -	}
    4.95 -	memcpy(buf, first, sz - 2);
    4.96 -	buf[sz - 1] = buf[sz - 2] = 0;
    4.97 -
    4.98 -	va_start(ap, first);
    4.99 -	while((item = va_arg(ap, char*))) {
   4.100 -		int len = strlen(item);
   4.101 -		char *tmp = realloc(buf, sz + len + 1);
   4.102 -		if(!tmp) {
   4.103 -			free(buf);
   4.104 -			return 0;
   4.105 -		}
   4.106 -		buf = tmp;
   4.107 -
   4.108 -		memcpy(buf + sz - 1, item, len);
   4.109 -		sz += len + 1;
   4.110 -		buf[sz - 1] = buf[sz - 2] = 0;
   4.111 -	}
   4.112 -	va_end(ap);
   4.113 -
   4.114 -	return buf;
   4.115 -}
   4.116 -
   4.117 -void imtk_free_list(char *list)
   4.118 -{
   4.119 -	free(list);
   4.120 -}*/
   4.121 +*/
     5.1 --- a/src/imtk.h	Sun Apr 17 18:20:23 2011 +0300
     5.2 +++ b/src/imtk.h	Mon Apr 18 06:15:46 2011 +0300
     5.3 @@ -20,6 +20,17 @@
     5.4  	IMTK_RIGHT_BUTTON
     5.5  };
     5.6  
     5.7 +enum {
     5.8 +	IMTK_TEXT_COLOR,
     5.9 +	IMTK_BASE_COLOR,
    5.10 +	IMTK_FOCUS_COLOR,
    5.11 +	IMTK_BEVEL_LIT_COLOR,
    5.12 +	IMTK_BEVEL_SHAD_COLOR,
    5.13 +	IMTK_CURSOR_COLOR,
    5.14 +	IMTK_SELECTION_COLOR,
    5.15 +	IMTK_CHECK_COLOR
    5.16 +};
    5.17 +
    5.18  
    5.19  #ifdef __cplusplus
    5.20  extern "C" {
    5.21 @@ -38,6 +49,7 @@
    5.22  void imtk_begin(void);
    5.23  void imtk_end(void);
    5.24  
    5.25 +void imtk_label(const char *str, int x, int y);
    5.26  int imtk_button(int id, const char *label, int x, int y);
    5.27  int imtk_checkbox(int id, const char *label, int x, int y, int state);
    5.28  void imtk_textbox(int id, char *textbuf, size_t buf_sz, int x, int y);
    5.29 @@ -52,6 +64,13 @@
    5.30  char *imtk_create_list(const char *first, ...);
    5.31  void imtk_free_list(char *list);
    5.32  
    5.33 +/* defined in draw.c */
    5.34 +void imtk_set_color(int col, float r, float g, float b, float a);
    5.35 +void imtk_set_alpha(float a);
    5.36 +float imtk_get_alpha(void);
    5.37 +void imtk_set_bevel_width(float b);
    5.38 +float imtk_get_bevel_width(void);
    5.39 +
    5.40  #ifdef __cplusplus
    5.41  }
    5.42  #endif
     6.1 --- a/src/progress.c	Sun Apr 17 18:20:23 2011 +0300
     6.2 +++ b/src/progress.c	Mon Apr 18 06:15:46 2011 +0300
     6.3 @@ -1,7 +1,8 @@
     6.4  #include "imtk.h"
     6.5  #include "draw.h"
     6.6  
     6.7 -#define SLIDER_SIZE             100
     6.8 +#define PROGR_SIZE             100
     6.9 +#define PROGR_HEIGHT			15
    6.10  
    6.11  static void draw_progress(int id, float pos, int x, int y);
    6.12  
    6.13 @@ -12,18 +13,19 @@
    6.14  
    6.15  static void draw_progress(int id, float pos, int x, int y)
    6.16  {
    6.17 -	int bar_size = SLIDER_SIZE * pos;
    6.18 +	int bar_size = PROGR_SIZE * pos;
    6.19 +	float b = imtk_get_bevel_width();
    6.20  
    6.21  	if(pos < 0.0) pos = 0.0;
    6.22  	if(pos > 1.0) pos = 1.0;
    6.23  
    6.24  	/* through */
    6.25 -	imtk_draw_rect(x - 1, y - 1, SLIDER_SIZE + 1, 18, imtk_get_color(IMTK_BASE_COLOR));
    6.26 -	imtk_draw_frame(x - 1, y - 1, SLIDER_SIZE + 2, 17, FRAME_INSET);
    6.27 +	imtk_draw_rect(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, imtk_get_color(IMTK_BASE_COLOR));
    6.28 +	imtk_draw_frame(x - b, y - b, PROGR_SIZE + b * 2, PROGR_HEIGHT + b * 2, FRAME_INSET);
    6.29  
    6.30  	if(pos > 0.0) {
    6.31  		/* bar */
    6.32 -		imtk_draw_rect(x, y, bar_size, 15, imtk_get_color(IMTK_BASE_COLOR));
    6.33 -		imtk_draw_frame(x, y, bar_size, 15, FRAME_OUTSET);
    6.34 +		imtk_draw_rect(x, y, bar_size, PROGR_HEIGHT, imtk_get_color(IMTK_BASE_COLOR));
    6.35 +		imtk_draw_frame(x, y, bar_size, PROGR_HEIGHT, FRAME_OUTSET);
    6.36  	}
    6.37  }
     7.1 --- a/src/textbox.c	Sun Apr 17 18:20:23 2011 +0300
     7.2 +++ b/src/textbox.c	Mon Apr 18 06:15:46 2011 +0300
     7.3 @@ -76,7 +76,7 @@
     7.4  
     7.5  	if(imtk_has_focus(id)) {
     7.6  		glBegin(GL_LINES);
     7.7 -		glColor4f(0.8, 0.25, 0.18, imtk_get_color(IMTK_TEXT_COLOR)[3]);
     7.8 +		glColor4fv(imtk_get_color(IMTK_CURSOR_COLOR));
     7.9  		glVertex2f(x + strsz + 3, y + 2);
    7.10  		glVertex2f(x + strsz + 3, y + 18);
    7.11  		glVertex2f(x + strsz + 4, y + 2);
     8.1 --- a/test.c	Sun Apr 17 18:20:23 2011 +0300
     8.2 +++ b/test.c	Mon Apr 18 06:15:46 2011 +0300
     8.3 @@ -53,6 +53,9 @@
     8.4  	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
     8.5  	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60.0);
     8.6  
     8.7 +	/*imtk_set_color(IMTK_BEVEL_LIT_COLOR, 0.3, 0.3, 0.3, 0.5);
     8.8 +	imtk_set_color(IMTK_BEVEL_SHAD_COLOR, 0.3, 0.3, 0.3, 0.5);*/
     8.9 +
    8.10  	glutMainLoop();
    8.11  	return 0;
    8.12  }
    8.13 @@ -61,15 +64,31 @@
    8.14  {
    8.15  	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    8.16  
    8.17 -	glViewport(200, 0, xsz - 200, ysz);
    8.18 +	glMatrixMode(GL_MODELVIEW);
    8.19 +	glLoadIdentity();
    8.20 +	glMatrixMode(GL_PROJECTION);
    8.21 +	glPushMatrix();
    8.22 +	glLoadIdentity();
    8.23  
    8.24 -	glMatrixMode(GL_PROJECTION);
    8.25 -	glLoadIdentity();
    8.26 -	gluPerspective(45.0, (float)(xsz - 200) / (float)ysz, 1.0, 1000.0);
    8.27 +	glPushAttrib(GL_ENABLE_BIT);
    8.28 +	glDisable(GL_LIGHTING);
    8.29 +	glDisable(GL_DEPTH_TEST);
    8.30 +
    8.31 +	glBegin(GL_QUADS);
    8.32 +	glColor3f(0.3, 0.4, 0.8);
    8.33 +	glVertex2f(-1, -1);
    8.34 +	glVertex2f(1, -1);
    8.35 +	glColor3f(0.7, 0.3, 0.2);
    8.36 +	glVertex2f(1, 1);
    8.37 +	glVertex2f(-1, 1);
    8.38 +	glEnd();
    8.39 +
    8.40 +	glPopAttrib();
    8.41 +	glPopMatrix();
    8.42  
    8.43  	glMatrixMode(GL_MODELVIEW);
    8.44  	glLoadIdentity();
    8.45 -	glTranslatef(0, 0, -8);
    8.46 +	glTranslatef(0, 0, -4);
    8.47  	glRotatef(25, 1, 0, 0);
    8.48  	glRotatef(angle, 0, 1, 0);
    8.49  
    8.50 @@ -93,9 +112,6 @@
    8.51  	}
    8.52  
    8.53  
    8.54 -	glViewport(0, 0, 200, ysz);
    8.55 -	imtk_set_viewport(200, ysz);
    8.56 -
    8.57  	gui();
    8.58  
    8.59  	glutSwapBuffers();
    8.60 @@ -113,13 +129,13 @@
    8.61  
    8.62  	imtk_begin();
    8.63  
    8.64 -	glBegin(GL_QUADS);
    8.65 +	/*glBegin(GL_QUADS);
    8.66  	glColor3f(0.6, 0.6, 0.6);
    8.67  	glVertex2f(0, 0);
    8.68  	glVertex2f(200, 0);
    8.69  	glVertex2f(200, glutGet(GLUT_WINDOW_HEIGHT));
    8.70  	glVertex2f(0, glutGet(GLUT_WINDOW_HEIGHT));
    8.71 -	glEnd();
    8.72 +	glEnd();*/
    8.73  
    8.74  	if(imtk_button(IMUID, "red", 30, 50)) {
    8.75  		float color[] = {1, 0.4, 0.3, 1};
    8.76 @@ -158,6 +174,9 @@
    8.77  
    8.78  	imtk_progress(IMUID, val / 360.0, 30, 420);
    8.79  
    8.80 +	imtk_label("alpha:", 24, 473);
    8.81 +	imtk_set_alpha(imtk_slider(IMUID, imtk_get_alpha(), 0.0, 1.0, 60, 470));
    8.82 +
    8.83  	if(imtk_button(IMUID, "Quit", 30, 500)) {
    8.84  		exit(0);
    8.85  	}
    8.86 @@ -171,6 +190,11 @@
    8.87  	ysz = y;
    8.88  
    8.89  	glViewport(0, 0, x, y);
    8.90 +	imtk_set_viewport(x, y);
    8.91 +
    8.92 +	glMatrixMode(GL_PROJECTION);
    8.93 +	glLoadIdentity();
    8.94 +	gluPerspective(45.0, (float)xsz / (float)ysz, 1.0, 1000.0);
    8.95  }
    8.96  
    8.97  void keyb(unsigned char key, int x, int y)