16# define M_PI 3.14159265
21static Bool WaitForNotify(Display *d, XEvent *e,
char *arg)
23 return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
34int ui_loop(
int argc,
char **argv,
const char *name)
38 XSetWindowAttributes swa;
46 XComposeStatus status;
49 dpy = XOpenDisplay(NULL);
51 fprintf(stderr,
"Could not open X display\n");
58 fprintf(stderr,
"No suitable visual for glx\n");
66 cmap = XCreateColormap(
dpy, RootWindow(
dpy, vi->screen),
67 vi->visual, AllocNone);
76 hint.flags = PPosition | PSize;
79 swa.event_mask = StructureNotifyMask;
80 win = XCreateWindow(
dpy, RootWindow(
dpy, vi->screen), 0, 0, width, height,
81 0, vi->depth, InputOutput, vi->visual,
82 CWBorderPixel|CWColormap|CWEventMask, &swa);
83 XSetStandardProperties (
dpy,
win, name, name, None, NULL, 0, &hint);
86 XIfEvent(
dpy, &event, WaitForNotify, (
char*)
win);
87 XSelectInput(
dpy,
win, KeyPressMask | StructureNotifyMask | ExposureMask);
96 if (XPending(
dpy) > 0) {
100 XLookupString((XKeyEvent *)&xev,buf,80,&keysym,&status);
122 case ConfigureNotify:
125 width = xev.xconfigure.width;
126 height = xev.xconfigure.height;
GLenum key(int k, GLenum mask)
void reshape(int width, int height)
GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct)
Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)
XVisualInfo * glXChooseVisual(Display *dpy, int screen, int *attribList)
void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
int ui_loop(int argc, char **argv, const char *name)