glamtk

changeset 5:86ba127ac2f2

trying to put some glamour in the toolkit
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 09 Mar 2011 01:13:28 +0200
parents 00a4ea4ee6dc
children 9b623dc0f296
files test.c
diffstat 1 files changed, 27 insertions(+), 16 deletions(-) [+]
line diff
     1.1 --- a/test.c	Sat Mar 05 09:25:27 2011 +0200
     1.2 +++ b/test.c	Wed Mar 09 01:13:28 2011 +0200
     1.3 @@ -61,14 +61,31 @@
     1.4  {
     1.5  	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     1.6  
     1.7 -	glViewport(200, 0, xsz - 200, ysz);
     1.8 -
     1.9 -	glMatrixMode(GL_PROJECTION);
    1.10 -	glLoadIdentity();
    1.11 -	gluPerspective(45.0, (float)(xsz - 200) / (float)ysz, 1.0, 1000.0);
    1.12 +	glPushAttrib(GL_ENABLE_BIT);
    1.13 +	glDisable(GL_LIGHTING);
    1.14 +	glDisable(GL_DEPTH_TEST);
    1.15  
    1.16  	glMatrixMode(GL_MODELVIEW);
    1.17  	glLoadIdentity();
    1.18 +
    1.19 +	glMatrixMode(GL_PROJECTION);
    1.20 +	glPushMatrix();
    1.21 +	glLoadIdentity();
    1.22 +
    1.23 +	glBegin(GL_QUADS);
    1.24 +	glColor3f(0.2, 0.3, 0.7);
    1.25 +	glVertex2f(1, 1);
    1.26 +	glVertex2f(-1, 1);
    1.27 +	glColor3f(0.7, 0.3, 0.2);
    1.28 +	glVertex2f(-1, -1);
    1.29 +	glVertex2f(1, -1);
    1.30 +	glEnd();
    1.31 +
    1.32 +	glPopMatrix();
    1.33 +	glMatrixMode(GL_MODELVIEW);
    1.34 +
    1.35 +	glPopAttrib();
    1.36 +
    1.37  	glTranslatef(0, 0, -8);
    1.38  	glRotatef(25, 1, 0, 0);
    1.39  	glRotatef(angle, 0, 1, 0);
    1.40 @@ -93,9 +110,6 @@
    1.41  	}
    1.42  
    1.43  
    1.44 -	glViewport(0, 0, 200, ysz);
    1.45 -	imtk_inp_reshape(200, ysz);
    1.46 -
    1.47  	gui();
    1.48  
    1.49  	glutSwapBuffers();
    1.50 @@ -113,14 +127,6 @@
    1.51  
    1.52  	imtk_begin();
    1.53  
    1.54 -	glBegin(GL_QUADS);
    1.55 -	glColor3f(0.6, 0.6, 0.6);
    1.56 -	glVertex2f(0, 0);
    1.57 -	glVertex2f(200, 0);
    1.58 -	glVertex2f(200, glutGet(GLUT_WINDOW_HEIGHT));
    1.59 -	glVertex2f(0, glutGet(GLUT_WINDOW_HEIGHT));
    1.60 -	glEnd();
    1.61 -
    1.62  	if(imtk_button(IMUID, "red", 30, 50)) {
    1.63  		float color[] = {1, 0.4, 0.3, 1};
    1.64  		glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
    1.65 @@ -171,6 +177,11 @@
    1.66  	ysz = y;
    1.67  
    1.68  	glViewport(0, 0, x, y);
    1.69 +	imtk_inp_reshape(x, y);
    1.70 +
    1.71 +	glMatrixMode(GL_PROJECTION);
    1.72 +	glLoadIdentity();
    1.73 +	gluPerspective(45.0, (float)x / (float)y, 1.0, 1000.0);
    1.74  }
    1.75  
    1.76  void keyb(unsigned char key, int x, int y)