PDA

View Full Version : glx 1.4 initialization



Y-tension
02-03-2009, 02:54 PM
Any help would be appreciated...I started X programming and am trying to initialize an opengl window with this code but the GLXWindow refuses to becreated with a messaged of "failed to create drawable".



int attribs[] = {GLX_BUFFER_SIZE, 32,
GLX_SAMPLE_BUFFERS, 0,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_X_RENDERABLE, True,
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
GLX_CONFIG_CAVEAT, GLX_NONE,
GLX_TRANSPARENT_TYPE, GLX_NONE,
GLX_DOUBLEBUFFER, True,
GLX_STEREO, False,
GLX_AUX_BUFFERS, 0,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_STENCIL_SIZE, 8,
None};
int numOfConfigs;
GLXFBConfig *config;
int tmp;
XVisualInfo *xvis;

display = XOpenDisplay(NULL);
if(glXQueryExtension(display, &tmp, &tmp))
cout << "glX support found.\n";

config = glXChooseFBConfig(display, DefaultScreen(display), attribs, &amp;numOfConfigs);
cout << numOfConfigs << " configurations found.\n";
if((xvis = glXGetVisualFromFBConfig(display, *config))!= NULL)
cout << "corresponding X visual found.\n";

if((context = glXCreateNewContext(display, *config, GLX_RGBA_TYPE, NULL, True))!=NULL)
cout << "context created.\n";

win = XCreateWindow(display, DefaultRootWindow(display), 0, 0, 800, 600, 0,
xvis->depth, InputOutput, xvis->visual,
0, NULL);

XMapRaised(display, win);

glxwin = glXCreateWindow(display, *config, win, NULL);

if(glXMakeContextCurrent(display, glxwin, glxwin, context))
cout << "context binding successful.\n";


XFree(xvis);
XFree(config);


Any suggestions welcome!
I'm using ubuntu intrepid with the open-source drivers(proprietary ones don't work for now...)

idr
02-04-2009, 01:31 AM
None of the open-source drivers support GLX 1.4. You can onfirm this by running 'glxinfo | grep "GLX version"'. Before attempting to use GLX 1.4 features (and you're actually using a GLX 1.3 feature), you need to query the GLX version. See glXQueryVersion (http://www.opengl.org/sdk/docs/man/xhtml/glXQueryVersion.xml) for details.

That said, all of the open-source drivers do support GLX_SGIX_fbconfig (http://www.opengl.org/registry/specs/SGIX/fbconfig.txt), which provides nearly identical functionality. Before trying to use that extension you'll need to make sure it's available by querying the GLX extension string. See glXQueryExtensionsString (http://www.opengl.org/sdk/docs/man/xhtml/glXQueryExtensionsString.xml).

Since you're getting the message "failed to create drawable," I think you have a slightly old version of libGL. Before about 3 weeks ago there were a couple bugs in this area that cause some false errors.

Dark Photon
02-04-2009, 06:10 AM
Any help would be appreciated...I started X programming and am trying to initialize an opengl window with this code but the GLXWindow refuses to becreated with a messaged of "failed to create drawable".
Try this (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=241530#Post241530) and tweak from there. Works for me. If you want a small complete glX program, just ask.

Y-tension
02-25-2009, 11:11 AM
Yep, you were right, open source drivers support glx 1.2. It was the fglrx ati driver that advertised 1.4 but these drivers crashed so I uninstalled them...Will try the old initialization procedure until they are fixed.

Y-tension
02-26-2009, 09:37 AM
I managed to make it work by substituting glxwin in
glXMakeContextCurrent(display, glxwin, glxwin, context)

with win(see code), without the glxCreateWindow call.

As said before, glx version is 1.2, GL_SGIX_fbconfig is supported and right now I'm gonna dig into some documentation to see what the hell is going on. Thnx,guys!