/* * Pixelflut binary UDP protocol, shared by the renderer and the benchmark. * * Packet layout (little-endian on the wire): * * +------+---------+ pixelflut_packet * | cmd | subcmd | 2-byte header * +------+---------+---------+----+----+----+ pixelflut_pixel[0] * | x (u16) | y (u16) | r | g | b | 7 bytes * +----------------+---------+----+----+----+ * | ... | PIXELS_PER_PACKET pixels * +----------------------------------------+ */ #ifndef PIXELFLUT_H #define PIXELFLUT_H #include /* Header bytes. */ #define PIXELFLUT_CMD_SET 0x00 /* "set pixels" command ... */ #define PIXELFLUT_SUBCMD_RGB 0x01 /* ... with 3-byte RGB colours */ /* Pixels batched into a single UDP datagram. */ #define PIXELS_PER_PACKET 120 #pragma pack(push, 1) /* A single pixel as it appears on the wire. */ struct pixelflut_pixel { uint16_t x; /* little-endian */ uint16_t y; /* little-endian */ uint8_t r; uint8_t g; uint8_t b; }; /* A full datagram: header followed by a batch of pixels. */ struct pixelflut_packet { uint8_t cmd; uint8_t subcmd; struct pixelflut_pixel pixels[PIXELS_PER_PACKET]; }; #pragma pack(pop) _Static_assert(sizeof(struct pixelflut_pixel) == 7, "pixel must be exactly 7 bytes on the wire"); _Static_assert(sizeof(struct pixelflut_packet) == 2 + 7 * PIXELS_PER_PACKET, "packet must be header + PIXELS_PER_PACKET pixels, no padding"); #endif /* PIXELFLUT_H */