imtk
diff test.c @ 4:00a4ea4ee6dc
attempt at slightly more complex widgets
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 05 Mar 2011 09:25:27 +0200 |
parents | 038e5577d527 |
children | 6d35e6c7b2ca |
line diff
1.1 --- a/test.c Fri Dec 31 18:10:13 2010 +0200 1.2 +++ b/test.c Sat Mar 05 09:25:27 2011 +0200 1.3 @@ -20,6 +20,7 @@ 1.4 1.5 int xsz, ysz; 1.6 float angle; 1.7 +int objsel; 1.8 1.9 int main(int argc, char **argv) 1.10 { 1.11 @@ -72,9 +73,24 @@ 1.12 glRotatef(25, 1, 0, 0); 1.13 glRotatef(angle, 0, 1, 0); 1.14 1.15 - glFrontFace(GL_CW); 1.16 - glutSolidTeapot(1.0); 1.17 - glFrontFace(GL_CCW); 1.18 + switch(objsel) { 1.19 + case 0: 1.20 + glFrontFace(GL_CW); 1.21 + glutSolidTeapot(1.0); 1.22 + glFrontFace(GL_CCW); 1.23 + break; 1.24 + 1.25 + case 1: 1.26 + glutSolidTorus(0.5, 1, 12, 24); 1.27 + break; 1.28 + 1.29 + case 2: 1.30 + glutSolidSphere(1.0, 24, 12); 1.31 + break; 1.32 + 1.33 + default: 1.34 + break; 1.35 + } 1.36 1.37 1.38 glViewport(0, 0, 200, ysz); 1.39 @@ -92,6 +108,8 @@ 1.40 static char textbuf[256]; 1.41 static char textbuf2[256]; 1.42 static float val; 1.43 + static int prev_sel; 1.44 + char *itemlist; 1.45 1.46 imtk_begin(); 1.47 1.48 @@ -108,12 +126,19 @@ 1.49 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); 1.50 glutPostRedisplay(); 1.51 } 1.52 - if(imtk_button(IMUID, "blue", 30, 100)) { 1.53 + if(imtk_button(IMUID, "blue", 30, 80)) { 1.54 float color[] = {0.3, 0.4, 1, 1}; 1.55 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color); 1.56 glutPostRedisplay(); 1.57 } 1.58 1.59 + itemlist = imtk_create_list("teapot", "torus", "sphere", NULL); 1.60 + if((objsel = imtk_listbox(IMUID, itemlist, prev_sel, 30, 120)) != prev_sel) { 1.61 + prev_sel = objsel; 1.62 + glutPostRedisplay(); 1.63 + } 1.64 + imtk_free_list(itemlist); 1.65 + 1.66 imtk_textbox(IMUID, textbuf, sizeof textbuf, 30, 200); 1.67 imtk_textbox(IMUID, textbuf2, sizeof textbuf2, 30, 250); 1.68