From c61782958b00aeaac4dae3b24b6ff26a1be53e8b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 6 Apr 2005 22:41:46 +0000 Subject: [PATCH] added wrappers/helpers for creating/destroying rendering contexts --- progs/xdemos/pbutil.c | 38 +++++++++++++++++++++++++++++++++++++- progs/xdemos/pbutil.h | 8 ++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/progs/xdemos/pbutil.c b/progs/xdemos/pbutil.c index 479abc983ca..d0bbd1b0fce 100644 --- a/progs/xdemos/pbutil.c +++ b/progs/xdemos/pbutil.c @@ -9,7 +9,6 @@ * to the GLX_SGIX_fbconfig/pbuffer extensions. */ - #include #include #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) diff --git a/progs/xdemos/pbutil.h b/progs/xdemos/pbutil.h index e877f20625d..e95b2565a23 100644 --- a/progs/xdemos/pbutil.h +++ b/progs/xdemos/pbutil.h @@ -46,6 +46,14 @@ extern XVisualInfo * GetVisualFromFBConfig(Display *dpy, int screen, FBCONFIG config); +extern GLXContext +CreateContext(Display *dpy, int screen, FBCONFIG config); + + +extern void +DestroyContext(Display *dpy, GLXContext ctx); + + extern PBUFFER CreatePbuffer(Display *dpy, int screen, FBCONFIG config, int width, int height, Bool preserve, Bool largest); -- 2.30.2