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)) {
42 wt_window(0, "foo", WT_WS_DEFAULT, 10, 10, 200, 200);
48 static void display(void)
50 glClear(GL_COLOR_BUFFER_BIT);
57 static void reshape(int x, int y)
59 glViewport(0, 0, x, y);
60 glMatrixMode(GL_PROJECTION);
62 glOrtho(0, x, y, 0, -1, 1);
64 wt_viewport(0, 0, x, y);
67 static void keypress(unsigned char key, int x, int y)
69 if(key == 27) exit(0);
74 static void keyrelease(unsigned char key, int x, int y)
79 static void mouse(int bn, int st, int x, int y)
81 wt_inp_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
84 static void motion(int x, int y)
89 /* ------ graphics callbacks -------- */
90 static float colors[32][3];
93 static int gfx_newcol(int r, int g, int b)
95 if(maxcol >= 32) return -1;
96 colors[maxcol][0] = r / 255.0f;
97 colors[maxcol][1] = g / 255.0f;
98 colors[maxcol][2] = b / 255.0f;
102 static void gfx_color(int c)
104 glColor3fv(colors[c]);
107 static void gfx_fillrect(struct wt_rect *r)
110 glVertex2f(r->x, r->y);
111 glVertex2f(r->x + r->width, r->y);
112 glVertex2f(r->x + r->width, r->y + r->height);
113 glVertex2f(r->x, r->y + r->height);
117 static void gfx_line(int x0, int y0, int x1, int y1)