#include "display.h"
#include "list.h"
#include <stdio.h>
+#include <string.h>
#include <assert.h>
#include <stdlib.h>
int x, int y, int width, int height, int bwidth);
static void glxrender_update_window_pixmap(d_window_t *w, data_t *d,
window_data_t *wd);
-static void glxrender_free_window_pixmap(d_window_t *w, window_data_t *wd);
+static void glxrender_free_window_pixmap(d_window_t *w, data_t *d,
+ window_data_t *wd);
static void glxrender_update_root_pixmap(d_screen_t *sc, data_t *d);
static void glxrender_window_show(d_window_t *window);
fbprops = xcb_glx_get_fb_configs_property_list(fbrep);
nfbprops = fbrep->num_properties;
- for (i = 0; i <= MAX_DEPTH; ++i)
- d->fbconfig[i] = 0;
+ memset(d->fbconfig, 0, (MAX_DEPTH + 1) * sizeof(d->fbconfig[0]));
db = 32767;
stencil = 32767;
if (!val > depthsize) continue;
depthsize = val;
- /* use this visual */
+ /* try this visual */
vid = visuals[j].visual_id;
- }
-
- if (!vid) continue;
-
- 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);
-
- val = glxrender_fbconfig_info(fbprops, k, nfbprops,
- GLX_VISUAL_ID);
- //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");
- if (db) continue;
-
- val = glxrender_fbconfig_info(fbprops, k, nfbprops,
- GLX_DEPTH_SIZE);
- //printf("depth size %d\n", val);
-
- val = glxrender_fbconfig_info(fbprops, k, nfbprops,
- GLX_RED_SIZE);
- //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);
- if (!val) continue;
- val = glxrender_fbconfig_info(fbprops, k, nfbprops,
- GLX_BLUE_SIZE);
- //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);
- if (!val) continue;
-
- val = glxrender_fbconfig_info(fbprops, j, nfbprops,
- GLX_RENDER_TYPE);
- //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);
-
- val = glxrender_fbconfig_info(fbprops, j, nfbprops,
- GLX_BIND_TO_TEXTURE_RGBA_EXT);
- //printf("bind ext %s\n", val ? "yes" : "no");
- if (!val) continue;
+ /* look for an fbconfig for this visual */
+ 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);
+
+ val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+ GLX_VISUAL_ID);
+ //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");
+ if (val) continue;
+
+ val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+ GLX_DEPTH_SIZE);
+ printf("depth size %d\n", val);
+
+ val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+ GLX_RED_SIZE);
+ 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);
+ if (!val) continue;
+
+ val = glxrender_fbconfig_info(fbprops, k, nfbprops,
+ GLX_BLUE_SIZE);
+ 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);
+ //if (depth_it.data->depth == 32 && !val) continue;
+
+ val = glxrender_fbconfig_info(fbprops, j, nfbprops,
+ GLX_RENDER_TYPE);
+ 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);
+
+ val = glxrender_fbconfig_info(fbprops, j, nfbprops,
+ GLX_BIND_TO_TEXTURE_RGBA_EXT);
+ printf("bind ext %s\n", val ? "yes" : "no");
+ if (!val) continue;
+
+ d->fbconfig[depth_it.data->depth] =
+ glxrender_fbconfig_info(fbprops, i, nfbprops,
+ GLX_FBCONFIG_ID);
+ break;
+ }
- d->fbconfig[depth_it.data->depth] =
- glxrender_fbconfig_info(fbprops, i, nfbprops, GLX_FBCONFIG_ID);
- break;
+ if (d->fbconfig[depth_it.data->depth])
+ printf("found visual 0x%x fbconfig 0x%x for depth %d\n",
+ vid, d->fbconfig[depth_it.data->depth],
+ depth_it.data->depth);
}
}
}
void
-glxrender_window_free_data(d_window_t *w, window_data_t *wd)
+glxrender_window_free_data(d_window_t *w, data_t *d, window_data_t *wd)
{
- glxrender_free_window_pixmap(w, wd);
+ glxrender_free_window_pixmap(w, d, wd);
glDeleteTextures(1, &wd->texname);
free(wd);
}
wd = window_find_plugin_data(w, plugin_id);
if (wd)
- glxrender_window_free_data(w, wd);
+ glxrender_window_free_data(w, d, wd);
wd = malloc(sizeof(window_data_t));
glGenTextures(1, &wd->texname);
+ wd->glpixmap = XCB_NONE;
window_add_plugin_data(w, plugin_id, wd);
}
d = screen_find_plugin_data(w->sc, plugin_id);
wd = window_find_plugin_data(w, plugin_id);
if (wd) {
- glxrender_window_free_data(w, wd);
+ glxrender_window_free_data(w, d, wd);
window_remove_plugin_data(w, plugin_id);
}
}
static void
-glxrender_free_window_pixmap(d_window_t *w, window_data_t *wd)
+glxrender_free_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
{
/* this might cause an error, oh well */
if (wd->glpixmap) {
glBindTexture(GL_TEXTURE_2D, wd->texname);
- //d->releaseTexImageEXT(obt_display, lw->glpixmap,
- // GLX_FRONT_LEFT_EXT);
+ {
+ /*
+ ReleaseTexImageEXT
+ 1 CARD8 opcode (X assigned)
+ 1 16 GLX opcode (glXVendorPrivate)
+ 2 5 request length
+ 4 1331 vendor specific opcode
+ 4 CARD32 context tag
+ 4 GLX_DRAWABLE drawable
+ 4 INT32 buffer
+ */
+ unsigned int len = (2 + 0) * sizeof(uint32_t);
+ uint32_t data[] = {
+ wd->glpixmap,
+ GLX_FRONT_LEFT_EXT
+ };
+ xcb_glx_vendor_private(w->sc->dpy->conn,
+ 1331,
+ d->context_tag,
+ len, (uint8_t*)data);
+ }
glBindTexture(GL_TEXTURE_2D, 0);
static const uint32_t attrs[] = {
GLX_TEXTURE_FORMAT_EXT,
- GLX_TEXTURE_FORMAT_RGBA_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);
+ printf("creating pixmap fbcon 0x%x\n", d->fbconfig[depth]);
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);
- }
+ 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 = (4 + 0) * sizeof(uint32_t);
+ uint32_t data[] = {
+ wd->glpixmap,
+ GLX_FRONT_LEFT_EXT,
+ 0,
+ NULL
+ };
+ xcb_glx_vendor_private(w->sc->dpy->conn,
+ 1330,
+ d->context_tag,
+ len, (uint8_t*)data);
}
- //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);
d->window_resize(w);
assert(wd != NULL);
- glxrender_free_window_pixmap(w, wd);
+ glxrender_free_window_pixmap(w, d, wd);
}
static void
d->window_reshape(w);
assert(wd != NULL);
- glxrender_free_window_pixmap(w, wd);
+ glxrender_free_window_pixmap(w, d, wd);
}
static void
data_t *d = screen_find_plugin_data(sc, plugin_id);
d_list_it_t *it;
- printf("painting\n");
+ //printf("painting\n");
paint_root(sc, d);
if (!wd->glpixmap)
glxrender_update_window_pixmap(w, d, wd);
+ glBindTexture(GL_TEXTURE_2D, wd->texname);
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glVertex2i(x, y);