[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/libos Os-GLX.cxx
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz/gfx/libos Os-GLX.cxx |
Date: |
Wed, 11 Dec 2002 07:47:35 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/12/11 07:47:35
Modified files:
gfx/libos : Os-GLX.cxx
Log message:
If fbconfig doesn't work, use choosevisual... please report whether it
works.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libos/Os-GLX.cxx.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
Patches:
Index: gzz/gfx/libos/Os-GLX.cxx
diff -u gzz/gfx/libos/Os-GLX.cxx:1.17 gzz/gfx/libos/Os-GLX.cxx:1.18
--- gzz/gfx/libos/Os-GLX.cxx:1.17 Wed Dec 11 05:45:47 2002
+++ gzz/gfx/libos/Os-GLX.cxx Wed Dec 11 07:47:35 2002
@@ -86,6 +86,32 @@
None
};
+ /** Attributes for db visual for ChooseVisual.
+ */
+ static int old_dbattrs[] = {
+ GLX_RGBA,
+ GLX_DOUBLEBUFFER,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DEPTH_SIZE, 1,
+ GLX_STENCIL_SIZE, 1,
+ None
+ };
+
+ /** Attributes for sb pixmap visual for ChooseVisual.
+ */
+ static int old_pxattrs[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DEPTH_SIZE, 1,
+ GLX_STENCIL_SIZE, 1,
+ None
+ };
+
+
struct LXImage : public Os::Image {
ImageRaster r;
LXImage(ImageRaster &r) : Os::Image(r.getWidth(), r.getHeight()), r(r)
@@ -145,13 +171,19 @@
int swaMask;
int numReturned;
+ // window
GLXFBConfig *dbFbConfig;
XVisualInfo *dbVinfo;
GLXContext dbContext;
+ // pbuffer
GLXFBConfig *pbFbConfig;
GLXContext pbContext;
+ // pixmap
+ XVisualInfo *pxVinfo;
+ GLXContext pxContext;
+
vector<Timeout> timeouts;
vector<LXWindow *> windows;
@@ -159,21 +191,54 @@
std::map<Win, LXWindow *> windowsByX;
+ /** The drawable to use to create pixmaps.
+ */
+ Drawable pixmapDrawable;
+
LXWindowSystem() {
if(!(dpy = XOpenDisplay( NULL ))) BARF("Can't start X");
int nel;
+
+ pbFbConfig = 0;
+
dbFbConfig = glXChooseFBConfig(dpy, DefaultScreen(dpy),
doubleBufferAttributes, &nel);
- if(!dbFbConfig) BARF("Can't get dblbuf visual");
+ if(dbFbConfig) {
+ // Got it -- use the new way
+ dbContext = glXCreateNewContext(dpy, dbFbConfig[0],
GLX_RGBA_TYPE,
+ 0, GL_TRUE);
+
+
+ dbVinfo = glXGetVisualFromFBConfig(dpy, dbFbConfig[0]);
+
+ pbFbConfig = glXChooseFBConfig(dpy, DefaultScreen(dpy),
+ pbufferAttributes, &nel);
+ if(!pbFbConfig) BARF("Can't get pbuffer config");
- dbContext = glXCreateNewContext(dpy, dbFbConfig[0], GLX_RGBA_TYPE,
- 0, GL_TRUE);
+ pbContext = glXCreateNewContext(dpy, pbFbConfig[0],
+ GLX_RGBA_TYPE,
+ dbContext, GL_TRUE);
+ } else {
+ // Didn't -- use pixmap for off-screen and
+ // glXChooseVisual
+
+ dbVinfo = glXChooseVisual(dpy, DefaultScreen(dpy),
+ old_dbattrs);
+
+ if(!dbVinfo) BARF("Can't get dblbuf visual");
+ dbContext = glXCreateContext(dpy, dbVinfo, 0, GL_TRUE);
+
+ pxVinfo = glXChooseVisual(dpy, DefaultScreen(dpy),
+ old_pxattrs);
+ if(!pxVinfo) BARF("Can't get dblbuf visual");
+ pxContext = glXCreateContext(dpy, pxVinfo, dbContext, GL_TRUE);
+
+ }
- dbVinfo = glXGetVisualFromFBConfig(dpy, dbFbConfig[0]);
swa.border_pixel = 0;
swa.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy),
@@ -200,14 +265,13 @@
CWBackPixmap
);
-
- pbFbConfig = glXChooseFBConfig(dpy, DefaultScreen(dpy),
- pbufferAttributes, &nel);
- if(!pbFbConfig) BARF("Can't get pbuffer visual");
-
- pbContext = glXCreateNewContext(dpy, pbFbConfig[0],
- GLX_RGBA_TYPE,
- dbContext, GL_TRUE);
+ pixmapDrawable = XCreateWindow(dpy,
+ RootWindow(dpy, dbVinfo->screen),
+ 0, 0, 1, 1,
+ 0, dbVinfo->depth, InputOutput,
+ dbVinfo->visual,
+ swaMask, &swa
+ );
}
@@ -242,6 +306,43 @@
// static char eventStringBuf[256];
//
+ struct LXPixmap : public Os::RenderingSurface {
+ LXWindowSystem *ws;
+
+ Pixmap pix;
+ int w, h;
+
+ LXPixmap(LXWindowSystem *ws, int w, int h) : ws(ws) {
+
+ pix = XCreatePixmap(ws->dpy,
+ ws->pixmapDrawable,
+ w,
+ h,
+ ws->pxVinfo->depth);
+ this->w = w;
+ this->h = h;
+ }
+
+ bool setCurrent() {
+ bool ret = glXMakeContextCurrent(ws->dpy, pix, pix, ws->pxContext);
+ return ret;
+ }
+ bool releaseCurrent() {
+ bool ret = glXMakeContextCurrent(ws->dpy, None, None, NULL);
+ return ret;
+ }
+
+ void getSize(int *xywh) {
+ xywh[0] = 0;
+ xywh[1] = 0;
+ xywh[2] = w;
+ xywh[3] = h;
+ }
+ };
+
+
+ // static char eventStringBuf[256];
+ //
struct LXPBuffer : public Os::RenderingSurface {
LXWindowSystem *ws;
@@ -509,7 +610,10 @@
Os::RenderingSurface *LXWindowSystem::openStableOffScreen(int w, int h)
{
- return new LXPBuffer(this, w, h);
+ if(pbFbConfig)
+ return new LXPBuffer(this, w, h);
+ else
+ return new LXPixmap(this, w, h);
}
WindowSystem *WindowSystem::instance = 0;