/** * glitz_glx_get_visual_info_from_format: * @display: an X Display * @screen: X Screen number where the window will be displayed * @format: Drawable format which is be used in matching Visual * * This function return the X Visual Info corresponding to drawable format. * * Return value: The matching X Visual Info, the function return nil if no * X Visual found. **/ XVisualInfo * glitz_glx_get_visual_info_from_format (Display *display, int screen, glitz_drawable_format_t *format) { XVisualInfo *vinfo = NULL; glitz_glx_screen_info_t *screen_info = glitz_glx_screen_info_get (display, screen); glitz_glx_static_proc_address_list_t *glx = &screen_info->glx; if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK) { GLXFBConfig *fbconfigs; int i, n_fbconfigs; int fbconfigid = screen_info->formats[format->id].u.uval; fbconfigs = glx->get_fbconfigs (display, screen, &n_fbconfigs); for (i = 0; i < n_fbconfigs; i++) { int value; glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_FBCONFIG_ID, &value); if (value == fbconfigid) break; } if (i < n_fbconfigs) vinfo = glx->get_visual_from_fbconfig (display, fbconfigs[i]); if (fbconfigs) XFree (fbconfigs); } else { XVisualInfo templ; int n_items; templ.visualid = screen_info->formats[format->id].u.uval; vinfo = XGetVisualInfo (display, VisualIDMask, &templ, &n_items); } return vinfo; }
/** * glitz_glx_find_pbuffer_format: * @display: an X Display * @screen: X Screen number where the window will be displayed * @mask: Format mask value * @templ: Format template which is be used in matching the drawable format * @count: Index number of found matching drawable format * * This function return the drawable format for a pixel buffer object that best * meets template format. The sort order of founds format follow GLX 1.3 * specification, you can safely choose the first format found (0). * * Return value: The @count index format drawable which matches template or nil * if no format matches. **/ glitz_drawable_format_t * glitz_glx_find_pbuffer_format (Display *display, int screen, unsigned long mask, const glitz_drawable_format_t *templ, int count) { glitz_int_drawable_format_t itempl; glitz_glx_screen_info_t *screen_info = glitz_glx_screen_info_get (display, screen); glitz_drawable_format_copy (templ, &itempl.d, mask); itempl.types = GLITZ_DRAWABLE_TYPE_PBUFFER_MASK; mask |= GLITZ_INT_FORMAT_PBUFFER_MASK; return glitz_drawable_format_find (screen_info->formats, screen_info->n_formats, mask, &itempl, count); }
glitz_drawable_t * glitz_glx_create_pbuffer_drawable (Display *display, int screen, glitz_drawable_format_t *format, unsigned int width, unsigned int height) { glitz_glx_screen_info_t *screen_info; glitz_int_drawable_format_t *iformat; screen_info = glitz_glx_screen_info_get (display, screen); if (!screen_info) return NULL; if (format->id >= screen_info->n_formats) return NULL; iformat = &screen_info->formats[format->id]; if (!(iformat->types & GLITZ_DRAWABLE_TYPE_PBUFFER_MASK)) return NULL; return _glitz_glx_create_pbuffer_drawable (screen_info, format, width, height); }
glitz_drawable_t * glitz_glx_create_drawable_for_window (Display *display, int screen, glitz_drawable_format_t *format, Window window, unsigned int width, unsigned int height) { glitz_glx_drawable_t *drawable; glitz_glx_screen_info_t *screen_info; glitz_glx_context_t *context; glitz_int_drawable_format_t *iformat; screen_info = glitz_glx_screen_info_get (display, screen); if (!screen_info) return NULL; if (format->id >= screen_info->n_formats) return NULL; iformat = &screen_info->formats[format->id]; if (!(iformat->types & GLITZ_DRAWABLE_TYPE_WINDOW_MASK)) return NULL; context = glitz_glx_context_get (screen_info, format); if (!context) return NULL; drawable = _glitz_glx_create_drawable (screen_info, context, format, window, (GLXPbuffer) 0, width, height); if (!drawable) return NULL; return &drawable->base; }
/** * glitz_glx_find_drawable_format_for_visual: * @display: an X Display * @screen: X Screen number where the window will be displayed * @visual_id: X Visual ID which is be used in matching drawable format * * This function return the drawable format for a X Visual ID. * * Return value: The format drawable which correspond to the Visual ID. If no * format is found the function return nil. **/ glitz_drawable_format_t * glitz_glx_find_drawable_format_for_visual (Display *display, int screen, VisualID visual_id) { glitz_drawable_format_t *format = NULL; glitz_glx_screen_info_t *screen_info; int i; screen_info = glitz_glx_screen_info_get (display, screen); if (!screen_info) return NULL; if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_FBCONFIG_MASK) { glitz_glx_static_proc_address_list_t *glx = &screen_info->glx; GLXFBConfig *fbconfigs; int fid, n_fbconfigs; fid = -1; fbconfigs = glx->get_fbconfigs (display, screen, &n_fbconfigs); for (i = 0; i < n_fbconfigs; i++) { XVisualInfo *visinfo; visinfo = glx->get_visual_from_fbconfig (display, fbconfigs[i]); if (visinfo && visinfo->visualid == visual_id) { int value; glx->get_fbconfig_attrib (display, fbconfigs[i], GLX_FBCONFIG_ID, &value); for (fid = 0; fid < screen_info->n_formats; fid++) { if (screen_info->formats[fid].u.uval == value) { format = &screen_info->formats[fid].d; break; } } if (format) { if (visinfo) XFree(visinfo); break; } } if (visinfo) XFree(visinfo); } if (fbconfigs) XFree (fbconfigs); } else { for (i = 0; i < screen_info->n_formats; i++) { if (visual_id == screen_info->formats[i].u.uval) { format = &screen_info->formats[i].d; break; } } } return format; }