include some error-checking from glx-dbl-bare and change direct to GL_TRUE in glXCreateContext() call
This commit is contained in:
parent
51aa9075e1
commit
d71c26b02b
@ -2,6 +2,7 @@
|
||||
#include <GL/glx.h>
|
||||
#include <GL/gl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
static int attributeList[] = { GLX_RGBA, None };
|
||||
static Bool WaitForNotify(Display *d, XEvent *e, char *arg) {
|
||||
return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
|
||||
@ -15,11 +16,28 @@ int main(int argc, char **argv) {
|
||||
GLXContext cx;
|
||||
XEvent event;
|
||||
/* get a connection */
|
||||
dpy = XOpenDisplay(0);
|
||||
dpy = XOpenDisplay(NULL);
|
||||
if (dpy == NULL)
|
||||
{
|
||||
fprintf(stderr, "XOpenDisplay() returned NULL\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* get an appropriate visual */
|
||||
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributeList);
|
||||
if (vi == NULL)
|
||||
{
|
||||
fprintf(stderr, "glXChooseVisual() returned NULL\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* create a GLX context */
|
||||
cx = glXCreateContext(dpy, vi, 0, GL_FALSE);
|
||||
cx = glXCreateContext(dpy, vi, NULL, GL_TRUE);
|
||||
if (cx == NULL)
|
||||
{
|
||||
fprintf(stderr, "glXCreateContext() returned NULL\n");
|
||||
return 2;
|
||||
}
|
||||
/* create a color map */
|
||||
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen),
|
||||
vi->visual, AllocNone);
|
||||
@ -33,11 +51,19 @@ int main(int argc, char **argv) {
|
||||
XMapWindow(dpy, win);
|
||||
XIfEvent(dpy, &event, WaitForNotify, (char*)win);
|
||||
/* connect the context to the window */
|
||||
glXMakeCurrent(dpy, win, cx);
|
||||
if (glXMakeCurrent(dpy, win, cx) == GL_FALSE)
|
||||
{
|
||||
fprintf(stderr, "glXMakeCurrent() returned false\n");
|
||||
return 2;
|
||||
}
|
||||
/* clear the buffer */
|
||||
glClearColor(1,1,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glFlush();
|
||||
/* wait a while */
|
||||
sleep(10);
|
||||
sleep(5);
|
||||
|
||||
/* teardown */
|
||||
XFree(vi);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user