From 4b596b1ac8a11facfd685d2f602d8ca0cb3bca94 Mon Sep 17 00:00:00 2001 From: ikits Date: Sat, 27 Sep 2003 06:56:18 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@143 783a27ee-832a-0410-bc00-9f386506c6dd --- auto/src/glewinfo_post.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/auto/src/glewinfo_post.c b/auto/src/glewinfo_post.c index c48fa00..907e231 100644 --- a/auto/src/glewinfo_post.c +++ b/auto/src/glewinfo_post.c @@ -101,13 +101,46 @@ void glewDestroyContext () # ifdef __APPLE__ +Display* dpy = NULL; +XVisualInfo* vi = NULL; +GLXContext ctx = NULL; +Window wnd; +Colormap cmap; + GLboolean glewCreateContext () { - return GL_TRUE; + int attrib[] = { GLX_RGBA, None }; + int erb, evb; + XSetWindowAttributes swa; + /* open display */ + dpy = XOpenDisplay(NULL); + if (NULL == dpy) return GL_TRUE; + /* query for glx */ + if (!glXQueryExtension(dpy, &erb, &evb)) return GL_TRUE; + /* choose visual */ + vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrib); + if (NULL == vi) return GL_TRUE; + /* create context */ + ctx = glXCreateContext(dpy, vi, None, True); + if (NULL == ctx) return GL_TRUE; + /* create window */ + /*wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 1, 0, 0);*/ + cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); + swa.border_pixel = 0; + swa.colormap = cmap; + wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 256, 256, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap, &swa); + /* make context current */ + if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE; + return GL_FALSE; } void glewDestroyContext () { + if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx); + if (NULL != dpy) XDestroyWindow(dpy, wnd); + if (NULL != dpy) XFreeColormap(dpy, cmap); + if (NULL != vi) XFree(vi); + if (NULL != dpy) XCloseDisplay(dpy); } # else /* __linux || __sgi */