blind-triangle-tessellation.c (2901B)
1 /* See LICENSE file for copyright and license details. */ 2 #include "common.h" 3 4 USAGE("[-F pixel-format] block-width block-height") 5 6 #define SET_XYZA(TYPE)\ 7 (colours = alloca(8 * stream.pixel_size),\ 8 ((TYPE *)colours)[ 0] = (TYPE)0.412457445582367600,\ 9 ((TYPE *)colours)[ 1] = (TYPE)0.212673370378408280,\ 10 ((TYPE *)colours)[ 2] = (TYPE)0.019333942761673460,\ 11 ((TYPE *)colours)[ 3] = (TYPE)1,\ 12 ((TYPE *)colours)[ 4] = (TYPE)0.206228722791183800,\ 13 ((TYPE *)colours)[ 5] = (TYPE)0.106336685189204140,\ 14 ((TYPE *)colours)[ 6] = (TYPE)0.009666971380836730,\ 15 ((TYPE *)colours)[ 7] = (TYPE)1,\ 16 ((TYPE *)colours)[ 8] = (TYPE)0.770033310827883400,\ 17 ((TYPE *)colours)[ 9] = (TYPE)0.927825100869440000,\ 18 ((TYPE *)colours)[10] = (TYPE)0.138525897843512050,\ 19 ((TYPE *)colours)[11] = (TYPE)1,\ 20 ((TYPE *)colours)[12] = (TYPE)0.385016655413941700,\ 21 ((TYPE *)colours)[13] = (TYPE)0.463912550434720000,\ 22 ((TYPE *)colours)[14] = (TYPE)0.069262948921756020,\ 23 ((TYPE *)colours)[15] = (TYPE)1,\ 24 ((TYPE *)colours)[16] = (TYPE)0.357575865245515900,\ 25 ((TYPE *)colours)[17] = (TYPE)0.715151730491031800,\ 26 ((TYPE *)colours)[18] = (TYPE)0.119191955081838600,\ 27 ((TYPE *)colours)[19] = (TYPE)1,\ 28 ((TYPE *)colours)[20] = (TYPE)0.178787932622757940,\ 29 ((TYPE *)colours)[21] = (TYPE)0.357575865245515900,\ 30 ((TYPE *)colours)[22] = (TYPE)0.059595977540919300,\ 31 ((TYPE *)colours)[23] = (TYPE)1,\ 32 ((TYPE *)colours)[24] = (TYPE)(1.0 * D65_XYZ_X),\ 33 ((TYPE *)colours)[25] = (TYPE)(1.0),\ 34 ((TYPE *)colours)[26] = (TYPE)(1.0 * D65_XYZ_Z),\ 35 ((TYPE *)colours)[27] = (TYPE)1,\ 36 ((TYPE *)colours)[28] = (TYPE)(0.5 * D65_XYZ_X),\ 37 ((TYPE *)colours)[29] = (TYPE)(0.5),\ 38 ((TYPE *)colours)[30] = (TYPE)(0.5 * D65_XYZ_Z),\ 39 ((TYPE *)colours)[31] = (TYPE)1) 40 41 static struct stream stream = { .width = 0, .height = 0, .frames = 1 }; 42 43 int 44 main(int argc, char *argv[]) 45 { 46 size_t width, height; 47 const char *pixfmt = "xyza"; 48 char *colours; 49 size_t x1, y1, x2, y2, k; 50 51 ARGBEGIN { 52 case 'F': 53 pixfmt = UARGF(); 54 break; 55 default: 56 usage(); 57 } ARGEND; 58 59 if (argc != 2) 60 usage(); 61 62 width = etozu_arg("block-width", argv[0], 1, SIZE_MAX); 63 height = etozu_arg("block-height", argv[1], 1, SIZE_MAX); 64 65 eset_pixel_format(&stream, pixfmt); 66 CHECK_N_CHAN(&stream, 4, 4); 67 if (stream.encoding == DOUBLE) 68 SET_XYZA(double); 69 else if (stream.encoding == FLOAT) 70 SET_XYZA(float); 71 else 72 eprintf("pixel format %s is not supported, try xyza\n", stream.pixfmt); 73 74 stream.width = 2 * width; 75 stream.height = 2 * height; 76 fprint_stream_head(stdout, &stream); 77 efflush(stdout, "<stdout>"); 78 79 for (y1 = 0; y1 < 2; y1++) { 80 for (y2 = 0; y2 < height; y2++) { 81 for (x1 = 0; x1 < 2; x1++) { 82 for (x2 = 0; x2 < width; x2++) { 83 k = y1 * 4 + x1 * 2 + (x2 * height > y2 * width); 84 ewriteall(STDOUT_FILENO, colours + k * stream.pixel_size, stream.pixel_size, "<stdout>"); 85 } 86 } 87 } 88 } 89 90 return 0; 91 }