1 #include "tests.h" 2 3 #define SHIFT 4 4 #define SIZE (1 << SHIFT) 5 float data[SIZE][SIZE]; 6 main()7int main() 8 { 9 printf("Ordered dither matrix:\n"); 10 pl_generate_bayer_matrix(&data[0][0], SIZE); 11 for (int y = 0; y < SIZE; y++) { 12 for (int x = 0; x < SIZE; x++) 13 printf(" %3d", (int)(data[y][x] * SIZE * SIZE)); 14 printf("\n"); 15 } 16 17 printf("Blue noise dither matrix:\n"); 18 pl_generate_blue_noise(&data[0][0], SHIFT); 19 for (int y = 0; y < SIZE; y++) { 20 for (int x = 0; x < SIZE; x++) 21 printf(" %3d", (int)(data[y][x] * SIZE * SIZE)); 22 printf("\n"); 23 } 24 25 // Generate an example of a dither shader 26 pl_log log = pl_test_logger(); 27 pl_shader sh = pl_shader_alloc(log, NULL); 28 pl_shader_obj obj = NULL; 29 30 pl_shader_dither(sh, 8, &obj, NULL); 31 const struct pl_shader_res *res = pl_shader_finalize(sh); 32 REQUIRE(res); 33 printf("Generated dither shader:\n%s\n", res->glsl); 34 35 pl_shader_obj_destroy(&obj); 36 pl_shader_free(&sh); 37 pl_log_destroy(&log); 38 } 39