Beginner Questions About XCB - xcb_alloc_color is too slow
Mark Solomonik
marik.solomonik at gmail.com
Sun Feb 21 02:37:38 UTC 2021
Hello,
I am trying to implement a 3D engine from scratch with XCB. To do this, I
have to set the color of every individual pixel before drawing it.
I noticed that calling xcb_alloc_color and xcb_alloc_color_reply are
bottlenecking the program and making it slow to draw individual triangles.
Below is how I am setting the color before drawing each pixel, straight
from this tutorial
<https://www.x.org/releases/X11R7.7/doc/libxcb/tutorial/index.html#usecolor>
:
void set_drawing_color(xcb_connection_t *c, xcb_colormap_t colormap,
xcb_gcontext_t gcontext, int r, int g, int b) {
xcb_alloc_color_reply_t *color_info;
uint32_t mask;
uint32_t value[3];
color_info = xcb_alloc_color_reply(c, xcb_alloc_color(c, colormap,
r, g, b), NULL);
if (!color_info)
return 0;
free(color_info);
mask = XCB_GC_FOREGROUND;
value[0] = color_info->pixel;
xcb_change_gc(c, gcontext, mask, value);}
Is this an appropriate way to set the color? Is there a more efficient
way to do so?
Slightly unrelated question: as someone completely new to Xorg and
Linux graphics in general,
how do you deal with the lack of documentation for XCB?
Thanks,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg/attachments/20210220/9d99d048/attachment.htm>
More information about the xorg
mailing list