GLXFBConfig fbconfig[MAX_DEPTH + 1];
GLXContext context;
+ GLuint root_texname;
+ GLXPixmap root_glpixmap;
BindEXTFunc bind_func;
ReleaseEXTFunc release_func;
window_data_t *wd);
static void glxrender_free_window_pixmap(d_window_t *w, data_t *d,
window_data_t *wd);
+static void glxrender_free_root_pixmap(d_screen_t *sc, data_t *d);
static void glxrender_update_root_pixmap(d_screen_t *sc, data_t *d);
static void glxrender_window_show(d_window_t *window);
glXGetProcAddress((const guchar*)"glXBindTexImageEXT");
d->release_func = (ReleaseEXTFunc)
glXGetProcAddress((const guchar*)"glXReleaseTexImageEXT");
+
+ glGenTextures(1, &d->root_texname);
+ d->root_glpixmap = XCB_NONE;
}
static gboolean
glxrender_free(d_screen_t *sc)
{
data_t *d = screen_find_plugin_data(sc, plugin_id);
+ glxrender_free_root_pixmap(sc, d);
free(d);
screen_remove_plugin_data(sc, plugin_id);
}
/* this might cause an error, oh well */
if (wd->glpixmap) {
glBindTexture(GL_TEXTURE_2D, wd->texname);
-
- {
- /*
- 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);
- */
- d->release_func(w->sc->dpy->xlib_dpy,
- wd->glpixmap, GLX_FRONT_LEFT_EXT);
- }
-
+ d->release_func(w->sc->dpy->xlib_dpy,
+ wd->glpixmap, GLX_FRONT_LEFT_EXT);
glBindTexture(GL_TEXTURE_2D, 0);
//xcb_glx_destroy_pixmap(w->sc->dpy->conn, wd->glpixmap);
}
}
+static void
+glxrender_free_root_pixmap(d_screen_t *sc, data_t *d)
+{
+ /* this might cause an error, oh well */
+ if (d->root_glpixmap) {
+ glBindTexture(GL_TEXTURE_2D, d->root_texname);
+ d->release_func(sc->dpy->xlib_dpy,
+ 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;
+ }
+}
+
static void
glxrender_update_window_pixmap(d_window_t *w, data_t *d, window_data_t *wd)
{
if (!px) return;
- //printf("%x %d %x\n", px, depth, d->fbconfig[depth]);
if (!d->fbconfig[depth]) {
printf("no GL visual for depth %d\n", depth);
return;
else
attrs[1] = GLX_TEXTURE_FORMAT_RGB_EXT;
-/*
- wd->glpixmap = xcb_generate_id(w->sc->dpy->conn);
- printf("bind config 0x%x screen %d pixmap 0x%x glpixmap 0x%x "
- "nattr %d\n",
- d->fbconfig[depth], w->sc->num, px, wd->glpixmap,
- sizeof(attrs)/sizeof(attrs[0]));
- xcb_void_cookie_t ck =
- xcb_glx_create_pixmap_checked(w->sc->dpy->conn, w->sc->num,
- d->fbconfig[depth],
- px, wd->glpixmap,
- sizeof(attrs)/sizeof(attrs[0] - 1),
- 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;
- }
-/*/
wd->glpixmap = glXCreatePixmap(w->sc->dpy->xlib_dpy,
d->fbconfig[depth],
px, attrs);
glBindTexture(GL_TEXTURE_2D, wd->texname);
-
- {
- /*
- 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 = (3 + 0) * sizeof(uint32_t);
- uint32_t data[] = {
- wd->glpixmap,
- GLX_FRONT_LEFT_EXT,
- 0
- };
- xcb_glx_vendor_private(w->sc->dpy->conn,
- 1330,
- d->context_tag,
- len, (uint8_t*)data);
- */
- d->bind_func(w->sc->dpy->xlib_dpy,
- wd->glpixmap, GLX_FRONT_LEFT_EXT, NULL);
- }
+ d->bind_func(w->sc->dpy->xlib_dpy,
+ wd->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);
}
glxrender_update_root_pixmap(d_screen_t *sc, data_t *d)
{
xcb_pixmap_t px;
+ static int attrs[] = {
+ GLX_TEXTURE_FORMAT_EXT,
+ GLX_TEXTURE_FORMAT_RGB_EXT,
+ XCB_NONE
+ };
px = screen_get_root_pixmap(sc);
- if (px) {
+ if (!px) return;
+
+ if (!d->fbconfig[sc->super->root_depth]) {
+ printf("no GL visual for depth %d\n", sc->super->root_depth);
+ return;
}
+
+ d->root_glpixmap = glXCreatePixmap(sc->dpy->xlib_dpy,
+ d->fbconfig[sc->super->root_depth],
+ px, attrs);
+
+
+ glBindTexture(GL_TEXTURE_2D, d->root_texname);
+ d->bind_func(sc->dpy->xlib_dpy,
+ d->root_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);
+
+ glBindTexture(GL_TEXTURE_2D, 0);
}
static void
data_t *d;
d = screen_find_plugin_data(sc, plugin_id);
- int a; /* XXX free things here */
- //if (d->root_picture) {
- // xcb_render_free_picture(sc->dpy->conn, d->root_picture);
- // d->root_picture = XCB_NONE;
- //}
+ glxrender_free_root_pixmap(sc, d);
/* pass it on */
d->screen_root_pixmap_change(sc);
static void
paint_root(d_screen_t *sc, data_t *d)
{
- //if (!d->root_picture)
- glxrender_update_root_pixmap(sc, d);
+ if (!d->root_glpixmap)
+ glxrender_update_root_pixmap(sc, d);
glClear(GL_COLOR_BUFFER_BIT);
+
+ glBindTexture(GL_TEXTURE_2D, d->root_texname);
+ glBegin(GL_QUADS);
+ glVertex2i(0, 0);
+ glTexCoord2f(1, 0);
+ glVertex2i(sc->super->width_in_pixels, 0);
+ glTexCoord2f(1, 1);
+ glVertex2i(sc->super->width_in_pixels, sc->super->height_in_pixels);
+ glTexCoord2f(0, 1);
+ glVertex2i(0, sc->super->height_in_pixels);
+ glTexCoord2f(0, 0);
+ glEnd();
+
+ glBindTexture(GL_TEXTURE_2D, 0);
}
static void