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 glClearColor(0.6, 0.6, 0.6, 1);
41 if(wt_init(800, 600, &gfx)) {
44 wt_window(0, "foo", WT_WS_DEFAULT, 100, 100, 200, 200);
50 static void display(void)
52 glClear(GL_COLOR_BUFFER_BIT);
59 static void reshape(int x, int y)
61 glViewport(0, 0, x, y);
62 glMatrixMode(GL_PROJECTION);
64 glOrtho(0, x, y, 0, -1, 1);
66 wt_viewport(0, 0, x, y);
69 static void keypress(unsigned char key, int x, int y)
71 if(key == 27) exit(0);
76 static void keyrelease(unsigned char key, int x, int y)
81 static void mouse(int bn, int st, int x, int y)
83 wt_inp_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
86 static void motion(int x, int y)
91 /* ------ graphics callbacks -------- */
92 static float colors[32][3];
95 static int gfx_newcol(int r, int g, int b)
97 if(maxcol >= 32) return -1;
98 colors[maxcol][0] = r / 255.0f;
99 colors[maxcol][1] = g / 255.0f;
100 colors[maxcol][2] = b / 255.0f;
104 static void gfx_color(int c)
106 glColor3fv(colors[c]);
109 static void gfx_fillrect(struct wt_rect *r)
112 glVertex2f(r->x, r->y);
113 glVertex2f(r->x + r->width, r->y);
114 glVertex2f(r->x + r->width, r->y + r->height);
115 glVertex2f(r->x, r->y + r->height);
119 static void gfx_line(int x0, int y0, int x1, int y1)