From 27ada80dd1ee1a8a590020c337392732d3387db5 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 16 Mar 2008 02:59:26 -0400 Subject: [PATCH] some small cleanups and things for gl --- dcompmgr.c | 8 ++++++++ glxrender.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/dcompmgr.c b/dcompmgr.c index d0ee687..3d73319 100644 --- a/dcompmgr.c +++ b/dcompmgr.c @@ -446,6 +446,14 @@ setup_functions(d_display_t *dpy, d_options_t *opts) /* these can be plugins.. */ id = 1; + if (opts->render == USE_OPENGL) { + if (!dpy->glx.present) { + printf("cannot use OpenGL rendering, no glX found\n"); + printf("using XRender instead\n"); + opts->render = USE_RENDER; + } + } + if (opts->render == USE_RENDER) render_init(sc, id++); else diff --git a/glxrender.c b/glxrender.c index 7a38442..4647d62 100644 --- a/glxrender.c +++ b/glxrender.c @@ -10,6 +10,9 @@ #include #include +#include +#include + #include #include #include @@ -131,15 +134,14 @@ glxrender_init(d_screen_t *sc, int id) exit(1); } - d->context = glXCreateContext(sc->dpy->xlib_dpy, vi, NULL, GL_TRUE); - glXMakeCurrent(sc->dpy->xlib_dpy, sc->overlay, d->context); - - if (!(glxrender_find_fb_config(sc, d))) { printf("unable to find FB configs\n"); exit(1); } + d->context = glXCreateContext(sc->dpy->xlib_dpy, vi, NULL, GL_TRUE); + glXMakeCurrent(sc->dpy->xlib_dpy, sc->overlay, d->context); + glViewport(0, 0, sc->super->width_in_pixels, sc->super->height_in_pixels); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -149,6 +151,8 @@ glxrender_init(d_screen_t *sc, int id) glLoadIdentity(); glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); + //glEnable(GL_SCISSOR_TEST); ?? what is this, glxcompmgr enables it + //glEnable(GL_STENCIL_TEST); ?? what is this, glxcompmgr enables it glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); @@ -156,6 +160,7 @@ glxrender_init(d_screen_t *sc, int id) glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glXSwapBuffers(sc->dpy->xlib_dpy, sc->overlay); d->bind_func = (BindEXTFunc) @@ -200,7 +205,7 @@ glxrender_find_fb_config(d_screen_t *sc, data_t *d) stencil = 32767; depth = 32767; - printf("looking for depth %d\n", i); + //printf("looking for depth %d\n", i); tvis.depth = i; visinfo = XGetVisualInfo(sc->dpy->xlib_dpy, VisualDepthMask, @@ -259,6 +264,7 @@ glxrender_free(d_screen_t *sc) data_t *d = screen_find_plugin_data(sc, plugin_id); if (d) { glxrender_free_root_pixmap(sc, d); + glXDestroyContext(sc->dpy->xlib_dpy, d->context); free(d); } screen_remove_plugin_data(sc, plugin_id); @@ -342,7 +348,6 @@ glxrender_free_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd) wd->glpixmap, GLX_FRONT_LEFT_EXT); glBindTexture(GL_TEXTURE_2D, 0); - //xcb_glx_destroy_pixmap(w->sc->dpy->conn, wd->glpixmap); glXDestroyPixmap(w->sc->dpy->xlib_dpy, wd->glpixmap); wd->glpixmap = XCB_NONE; @@ -371,7 +376,6 @@ glxrender_free_root_pixmap(d_screen_t *sc, data_t *d) d->root_glpixmap, GLX_FRONT_LEFT_EXT); glBindTexture(GL_TEXTURE_2D, 0); - //xcb_glx_destroy_pixmap(w->sc->dpy->conn, wd->glpixmap); glXDestroyPixmap(sc->dpy->xlib_dpy, d->root_glpixmap); d->root_glpixmap = XCB_NONE; } @@ -407,10 +411,55 @@ glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd) wd->glpixmap = glXCreatePixmap(w->sc->dpy->xlib_dpy, d->fbconfig[depth], px, attrs); +#if 0 + wd->glpixmap = xcb_generate_id(w->sc->dpy->conn); + int v; + glXGetFBConfigAttrib(w->sc->dpy->xlib_dpy, d->fbconfig[depth], + GLX_FBCONFIG_ID, &v); + xcb_void_cookie_t ck = + xcb_glx_create_pixmap_checked(w->sc->dpy->conn, w->sc->num, + v, + px, wd->glpixmap, + 2, + attrs); + xcb_generic_error_t *err = xcb_request_check(w->sc->dpy->conn, ck); + if (err) { + display_error(w->sc->dpy, err); + free(err); + wd->glpixmap = XCB_NONE; + return; + } +#endif glBindTexture(GL_TEXTURE_2D, wd->texname); d->bind_func(w->sc->dpy->xlib_dpy, wd->glpixmap, GLX_FRONT_LEFT_EXT, NULL); +#if 0 + { + /* + BindTexImageEXT + 1 CARD8 opcode (X assigned) + 1 16 GLX opcode (glXVendorPrivate) + 2 6+n request length + 4 1330 vendor specific opcode + 4 CARD32 context tag + 4 GLX_DRAWABLE drawable + 4 INT32 buffer + 4 CARD32 num_attributes + 4*n LISTofATTRIBUTE_PAIR attribute, value pairs. + */ + unsigned int len = 12; + uint32_t data[] = { + wd->glpixmap, + GLX_FRONT_LEFT_EXT, + 0, + }; + xcb_glx_vendor_private(w->sc->dpy->conn, + X_GLXvop_BindTexImageEXT, + 1, + len, (uint8_t*)data); + } +#endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -676,7 +725,6 @@ glxrender_paint(d_screen_t *sc) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glDisable(GL_BLEND); - //xcb_glx_swap_buffers(sc->dpy->conn, d->context_tag, sc->overlay); glXSwapBuffers(sc->dpy->xlib_dpy, sc->overlay); /* call the function we replaced in the chain */ -- 1.9.1