6 static void display(void);
7 static void reshape(int x, int y);
8 static void keypress(unsigned char key, int x, int y);
9 static void keyrelease(unsigned char key, int x, int y);
10 static void mouse(int bn, int st, int x, int y);
11 static void motion(int x, int y);
13 static int gfx_newcol(int r, int g, int b);
14 static void gfx_color(int c);
15 static void gfx_fillrect(struct wt_rect *r);
16 static void gfx_line(int x0, int y0, int x1, int y1);
18 static struct wt_graphics gfx = {
19 gfx_newcol, gfx_color,
24 int main(int argc, char **argv)
26 glutInit(&argc, argv);
27 glutInitWindowSize(800, 600);
28 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
29 glutCreateWindow("windtk example");
31 glutDisplayFunc(display);
32 glutReshapeFunc(reshape);
33 glutKeyboardFunc(keypress);
34 glutKeyboardUpFunc(keyrelease);
36 glutMotionFunc(motion);
37 glutPassiveMotionFunc(motion);
39 if(wt_init(800, 600, &gfx)) {
47 static void display(void)
49 glClear(GL_COLOR_BUFFER_BIT);
54 static void reshape(int x, int y)
56 glViewport(0, 0, x, y);
57 glMatrixMode(GL_PROJECTION);
59 glOrtho(0, x, y, 0, -1, 1);
61 wt_viewport(0, 0, x, y);
64 static void keypress(unsigned char key, int x, int y)
66 if(key == 27) exit(0);
71 static void keyrelease(unsigned char key, int x, int y)
76 static void mouse(int bn, int st, int x, int y)
78 wt_inp_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
81 static void motion(int x, int y)
86 /* ------ graphics callbacks -------- */
87 static float colors[32][3];
90 static int gfx_newcol(int r, int g, int b)
92 if(maxcol >= 32) return -1;
93 colors[maxcol][0] = r / 255.0f;
94 colors[maxcol][1] = g / 255.0f;
95 colors[maxcol][2] = b / 255.0f;
99 static void gfx_color(int c)
101 glColor3fv(colors[c]);
104 static void gfx_fillrect(struct wt_rect *r)
107 glVertex2f(r->x, r->y);
108 glVertex2f(r->x + r->width, r->y);
109 glVertex2f(r->x + r->width, r->y + r->height);
110 glVertex2f(r->x, r->y + r->height);
114 static void gfx_line(int x0, int y0, int x1, int y1)