From 1cdafda1bfaac0eb6516d63adfced8a69b87e171 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 10 Mar 2008 00:25:28 -0400 Subject: [PATCH] the code is more or less there. have to figure out how to find the fbconfigs right, it is looking for depths 0 and 1 or something right now. and have to figure out how to do BIND_EXT with xcb --- glxrender.c | 131 ++++++++++++++++++++++++++++++++++------------------ window.c | 15 ++++-- window.h | 2 + 3 files changed, 99 insertions(+), 49 deletions(-) diff --git a/glxrender.c b/glxrender.c index 1a4a8da..c1058ea 100644 --- a/glxrender.c +++ b/glxrender.c @@ -248,7 +248,6 @@ glxrender_find_fb_config(d_screen_t *sc, data_t *d) xcb_glx_get_fb_configs_cookie_t fbck; xcb_glx_get_fb_configs_reply_t *fbrep; xcb_depth_iterator_t depth_it; - uint32_t fbcon = FALSE; unsigned int i, nvprops, nfbprops; uint32_t *vprops, *fbprops; uint32_t db, stencil, depthsize; @@ -283,6 +282,8 @@ glxrender_find_fb_config(d_screen_t *sc, data_t *d) vid = 0; if (depth_it.data->depth > MAX_DEPTH) continue; + printf("looking for depth %d\n", depth_it.data->depth); + visuals = xcb_depth_visuals(depth_it.data); nvisuals = xcb_depth_visuals_length(depth_it.data); @@ -320,60 +321,60 @@ glxrender_find_fb_config(d_screen_t *sc, data_t *d) if (!vid) continue; - printf("found visual for depth %d\n", i); + printf("found visual for depth %d\n", depth_it.data->depth); for (k = 0; k < fbrep->num_FB_configs; ++k) { uint32_t val; - printf("root visual 0x%x\n", sc->super.root_visual); - printf("overlay visual 0x%x\n", sc->overlay_visual); + //printf("root visual 0x%x\n", sc->super.root_visual); + //printf("overlay visual 0x%x\n", sc->overlay_visual); val = glxrender_fbconfig_info(fbprops, k, nfbprops, GLX_VISUAL_ID); - printf("x visual 0x%x\n", val); + //printf("x visual 0x%x\n", val); if (val != vid) continue; val = glxrender_fbconfig_info(fbprops, k, nfbprops, GLX_DOUBLEBUFFER); - printf("dbl buffer %s\n", val ? "yes" : "no"); + //printf("dbl buffer %s\n", val ? "yes" : "no"); if (db) continue; val = glxrender_fbconfig_info(fbprops, k, nfbprops, GLX_DEPTH_SIZE); - printf("depth size %d\n", val); + //printf("depth size %d\n", val); val = glxrender_fbconfig_info(fbprops, k, nfbprops, GLX_RED_SIZE); - printf("red size %d\n", val); + //printf("red size %d\n", val); if (!val) continue; val = glxrender_fbconfig_info(fbprops, k, nfbprops, GLX_GREEN_SIZE); - printf("green size %d\n", val); + //printf("green size %d\n", val); if (!val) continue; val = glxrender_fbconfig_info(fbprops, k, nfbprops, GLX_BLUE_SIZE); - printf("blue size %d\n", val); + //printf("blue size %d\n", val); if (!val) continue; val = glxrender_fbconfig_info(fbprops, k, nfbprops, GLX_ALPHA_SIZE); - printf("alpha size %d\n", val); + //printf("alpha size %d\n", val); if (!val) continue; val = glxrender_fbconfig_info(fbprops, j, nfbprops, GLX_RENDER_TYPE); - printf("rgba bit %s\n", val & GLX_RGBA_BIT ? "yes" : "no"); + //printf("rgba bit %s\n", val & GLX_RGBA_BIT ? "yes" : "no"); if (!(val & GLX_RGBA_BIT)) continue; val = glxrender_fbconfig_info(fbprops, j, nfbprops, GLX_CONFIG_CAVEAT); - printf("caveat 0x%x\n", val); + //printf("caveat 0x%x\n", val); val = glxrender_fbconfig_info(fbprops, j, nfbprops, GLX_BIND_TO_TEXTURE_RGBA_EXT); - printf("bind ext %s\n", val ? "yes" : "no"); + //printf("bind ext %s\n", val ? "yes" : "no"); if (!val) continue; d->fbconfig[depth_it.data->depth] = @@ -459,18 +460,66 @@ static void glxrender_free_window_pixmap(d_window_t *w, window_data_t *wd) { /* this might cause an error, oh well */ - //if (wd->picture) { - // xcb_render_free_picture(w->sc->dpy->conn, wd->picture); - // wd->picture = XCB_NONE; - //} + if (wd->glpixmap) { + glBindTexture(GL_TEXTURE_2D, wd->texname); + + //d->releaseTexImageEXT(obt_display, lw->glpixmap, + // GLX_FRONT_LEFT_EXT); + + glBindTexture(GL_TEXTURE_2D, 0); + + xcb_glx_destroy_glx_pixmap(w->sc->dpy->conn, wd->glpixmap); + wd->glpixmap = XCB_NONE; + } } static void glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd) { xcb_pixmap_t px; + uint8_t depth; + + static const uint32_t attrs[] = { + GLX_TEXTURE_FORMAT_EXT, + GLX_TEXTURE_FORMAT_RGBA_EXT + }; px = window_get_pixmap(w); + depth = window_get_depth(w); + if (px && d->fbconfig[depth]) { + wd->glpixmap = xcb_generate_id(w->sc->dpy->conn); + xcb_glx_create_pixmap(w->sc->dpy->conn, w->sc->num, d->fbconfig[depth], + px, wd->glpixmap, 2, attrs); + + glBindTexture(GL_TEXTURE_2D, wd->texname); + + { + unsigned int len = 2 * sizeof(uint32_t); + uint32_t data[] = {wd->glpixmap, GLX_FRONT_LEFT_EXT}; + xcb_void_cookie_t ck; + xcb_generic_error_t *err; + + ck = xcb_glx_vendor_private(w->sc->dpy->conn, + GLX_BIND_TO_TEXTURE_RGBA_EXT, + d->context_tag, + len, data); + if ((err = xcb_request_check(w->sc->dpy->conn, ck))) { + display_error(w->sc->dpy, err); + free(err); + } + } + //d->bindTexImageEXT(obt_display, lw->glpixmap, + // GLX_FRONT_LEFT_EXT, NULL); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glBindTexture(GL_TEXTURE_2D, 0); + } } static void @@ -537,6 +586,8 @@ glxrender_paint(d_screen_t *sc) data_t *d = screen_find_plugin_data(sc, plugin_id); d_list_it_t *it; + printf("painting\n"); + paint_root(sc, d); for (it = list_bottom(sc->stacking); it; it = it->prev) { @@ -579,39 +630,29 @@ paint_root(d_screen_t *sc, data_t *d) { //if (!d->root_picture) glxrender_update_root_pixmap(sc, d); + + glClear(GL_COLOR_BUFFER_BIT); } static void paint_window(d_window_t *w, data_t *d, window_data_t *wd, gboolean opaque, int x, int y, int width, int height, int bwidth) { - //if (!wd->picture) - glxrender_update_window_pixmap(w, d, wd); - - //printf("-- paint window 0x%x picture 0x%x --\n", w->id, wd->picture); -/* - if (wd->picture) { - xcb_render_picture_t alphamap; - int op; - - if (opaque) { - op = XCB_RENDER_PICT_OP_SRC; - alphamap = XCB_NONE; - } - else { - op = XCB_RENDER_PICT_OP_OVER; - alphamap = wd->alpha_picture; - } - - xcb_render_composite(w->sc->dpy->conn, - op, - wd->picture, - alphamap, - d->overlay_buffer, - 0, 0, 0, 0, - x, y, width + bwidth*2, height + bwidth *2); - } -*/ + if (!wd->glpixmap) + glxrender_update_window_pixmap(w, d, wd); + + glBegin(GL_QUADS); + glColor3f(1.0, 1.0, 1.0); + glVertex2i(x, y); + glTexCoord2f(1, 0); + glVertex2i(x + width + bwidth, y); + glTexCoord2f(1, 1); + glVertex2i(x + width + bwidth, + y + height + bwidth); + glTexCoord2f(0, 1); + glVertex2i(x, y + height + bwidth); + glTexCoord2f(0, 0); + glEnd(); } static void diff --git a/window.c b/window.c index 39685a8..b14de39 100644 --- a/window.c +++ b/window.c @@ -26,7 +26,7 @@ typedef struct { int x, y, w, h, bw; gboolean attr_mapped; gboolean input_only; - gboolean argb; + uint8_t depth; xcb_visualid_t visual; xcb_pixmap_t pixmap; xcb_xfixes_region_t region; @@ -338,14 +338,14 @@ window_get_geometry_reply(d_window_priv_t *w) w->w = rep->width; w->h = rep->height; w->bw = rep->border_width; - w->argb = rep->depth == 32; + w->depth = rep->depth; free(rep); } else { w->x = w->y = -1; w->w = w->h = 1; w->bw = 0; - w->argb = FALSE; + w->depth = 0; } if (err) { printf("error getting geometry for window 0x%x\n", w->id); @@ -372,11 +372,18 @@ window_is_attr_mapped(d_window_t *pubw) gboolean window_is_argb(d_window_t *pubw) +{ + uint8_t depth = window_get_depth(pubw); + return depth == 32; +} + +uint8_t +window_get_depth(d_window_t *pubw) { d_window_priv_t *w = (d_window_priv_t*)pubw; if (w->waiting_geom) window_get_geometry_reply(w); - return w->argb; + return w->depth; } xcb_visualid_t diff --git a/window.h b/window.h index 8d29274..d6c4f79 100644 --- a/window.h +++ b/window.h @@ -57,6 +57,8 @@ gboolean window_is_mapped(d_window_t *w); gboolean window_is_attr_mapped(d_window_t *w); gboolean window_is_argb(d_window_t *w); +uint8_t window_get_depth(d_window_t *w); + void window_get_area(d_window_t *w, int *x, int *y, int *width, int *height, int *border_width); -- 2.34.1