#include #include #include int main( int argc, char *argv[]) { Display *display; int fb_attrs[] = { GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, None }; int pbuf_attrs[] = { GLX_PBUFFER_WIDTH, 8, GLX_PBUFFER_HEIGHT, 8, GLX_PRESERVED_CONTENTS, False, None }; int config_count = 0; GLXFBConfig *configs; GLXContext new_context; GLXPbuffer pbuf; printf( "Opening X display...\n" ); display = XOpenDisplay( NULL ); if( !display ) { printf( "Could not open X display.\n" ); return -1; } printf( "Choosing framebuffer config\n" ); configs = glXChooseFBConfig( display, DefaultScreen( display ), fb_attrs, &config_count ); if( !config_count ) { printf( "No frame buffer configurations available. Which is weird.\n" ); return -1; } new_context = glXCreateNewContext( display, configs[0], GLX_RGBA_TYPE, NULL, True ); if( !new_context ) { printf( "Failed to create context.\n" ); return -1; } pbuf = glXCreatePbuffer( display, configs[0], pbuf_attrs ); if( pbuf == None ) { printf( "Failed to create XGL pixel buffer.\n" ); return -1; } if( !glXMakeContextCurrent( display, pbuf, pbuf, new_context ) ) { printf( "Failed to set context current.\n" ); return -1; } glXDestroyPbuffer( display, pbuf ); glXDestroyContext( display, new_context ); printf( "Success\n" ); return 0; }