Hi, I'm trying to learn coding with XCB and found an issue the XCB people think should be placed her.
Drawing a diamond seems to render correctly only if started (end ended) at the right-most corner, drawing from any other corner causes the right-most pixel not to be rendered. As I'm new to XCB and Xlib programing my assumption is that I am doing something stupid, but I can't see where I failed, so any help is appreciated. I've tried to make a MWE that demonstrates the issue. It uses the xcb lib, and compiles with gcc -lxcb <source-file> (with a high DPI screen you likely need to zoom in to see the problem (screenshot)). ~Per --- #include <stdlib.h> #include <stdio.h> #include <xcb/xcb.h> xcb_connection_t *connection; xcb_drawable_t window; xcb_screen_t *screen; xcb_gcontext_t foreground; void draw_diamond (int x, int y, xcb_point_t *points) { xcb_point_t diamond [5]; for (int i = 0; i < 4; i++) { diamond [i].x = x + points [i].x; diamond [i].y = y + points [i].y; } diamond [4] = diamond [0]; xcb_poly_line (connection, XCB_COORD_MODE_ORIGIN, window, foreground, 5, diamond); } xcb_point_t P_Top = { 0, -5 }; xcb_point_t P_Right = { 5, 0 }; xcb_point_t P_Left = { -5, 0 }; xcb_point_t P_Bottom = { 0, 5 }; int main () { xcb_point_t ccT[] = { P_Top, P_Right, P_Bottom, P_Left }; xcb_point_t ccR[] = { P_Right, P_Bottom, P_Left, P_Top }; xcb_point_t ccB[] = { P_Bottom, P_Left, P_Top, P_Right }; xcb_point_t ccL[] = { P_Left, P_Top, P_Right, P_Bottom }; xcb_point_t cccT[] = { P_Top, P_Left, P_Bottom, P_Right }; xcb_point_t cccR[] = { P_Right, P_Top, P_Left, P_Bottom }; xcb_point_t cccB[] = { P_Bottom, P_Right, P_Top, P_Left }; xcb_point_t cccL[] = { P_Left, P_Bottom, P_Right, P_Top }; /* Open the connection to the X server */ connection = xcb_connect (NULL, NULL); /* Get the first screen */ screen = xcb_setup_roots_iterator (xcb_get_setup (connection)).data; /* Create black (foreground) graphic context */ window = screen->root; foreground = xcb_generate_id (connection); uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; uint32_t values[2] = {screen->black_pixel, 0}; xcb_create_gc (connection, foreground, window, mask, values); /* Create a window */ window = xcb_generate_id (connection); mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; values[0] = screen->white_pixel; values[1] = XCB_EVENT_MASK_EXPOSURE; xcb_create_window (connection, /* connection */ XCB_COPY_FROM_PARENT, /* depth */ window, /* window Id */ screen->root, /* parent window */ 0, 0, /* x, y */ 150, 150, /* width, height */ 10, /* border_width */ XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class */ screen->root_visual, /* visual */ mask, values ); /* masks */ /* Map the window on the screen and flush*/ xcb_map_window (connection, window); xcb_flush (connection); /* draw primitives */ xcb_generic_event_t *event; while ((event = xcb_wait_for_event (connection))) { switch (event->response_type & ~0x80) { case XCB_EXPOSE: draw_diamond (10, 10, ccT); draw_diamond (25, 10, ccR); draw_diamond (40, 10, ccB); draw_diamond (55, 10, ccL); draw_diamond (10, 30, cccT); draw_diamond (25, 30, cccR); draw_diamond (40, 30, cccB); draw_diamond (55, 30, cccL); /* flush the request */ xcb_flush (connection); break; default: /* Unknown event type, ignore it */ break; } free (event); } return 0; } --- _______________________________________________ xorg@lists.x.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: https://lists.x.org/mailman/listinfo/xorg Your subscription address: %(user_address)s