diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2005-04-06 22:41:46 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2005-04-06 22:41:46 +0000 |
commit | c61782958b00aeaac4dae3b24b6ff26a1be53e8b (patch) | |
tree | 18d34a9a1ef6e1a9f081b3a84ffcb7524ac36987 /progs/xdemos/pbutil.c | |
parent | c3984fc01595e40cabc77ed45d9e76625a3152e2 (diff) |
added wrappers/helpers for creating/destroying rendering contexts
Diffstat (limited to 'progs/xdemos/pbutil.c')
-rw-r--r-- | progs/xdemos/pbutil.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/progs/xdemos/pbutil.c b/progs/xdemos/pbutil.c index 479abc983c..d0bbd1b0fc 100644 --- a/progs/xdemos/pbutil.c +++ b/progs/xdemos/pbutil.c @@ -9,7 +9,6 @@ * to the GLX_SGIX_fbconfig/pbuffer extensions. */ - #include <stdio.h> #include <string.h> #include "pbutil.h" @@ -293,6 +292,43 @@ PrintFBConfigInfo(Display *dpy, int screen, FBCONFIG config, Bool horizFormat) +GLXContext +CreateContext(Display *dpy, int screen, FBCONFIG config) +{ + int pbSupport = QueryPbuffers(dpy, screen); +#if defined(GLX_VERSION_1_3) + if (pbSupport == 1) { + /* GLX 1.3 */ + GLXContext c; + c = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, True); + if (!c) { + /* try indirect */ + c = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, False); + } + return c; + } +#endif +#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer) + if (pbSupport == 2) { + GLXContext c; + c = glXCreateContextWithConfigSGIX(dpy, config, GLX_RGBA_TYPE_SGIX, NULL, True); + if (!c) { + c = glXCreateContextWithConfigSGIX(dpy, config, GLX_RGBA_TYPE_SGIX, NULL, False); + } + return c; + } +#endif + return 0; +} + + +void +DestroyContext(Display *dpy, GLXContext ctx) +{ + glXDestroyContext(dpy, ctx); +} + + /* This is only used by CreatePbuffer() */ static int XErrorFlag = 0; static int HandleXError(Display *dpy, XErrorEvent *event) |