XRenderSetPictureTransform: Black window - Xwindows

This is a discussion on XRenderSetPictureTransform: Black window - Xwindows ; Hallo, i want to use xrender to rotate the contents of a window. It works with the following transformation matrix XTransform transform = {{{XDoubleToFixed (1.0), 0, 0 }, {0, XDoubleToFixed (1.0), 0 }, {0, 0, XDoubleToFixed (1.0)}}}; like in the ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: XRenderSetPictureTransform: Black window

  1. XRenderSetPictureTransform: Black window

    Hallo,
    i want to use xrender to rotate the contents of a window. It works
    with the following transformation matrix

    XTransform transform = {{{XDoubleToFixed (1.0), 0, 0 },
    {0, XDoubleToFixed (1.0), 0 },
    {0, 0, XDoubleToFixed (1.0)}}};

    like in the sample code. But when I use this
    XTransform transform = {{{XDoubleToFixed (1.2), 0, 0 },
    {0, XDoubleToFixed (1.2), 0 },
    {0, 0, XDoubleToFixed (1.0)}}};

    i get a black window. So, what`s wrong?

    Test: Save code in file test.c
    gcc test.c -o test -L/usr/X11R6/lib -lXt -lX11 -lXrender
    call test

    Thank you for help.



    #include
    #include
    #include
    #include
    #include

    enum
    {
    WM_DELETE_WINDOW,
    ATOMCOUNT

    };

    static char *atom_names[ATOMCOUNT] = {
    "WM_DELETE_WINDOW"

    };

    static Window
    create_dst_window(Display *display, const Atom atoms[], int argc, char
    **argv)
    {
    Screen *screen;
    Window dst_window;
    XWMHints wm_hints;
    Atom protocols[1];
    XSetWindowAttributes attributes;

    screen = DefaultScreenOfDisplay(display);
    attributes.event_mask = ExposureMask;
    attributes.bit_gravity = ForgetGravity;
    dst_window = XCreateWindow(display, RootWindowOfScreen(screen),
    0, 0, 302, 202, 1,
    DefaultDepthOfScreen(screen),
    InputOutput,
    DefaultVisualOfScreen(screen),
    CWEventMask | CWBitGravity,
    &attributes);

    wm_hints.flags = InputHint;
    wm_hints.input = False;
    /* XmbSetWMProperties(display, dst_window,
    "xrender-rotate", NULL, argv, argc,
    NULL, &wm_hints, NULL);*/
    protocols[0] = atoms[WM_DELETE_WINDOW];
    XSetWMProtocols(display, dst_window, protocols, 1);
    return dst_window;

    }

    static XFixed
    float_to_fixed(float f)
    {
    fprintf(stderr, "f %f\n",f* 0x10000);
    return f * 0x10000;

    }

    static int
    demonstrate_render(Display *display, Window src_window, Window
    dst_window)
    {
    int ok = 0;
    Picture src_picture = None;
    Picture dst_picture = None;
    XRenderPictFormat *src_pictformat = NULL;
    XRenderPictFormat *dst_pictformat = NULL;
    XRenderPictureAttributes pictattr = {0};
    XWindowAttributes src_window_attributes;
    XWindowAttributes dst_window_attributes;

    pictattr.repeat = RepeatNormal;
    if (!XGetWindowAttributes(display, src_window,
    &src_window_attributes)) {
    fprintf(stderr, "Cannot retrieve source window attributes\n");
    goto error;
    }
    if (!XGetWindowAttributes(display, dst_window,
    &dst_window_attributes)) {
    fprintf(stderr, "Cannot retrieve destination window attributes
    \n");
    goto error;
    }
    src_pictformat = XRenderFindVisualFormat(display,

    src_window_attributes.visual);
    dst_pictformat = XRenderFindVisualFormat(display,

    dst_window_attributes.visual);
    src_picture = XRenderCreatePicture(display, src_window,
    src_pictformat,
    CPRepeat, &pictattr);
    dst_picture = XRenderCreatePicture(display, dst_window,
    dst_pictformat,
    CPRepeat, &pictattr);


    XTransform transform = {{{XDoubleToFixed (1.0), 0, 0 },
    {0, XDoubleToFixed (1.0), 0 },
    {0, 0, XDoubleToFixed (1.0)}}};
    XRenderSetPictureTransform(display, src_picture, &transform);
    XRenderSetPictureFilter(display, src_picture, "fast", NULL, 0);

    XRenderComposite(display, PictOpSrc, src_picture, None, dst_picture,
    0, 0, 0, 0, 0, 0,
    dst_window_attributes.width,
    dst_window_attributes.height);

    ok = 1;
    error:
    if (src_picture != None)
    XRenderFreePicture(display, src_picture);
    if (dst_picture != None)
    XRenderFreePicture(display, dst_picture);
    return ok;

    }

    int
    main(int argc, char **argv)
    {
    int mainret = EXIT_FAILURE;
    Display *display = NULL;
    Atom atoms[ATOMCOUNT];

    int render_event_base;
    int render_error_base;
    int render_major_ver;
    int render_minor_ver;
    Window src_window;
    Window dst_window = None;
    XEvent event;

    if (argc != 2) {
    fprintf(stderr, "Usage: xrender-rotate WINDOWID\n");
    goto error;
    }
    src_window = strtol(argv[1], NULL, 0);

    display = XOpenDisplay(NULL);
    if (display == NULL) {
    fprintf(stderr, "Cannot open display\n");
    goto error;
    }

    XInternAtoms(display, atom_names, ATOMCOUNT, False, atoms);

    if (!XRenderQueryExtension(display, &render_event_base,
    &render_error_base)) {
    fprintf(stderr, "RENDER extension not found and alternative code
    not yet implemented\n");
    goto error;
    }
    if (!XRenderQueryVersion(display, &render_major_ver,
    &render_minor_ver)) {
    fprintf(stderr, "RENDER extension version is unclear\n");
    goto error;
    }


    dst_window = create_dst_window(display, atoms, argc, argv);
    XMapWindow(display, dst_window);

    for (; {
    XNextEvent(display, &event);
    switch (event.type) {
    case Expose:
    if (event.xexpose.count == 0) {
    if (!demonstrate_render(display, src_window, dst_window))
    goto error;
    }
    break;
    case ClientMessage:
    if (event.xclient.data.l[0] == atoms[WM_DELETE_WINDOW])
    goto finish;
    }
    }

    finish:
    mainret = EXIT_SUCCESS;
    error:
    if (dst_window != None)
    XDestroyWindow(display, dst_window);
    if (display != NULL)
    XCloseDisplay(display);
    return mainret;
    }

  2. Re: XRenderSetPictureTransform: Black window

    jubi writes:

    > But when I use this
    > XTransform transform = {{{XDoubleToFixed (1.2), 0, 0 },
    > {0, XDoubleToFixed (1.2), 0 },
    > {0, 0, XDoubleToFixed (1.0)}}};
    >
    > i get a black window. So, what`s wrong?


    I don't know why the program doesn't work, but I wondered about
    the same thing in article
    on 2007-12-25. Your test program seems based on mine. Please
    credit your sources.


    does not document the XDoubleToFixed macro, so I did not use it.

  3. Re: XRenderSetPictureTransform: Black window

    jubi wrote:
    > Hallo,
    > i want to use xrender to rotate the contents of a window. It works
    > with the following transformation matrix
    >
    > XTransform transform = {{{XDoubleToFixed (1.0), 0, 0 },
    > {0, XDoubleToFixed (1.0), 0 },
    > {0, 0, XDoubleToFixed (1.0)}}};
    >
    > like in the sample code. But when I use this
    > XTransform transform = {{{XDoubleToFixed (1.2), 0, 0 },
    > {0, XDoubleToFixed (1.2), 0 },
    > {0, 0, XDoubleToFixed (1.0)}}};
    >
    > i get a black window. So, what`s wrong?


    Are you sure your video driver supports Render and Composite? Nvidia
    drivers for instance for my cards don't support Composite if GLX is
    enabled. This all makes it rather pointless to have those extensions.

    Perhaps X12 or X13 will fix the problems, or a totally different window
    system, if Nvidia and others can stop writing proprietary software that
    halts progress.

    I think it's time for a new model that utilizes shared memory window
    buffers, with automatic double-buffering. With optional network
    transparency when needed.


    George

+ Reply to Thread