imtk
diff test.c @ 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 | 467a520f5c00 |
children | df2bc9406561 |
line diff
1.1 --- a/test.c Sun Apr 17 18:20:23 2011 +0300 1.2 +++ b/test.c Mon Apr 18 06:15:46 2011 +0300 1.3 @@ -53,6 +53,9 @@ 1.4 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); 1.5 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60.0); 1.6 1.7 + /*imtk_set_color(IMTK_BEVEL_LIT_COLOR, 0.3, 0.3, 0.3, 0.5); 1.8 + imtk_set_color(IMTK_BEVEL_SHAD_COLOR, 0.3, 0.3, 0.3, 0.5);*/ 1.9 + 1.10 glutMainLoop(); 1.11 return 0; 1.12 } 1.13 @@ -61,15 +64,31 @@ 1.14 { 1.15 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.16 1.17 - glViewport(200, 0, xsz - 200, ysz); 1.18 + glMatrixMode(GL_MODELVIEW); 1.19 + glLoadIdentity(); 1.20 + glMatrixMode(GL_PROJECTION); 1.21 + glPushMatrix(); 1.22 + glLoadIdentity(); 1.23 1.24 - glMatrixMode(GL_PROJECTION); 1.25 - glLoadIdentity(); 1.26 - gluPerspective(45.0, (float)(xsz - 200) / (float)ysz, 1.0, 1000.0); 1.27 + glPushAttrib(GL_ENABLE_BIT); 1.28 + glDisable(GL_LIGHTING); 1.29 + glDisable(GL_DEPTH_TEST); 1.30 + 1.31 + glBegin(GL_QUADS); 1.32 + glColor3f(0.3, 0.4, 0.8); 1.33 + glVertex2f(-1, -1); 1.34 + glVertex2f(1, -1); 1.35 + glColor3f(0.7, 0.3, 0.2); 1.36 + glVertex2f(1, 1); 1.37 + glVertex2f(-1, 1); 1.38 + glEnd(); 1.39 + 1.40 + glPopAttrib(); 1.41 + glPopMatrix(); 1.42 1.43 glMatrixMode(GL_MODELVIEW); 1.44 glLoadIdentity(); 1.45 - glTranslatef(0, 0, -8); 1.46 + glTranslatef(0, 0, -4); 1.47 glRotatef(25, 1, 0, 0); 1.48 glRotatef(angle, 0, 1, 0); 1.49 1.50 @@ -93,9 +112,6 @@ 1.51 } 1.52 1.53 1.54 - glViewport(0, 0, 200, ysz); 1.55 - imtk_set_viewport(200, ysz); 1.56 - 1.57 gui(); 1.58 1.59 glutSwapBuffers(); 1.60 @@ -113,13 +129,13 @@ 1.61 1.62 imtk_begin(); 1.63 1.64 - glBegin(GL_QUADS); 1.65 + /*glBegin(GL_QUADS); 1.66 glColor3f(0.6, 0.6, 0.6); 1.67 glVertex2f(0, 0); 1.68 glVertex2f(200, 0); 1.69 glVertex2f(200, glutGet(GLUT_WINDOW_HEIGHT)); 1.70 glVertex2f(0, glutGet(GLUT_WINDOW_HEIGHT)); 1.71 - glEnd(); 1.72 + glEnd();*/ 1.73 1.74 if(imtk_button(IMUID, "red", 30, 50)) { 1.75 float color[] = {1, 0.4, 0.3, 1}; 1.76 @@ -158,6 +174,9 @@ 1.77 1.78 imtk_progress(IMUID, val / 360.0, 30, 420); 1.79 1.80 + imtk_label("alpha:", 24, 473); 1.81 + imtk_set_alpha(imtk_slider(IMUID, imtk_get_alpha(), 0.0, 1.0, 60, 470)); 1.82 + 1.83 if(imtk_button(IMUID, "Quit", 30, 500)) { 1.84 exit(0); 1.85 } 1.86 @@ -171,6 +190,11 @@ 1.87 ysz = y; 1.88 1.89 glViewport(0, 0, x, y); 1.90 + imtk_set_viewport(x, y); 1.91 + 1.92 + glMatrixMode(GL_PROJECTION); 1.93 + glLoadIdentity(); 1.94 + gluPerspective(45.0, (float)xsz / (float)ysz, 1.0, 1000.0); 1.95 } 1.96 1.97 void keyb(unsigned char key, int x, int y)