linux - Attach GLX contexts with different visuals to the same X Window subsequently -


i'm trying create glx context, attach x window, detach , destroy again, create glx context different visual , attach same window.

#include <gl/glx.h> #include <x11/xlib.h> #include <stdlib.h> #include <stdio.h>  // descriptions visuals try - if both equal, example works static int attr_sets[][3] = {         { glx_rgba, glx_doublebuffer, none },         { glx_rgba, none } };  display *dpy; xvisualinfo *vi; glxcontext cxt; window wnd; size_t i;  void fail(const char *m) { fprintf(stderr, "fail: %s #%lu\n", m, i+1); abort(); }  int main(void) {     dpy = xopendisplay(null);     wnd = xcreatesimplewindow(dpy, rootwindow(dpy, 0), 0, 0, 1, 1, 1, 0, 0);     (i = 0; < 2; ++i) {         if (!(vi = glxchoosevisual(dpy, 0, attr_sets[1]))) fail("choose");         if (!(cxt = glxcreatecontext(dpy, vi, none, true))) fail("create");         xfree(vi);         if (!glxmakecurrent(dpy, wnd, cxt)) fail("attach");         if (!glxmakecurrent(dpy, wnd, 0)) fail("detach");         glxdestroycontext(dpy, cxt);     }     xdestroywindow(dpy, wnd);     xclosedisplay(dpy);     return 0; } 

this example works on mesa 10.5.2 intel graphics fails on amd fglrx 12.104 when second context attached (fail: attach #2).

what reason error? forbidden specification or driver error?

if @ definition of xcreatesimplewindow you'll see, it's wrapper around xcreatewindow. xcreatewindow in turn use visual of it's parent.

now x11 visuals half story. when attach opengl context drawable first time, visual (and more advanced features fbconfig) of drawable may become refined, later on opengl contexts compatible configurations can attached.

in short once drawables visual/fbconfig has been pinned down, opengl contexts compatible can attached. see error's defined glxmakecurrent, notably

badmatch generated if drawable not created same x screen , visual ctx. generated if drawable none , ctx not null.

normally when using glx you'd use glxcreatewindow create opengl exclusive subwindow in main window, visual/fbconfig can set without affecting main window.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -