272 |
|
|
273 |
dbContext = glXCreateContext(dpy, dbVinfo, 0, GL_TRUE); |
dbContext = glXCreateContext(dpy, dbVinfo, 0, GL_TRUE); |
274 |
|
|
|
pxVinfo = glXChooseVisual(dpy, DefaultScreen(dpy), |
|
|
old_pxattrs); |
|
|
if(!pxVinfo) BARF("Can't get dblbuf visual"); |
|
|
pxContext = glXCreateContext(dpy, pxVinfo, dbContext, GL_TRUE); |
|
275 |
|
|
276 |
} |
} |
277 |
|
|
278 |
|
// Get this in any case -- ATI doesn't |
279 |
|
// let us use pbuffers on radeons... |
280 |
|
pxVinfo = glXChooseVisual(dpy, DefaultScreen(dpy), |
281 |
|
old_pxattrs); |
282 |
|
if(!pxVinfo) BARF("Can't get dblbuf visual"); |
283 |
|
pxContext = glXCreateContext(dpy, pxVinfo, dbContext, GL_TRUE); |
284 |
|
|
285 |
swa.border_pixel = 0; |
swa.border_pixel = 0; |
286 |
|
|
287 |
swa.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), |
swa.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), |
362 |
w, |
w, |
363 |
h, |
h, |
364 |
ws->pxVinfo->depth); |
ws->pxVinfo->depth); |
365 |
|
|
366 |
|
DBG(dbg) << "Created LXPixmap: "<<pix<<" "<<ws->pixmapDrawable<<" "<< |
367 |
|
ws->pxVinfo->depth<<" "<<w<<" "<<h<<"\n"; |
368 |
|
if(pix == 0) |
369 |
|
throw "Can't create pixmap"; |
370 |
this->w = w; |
this->w = w; |
371 |
this->h = h; |
this->h = h; |
372 |
} |
} |
375 |
DBG(dbg) << "setcurrent pixmap "<<pix<<" "<<ws->pxContext<<"\n"; |
DBG(dbg) << "setcurrent pixmap "<<pix<<" "<<ws->pxContext<<"\n"; |
376 |
bool ret = glXMakeContextCurrent(ws->dpy, pix, pix, ws->pxContext); |
bool ret = glXMakeContextCurrent(ws->dpy, pix, pix, ws->pxContext); |
377 |
DBG(dbg) << "setcurrent pixmap ret: "<<ret<<"\n"; |
DBG(dbg) << "setcurrent pixmap ret: "<<ret<<"\n"; |
378 |
|
throw "Can't draw into pixmap"; |
379 |
return ret; |
return ret; |
380 |
} |
} |
381 |
bool releaseCurrent() { |
bool releaseCurrent() { |
382 |
DBG(dbg) << "Releasecurrent pixmap "<<pix<<" "<<ws->pxContext<<"\n"; |
DBG(dbg) << "Releasecurrent pixmap "<<pix<<" "<<ws->pxContext<<"\n"; |
383 |
bool ret = glXMakeContextCurrent(ws->dpy, None, None, NULL); |
bool ret = glXMakeContextCurrent(ws->dpy, None, None, NULL); |
384 |
DBG(dbg) << "Releasecurrent pixmap ret: "<<ret<<"\n"; |
DBG(dbg) << "Releasecurrent pixmap ret: "<<ret<<"\n"; |
385 |
|
throw "Can't draw into pixmap"; |
386 |
return ret; |
return ret; |
387 |
} |
} |
388 |
|
|
395 |
}; |
}; |
396 |
|
|
397 |
|
|
398 |
|
|
399 |
// static char eventStringBuf[256]; |
// static char eventStringBuf[256]; |
400 |
// |
// |
401 |
struct LXPBuffer : public Os::RenderingSurface { |
struct LXPBuffer : public Os::RenderingSurface { |
404 |
GLXPbuffer pbuf; |
GLXPbuffer pbuf; |
405 |
int w, h; |
int w, h; |
406 |
|
|
407 |
LXPBuffer(LXWindowSystem *ws, int w, int h) : ws(ws) { |
LXPBuffer(LXWindowSystem *ws, GLXPbuffer pbuf, |
408 |
int attrs[] = { |
int w, int h) : ws(ws), pbuf(pbuf) { |
|
GLX_PBUFFER_WIDTH, w, |
|
|
GLX_PBUFFER_HEIGHT, h, |
|
|
GLX_PRESERVED_CONTENTS, 1, |
|
|
GLX_LARGEST_PBUFFER, 0, |
|
|
0 |
|
|
}; |
|
|
pbuf = glXCreatePbuffer(ws->dpy, ws->pbFbConfig[0], attrs); |
|
409 |
|
|
410 |
unsigned val; |
unsigned val; |
411 |
glXQueryDrawable(ws->dpy, pbuf, GLX_PBUFFER_WIDTH, &val); |
glXQueryDrawable(ws->dpy, pbuf, GLX_PBUFFER_WIDTH, &val); |
424 |
DBG(dbg) << "setcurrent pbuf "<<pbuf<<" "<<ws->pbContext<<"\n"; |
DBG(dbg) << "setcurrent pbuf "<<pbuf<<" "<<ws->pbContext<<"\n"; |
425 |
bool ret = glXMakeContextCurrent(ws->dpy, pbuf, pbuf, ws->pbContext); |
bool ret = glXMakeContextCurrent(ws->dpy, pbuf, pbuf, ws->pbContext); |
426 |
DBG(dbg) << "setcurrent pbuf ret: "<<ret<<"\n"; |
DBG(dbg) << "setcurrent pbuf ret: "<<ret<<"\n"; |
427 |
|
throw "Can't draw into pbuf"; |
428 |
return ret; |
return ret; |
429 |
} |
} |
430 |
bool releaseCurrent() { |
bool releaseCurrent() { |
431 |
DBG(dbg) << "Releasecurrent pbuf "<<pbuf<<" "<<ws->pbContext<<"\n"; |
DBG(dbg) << "Releasecurrent pbuf "<<pbuf<<" "<<ws->pbContext<<"\n"; |
432 |
bool ret = glXMakeContextCurrent(ws->dpy, None, None, NULL); |
bool ret = glXMakeContextCurrent(ws->dpy, None, None, NULL); |
433 |
DBG(dbg) << "Releasecurrent pbuf ret: "<<ret<<"\n"; |
DBG(dbg) << "Releasecurrent pbuf ret: "<<ret<<"\n"; |
434 |
|
throw "Can't draw into pbuf"; |
435 |
return ret; |
return ret; |
436 |
} |
} |
437 |
|
|
443 |
} |
} |
444 |
}; |
}; |
445 |
|
|
446 |
|
LXPBuffer *createPBuffer(LXWindowSystem *ws, int w, int h) { |
447 |
|
int attrs[] = { |
448 |
|
GLX_PBUFFER_WIDTH, w, |
449 |
|
GLX_PBUFFER_HEIGHT, h, |
450 |
|
GLX_PRESERVED_CONTENTS, 1, |
451 |
|
GLX_LARGEST_PBUFFER, 0, |
452 |
|
0 |
453 |
|
}; |
454 |
|
GLXPbuffer pbuf = glXCreatePbuffer(ws->dpy, ws->pbFbConfig[0], attrs); |
455 |
|
DBG(dbg) << "Pbuf alloc: "<<w<<" "<<h<<" "<<pbuf<<"\n"; |
456 |
|
if(pbuf == 0) |
457 |
|
return 0; |
458 |
|
return new LXPBuffer(ws, pbuf, w, h); |
459 |
|
} |
460 |
|
|
461 |
struct LXWindow : public Os::Window { |
struct LXWindow : public Os::Window { |
462 |
LXWindowSystem *ws; |
LXWindowSystem *ws; |
463 |
::Window xw; |
::Window xw; |
663 |
|
|
664 |
Os::RenderingSurface *LXWindowSystem::openStableOffScreen(int w, int h) |
Os::RenderingSurface *LXWindowSystem::openStableOffScreen(int w, int h) |
665 |
{ |
{ |
666 |
if(pbFbConfig) |
Os::RenderingSurface *ret = 0; |
667 |
return new LXPBuffer(this, w, h); |
if(pbFbConfig) { |
668 |
else |
ret = createPBuffer(this, w, h); |
669 |
return new LXPixmap(this, w, h); |
if(ret != 0) { |
670 |
|
DBG(dbg) << "Pixbuf successfully created\n"; |
671 |
|
return ret; |
672 |
|
} |
673 |
|
} |
674 |
|
return new LXPixmap(this, w, h); |
675 |
} |
} |
676 |
|
|
677 |
WindowSystem *WindowSystem::instance = 0; |
WindowSystem *WindowSystem::instance = 0; |