5 static void display(void);
6 static void reshape(int x, int y);
7 static void keyb(unsigned char key, int x, int y);
8 static void mouse(int bn, int st, int x, int y);
9 static void motion(int x, int y);
11 static int win_width, win_height;
12 static float win_aspect;
14 static struct erb_rend *erb;
16 static int mouse_x, mouse_y;
17 static int drag_x, drag_y;
21 int main(int argc, char **argv)
23 glutInit(&argc, argv);
24 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
25 glutInitWindowSize(1280, 800);
26 glutCreateWindow("X erebus");
28 glutDisplayFunc(display);
29 glutReshapeFunc(reshape);
30 glutKeyboardFunc(keyb);
32 glutMotionFunc(motion);
34 if(!(erb = erb_create())) {
44 static void display(void)
49 erb_allocframe(erb, x, y);
52 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, win_width, win_height, 0,
53 GL_RGB, GL_FLOAT, erb_getframe(erb));
55 /* TODO: continue with getting notified when a block is done rendering */
57 glClear(GL_COLOR_BUFFER_BIT);
60 glEnable(GL_LOGIC_OP);
63 glBegin(GL_LINE_LOOP);
65 glVertex2f(drag_x, drag_y);
66 glVertex2f(mouse_x, drag_y);
67 glVertex2f(mouse_x, mouse_y);
68 glVertex2f(drag_x, mouse_y);
71 glDisable(GL_LOGIC_OP);
77 static void reshape(int x, int y)
81 win_aspect = (float)x / (float)y;
83 glViewport(0, 0, x, y);
85 glMatrixMode(GL_PROJECTION);
87 glOrtho(0, x, y, 0, -1, 1);
93 static void keyb(unsigned char key, int x, int y)
100 static void mouse(int bn, int st, int x, int y)
108 if(st == GLUT_DOWN) {
115 rect[0] = x < drag_x ? x : drag_x;
116 rect[1] = y < drag_y ? y : drag_y;
117 rect[2] = abs(x - drag_x);
118 rect[3] = abs(y - drag_y);
119 printf("rect: %d,%d %dx%d\n", rect[0], rect[1], rect[2], rect[3]);
126 static void motion(int x, int y)