Xrender

Russell Shaw rjshaw at netspace.net.au
Mon Jul 24 06:42:42 PDT 2006


Hi,
When i step through this test with gdb, i get a white window with
a black square instead of a red square. Why?


#include<stdlib.h>
#include<stdio.h>
#include<X11/Xlib.h>
#include<X11/extensions/Xrender.h>

int
main(int argc, char *argv[])
{
     char *displayname = ":0.0";
     Display *display = XOpenDisplay(displayname);

     XSynchronize(display, 1);

     int xrender_eventbase, xrender_errorbase;
     if(!XRenderQueryExtension(display, &xrender_eventbase, &xrender_errorbase)) {
         printf("Xrender extension is required, but not available.\n");
         exit(1);
     }

     int major = 0;
     int minor = 0;
     if(!XRenderQueryVersion(display, &major, &minor)) {
         printf("Error querying Xrender version.\n");
         exit(1);
     }

     XSetWindowAttributes values;
     values.background_pixel = WhitePixel(display, 0);

     Window window = XCreateWindow(
                       display,
                       RootWindow(display, 0), 0, 0, 100, 100, 0,
                       DefaultDepth(display, 0),
                       InputOutput,
                       DefaultVisual(display, 0),
                       CWBackPixel,
                       &values
                     );

     XMapWindow(display, window);

     XRenderPictFormat *pictformat = XRenderFindVisualFormat(display, DefaultVisual(display, 0));
     XRenderPictureAttributes attributes;

     Picture picture = XRenderCreatePicture(display, window, pictformat, 0, &attributes);

     XRenderColor color = {255, 0, 0, 255};

     XRenderFillRectangle(display, PictOpSrc, picture, &color, 0, 0, 20, 20);
}



More information about the xorg mailing list