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 void gfx_color(int r, int g, int b);
14 static void gfx_fillrect(struct ag_rect *r);
15 static void gfx_line(int x0, int y0, int x1, int y1);
17 static struct ag_graphics gfx = {
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(ag_init(800, 600, &gfx) == -1) {
44 ag_window(0, "foo", AG_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 ag_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 ag_inp_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
86 static void motion(int x, int y)
91 /* ------ graphics callbacks -------- */
92 static void gfx_color(int r, int g, int b)
97 static void gfx_fillrect(struct ag_rect *r)
100 glVertex2f(r->x, r->y);
101 glVertex2f(r->x + r->w, r->y);
102 glVertex2f(r->x + r->w, r->y + r->h);
103 glVertex2f(r->x, r->y + r->h);
107 static void gfx_line(int x0, int y0, int x1, int y1)