/* Some ugly global vars */
-static GLXFBConfigSGIX gFBconfig = 0;
static Display *gDpy = NULL;
static int gScreen = 0;
-static GLXPbufferSGIX gPBuffer = 0;
+static FBCONFIG gFBconfig = 0;
+static PBUFFER gPBuffer = 0;
static int gWidth, gHeight;
+static GLXContext glCtx;
/*
- * Create the pbuffer and return a GLXPbufferSGIX handle.
+ * Create the pbuffer and return a GLXPbuffer handle.
*
* We loop over a list of fbconfigs trying to create
* a pixel buffer. We return the first pixel buffer which we successfully
* create.
*/
-static GLXPbufferSGIX
+static PBUFFER
MakePbuffer( Display *dpy, int screen, int width, int height )
{
#define NUM_FB_CONFIGS 4
int fbAttribs[NUM_FB_CONFIGS][100] = {
{
/* Single buffered, with depth buffer */
- GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
- GLX_DRAWABLE_TYPE_SGIX, GLX_PIXMAP_BIT_SGIX,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
},
{
/* Double buffered, with depth buffer */
- GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
- GLX_DRAWABLE_TYPE_SGIX, GLX_PIXMAP_BIT_SGIX,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
},
{
/* Single bufferd, without depth buffer */
- GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
- GLX_DRAWABLE_TYPE_SGIX, GLX_PIXMAP_BIT_SGIX,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
},
{
/* Double bufferd, without depth buffer */
- GLX_RENDER_TYPE_SGIX, GLX_RGBA_BIT_SGIX,
- GLX_DRAWABLE_TYPE_SGIX, GLX_PIXMAP_BIT_SGIX,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None
}
};
- int pbAttribs[] = {
- GLX_LARGEST_PBUFFER_SGIX, True,
- GLX_PRESERVED_CONTENTS_SGIX, False,
- None
- };
- GLXFBConfigSGIX *fbConfigs;
- GLXPbufferSGIX pBuffer = None;
+ Bool largest = True;
+ Bool preserve = False;
+ FBCONFIG *fbConfigs;
+ PBUFFER pBuffer = None;
int nConfigs;
int i;
int attempt;
for (attempt=0; attempt<NUM_FB_CONFIGS; attempt++) {
/* Get list of possible frame buffer configurations */
- fbConfigs = glXChooseFBConfigSGIX(dpy, screen, fbAttribs[attempt], &nConfigs);
+ fbConfigs = ChooseFBConfig(dpy, screen, fbAttribs[attempt], &nConfigs);
if (nConfigs==0 || !fbConfigs) {
- printf("Error: glxChooseFBConfigSGIX failed\n");
+ printf("Error: glXChooseFBConfig failed\n");
XCloseDisplay(dpy);
return 0;
}
-#ifdef DEBUG
+#if 0 /*DEBUG*/
for (i=0;i<nConfigs;i++) {
printf("Config %d\n", i);
- PrintFBConfigInfo(dpy, fbConfigs[i], 0);
+ PrintFBConfigInfo(dpy, screen, fbConfigs[i], 0);
}
#endif
/* Create the pbuffer using first fbConfig in the list that works. */
for (i=0;i<nConfigs;i++) {
- pBuffer = CreatePbuffer(dpy, fbConfigs[i], width, height, pbAttribs);
+ pBuffer = CreatePbuffer(dpy, screen, fbConfigs[i], width, height, preserve, largest);
if (pBuffer) {
gFBconfig = fbConfigs[i];
gWidth = width;
static int
Setup(int width, int height)
{
-#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
+ int pbSupport;
XVisualInfo *visInfo;
- GLXContext glCtx;
/* Open the X display */
gDpy = XOpenDisplay(NULL);
gScreen = DefaultScreen(gDpy);
/* Test that pbuffers are available */
- if (!QueryPbuffers(gDpy, gScreen)) {
+ pbSupport = QueryPbuffers(gDpy, gScreen);
+ if (pbSupport == 1) {
+ printf("Using GLX 1.3 Pbuffers\n");
+ }
+ else if (pbSupport == 2) {
+ printf("Using SGIX Pbuffers\n");
+ }
+ else {
printf("Error: pbuffers not available on this screen\n");
XCloseDisplay(gDpy);
return 0;
}
/* Get corresponding XVisualInfo */
- visInfo = glXGetVisualFromFBConfigSGIX(gDpy, gFBconfig);
+ visInfo = GetVisualFromFBConfig(gDpy, gScreen, gFBconfig);
if (!visInfo) {
printf("Error: can't get XVisualInfo from FBconfig\n");
XCloseDisplay(gDpy);
}
return 1; /* Success!! */
-#else
- printf("Error: GLX_SGIX_fbconfig and/or GLX_SGIX_pbuffer extensions not"
- " available at compile-time.\n");
- return 0;
-#endif
}
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0, 0.0, -15.0 );
-
}
int NumBoxes = 100;
int i;
- InitGL();
glClearColor(0.2, 0.2, 0.9, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (!Setup(width, height)) {
return 1;
}
+ InitGL();
Render();
WriteFile(fileName);
- glXDestroyGLXPbufferSGIX( gDpy, gPBuffer );
+ DestroyPbuffer(gDpy, gScreen, gPBuffer);
}
return 0;
}