我想在linux上做一个多窗口的应用程序。我试着像下面的代码那样做,但在windows下它只显示黑屏。这可能是什么原因?
struct argList{
Display *dpy;
XID *root;
GLint *att;
XVisualInfo *vi;
Colormap *cmap;
XSetWindowAttributes *swa;
GLXContext *glc;
XWindowAttributes *gwa;
XEvent *xev;
int *cop;
XID **wl;
};
void *throwMe(void *args){
argList *argsl = (argList*)(args);
while(true){
glClearColor(1,1,1,0.5);
XNextEvent(argsl->dpy, argsl->xev);
for(int i = 0; i < *argsl->cop; i++){
#ifdef stdinLOG
printf("Checking (%i) window in list...",i);
#endif
if(argsl->wl[i] == nullptr)
continue;
else if(argsl->xev->xclient.window==*argsl->wl[i]) {
argsl->vi->visual, AllocNone);
*argsl->glc = glXCreateContext(argsl->dpy, argsl->vi, NULL, GL_TRUE);
XGetWindowAttributes(argsl->dpy, *argsl->wl[i], argsl->gwa);
glXMakeCurrent(argsl->dpy, *argsl->wl[i], *argsl->glc);
glViewport(0, 0, argsl->gwa->width, argsl->gwa->height);
glEnable(GL_DEPTH_TEST);
glOrtho(0,100,0,100,0,0);
#ifdef stdinLOG
printf("Event (%p:%i) called from (%p:%i) window\n",argsl->xev,argsl->xev->type,*argsl->wl[i]);
printf("Updatin (%p:%i) window\n", argsl->wl[i], *argsl->wl[i]);
#endif
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glXSwapBuffers(argsl->dpy, *argsl->wl[i]);
if(argsl->xev->type == 22) {
}
else if(argsl->xev->type == KeyPress) {
glXMakeCurrent(argsl->dpy, None, NULL);
glXDestroyContext(argsl->dpy, *argsl->glc);
XDestroyWindow(argsl->dpy, *argsl->wl[i]);
}
continue;
}
}
}
}
当wl - 窗口列表时,是一个XID(X窗口ID)的数组。这是一个XID(X窗口ID)的数组。