我们有一个使用 3 个图形卡在不同屏幕上具有多个窗口的应用程序。每个窗口都使用 opengl 来渲染字体、图像等......到目前为止,这工作得很好,除了共享资源。我们试图实现这样的东西(fenster 是一个自定义类来存储上下文等信息......):
//a list of display names
vector<string> displays;
displays.push_back(":0.0");
displays.push_back(":0.1");
displays.push_back(":0.2");
displays.push_back(":0.3");
displays.push_back(":0.4");
//and then we loop them
FOREACH(string dispName in displays): //dummy code
static int dblBuf[] = {GLX_RGBA, GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None};
Display* disp;
if(dispName != "default")
disp = XOpenDisplay(dispName.c_str());
else
disp = XOpenDisplay(NULL);
if(disp == NULL)
{
cout << "ERROR GETING DISPLAY " << dispName << endl;
return NULL;
}
cout << "CREATING WINDOW ON SCREEN "<< dispName << endl;
XVisualInfo *vi = glXChooseVisual(disp, DefaultScreen(disp), dblBuf);
fenster->display = disp;
fenster->window = XCreateSimpleWindow(disp, RootWindow(disp, vi->screen), 1, 1, 500, 500, 0, BlackPixel (disp, 0), BlackPixel(disp, 0));
XSetStandardProperties(fenster->display, fenster->window, "main", "main", None,NULL, 0, NULL);
XMapWindow(disp, fenster->window);
if(fensterList.size()==0)
fenster->glXContext = glXCreateContext(disp, vi, NULL, GL_TRUE);
else
fenster->glXContext = glXCreateContext(fensterList[0]->display, vi, fensterList[0]->glXContext, GL_TRUE);
XSelectInput(disp, fenster->window, ButtonPressMask|KeyPressMask);
glXMakeCurrent(disp, fenster->window, fenster->glXContext);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0, 0.0, 0.0, 0.0);
XFlush(disp);
fenster->id = fensterList.size();
fensterList.push_back(fenster);
fenster->setup();
这编译得很好,但在运行时会产生以下错误:
CREATING WINDOW ON SCREEN :0.0
CREATING WINDOW ON SCREEN :0.1
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 137 (GLX)
Minor opcode of failed request: 3 (X_GLXCreateContext)
Serial number of failed request: 90
Current serial number in output stream: 91
当我尝试在同一个桌面上创建多个窗口(使用显示:0.0)时,该代码有效。
该系统是 ubuntu 10.10,使用专有的 ATI 驱动程序。
有任何想法吗?甚至可能吗?