From c18b773a01dc5a169c15dd47d4fcd9bc782fd3c8 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 28 Apr 2023 19:22:32 -0700 Subject: [PATCH] monitor calibration test block --- ...standalone_srgb_antialiasing_experiments.c | 82 ++++++++++++++++++- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/src/standalone_srgb_antialiasing_experiments.c b/src/standalone_srgb_antialiasing_experiments.c index 1928066..bd08c6d 100644 --- a/src/standalone_srgb_antialiasing_experiments.c +++ b/src/standalone_srgb_antialiasing_experiments.c @@ -717,19 +717,23 @@ static GLuint test3_texture = 0; #define CIRCLE5_X 6.f #define CIRCLE5_Y 6.f #define CIRCLE5_SIDE 12 -static GLuint circle5_texture = 0; +static GLuint circle5_texture = 0; #define CIRCLE25_RADIUS 25.f #define CIRCLE25_X 30.f #define CIRCLE25_Y 30.f #define CIRCLE25_SIDE 60 -static GLuint circle25_texture = 0; +static GLuint circle25_texture = 0; #define CIRCLE125_RADIUS 125.f #define CIRCLE125_X 150.f #define CIRCLE125_Y 150.f #define CIRCLE125_SIDE 300 -static GLuint circle125_texture = 0; +static GLuint circle125_texture = 0; + + +#define CALIBRATION_SIDE 120 +static GLuint calibration_texture = 0; static void @@ -919,6 +923,50 @@ opengl_render_init(void){ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } + //- calibration texture + { + U8 buf[CALIBRATION_SIDE*CALIBRATION_SIDE] = {0}; + // checkerboards + for (U32 x = 0; x < (CALIBRATION_SIDE/2); x += 1){ + for (U32 y = 0; y < (CALIBRATION_SIDE/2); y += 1){ + B32 b = (((x + y)&1) == 1); + U8 c = b?255:0; + buf[x + y*CALIBRATION_SIDE] = c; + buf[x + (CALIBRATION_SIDE/2) + (y + (CALIBRATION_SIDE/2))*CALIBRATION_SIDE] = c; + } + } + // (1/2) gray srgb + for (U32 x = 0; x < (CALIBRATION_SIDE/2); x += 1){ + for (U32 y = 0; y < (CALIBRATION_SIDE/2); y += 1){ + buf[x + (CALIBRATION_SIDE/2) + y*CALIBRATION_SIDE] = 128; + } + } + // (1/2) gray linear + for (U32 x = 0; x < (CALIBRATION_SIDE/2); x += 1){ + for (U32 y = 0; y < (CALIBRATION_SIDE/2); y += 1){ + buf[x + (y + (CALIBRATION_SIDE/2))*CALIBRATION_SIDE] = 186; + } + } + + U8 img[CALIBRATION_SIDE*CALIBRATION_SIDE*3] = {0}; + for (U32 i = 0; i < CALIBRATION_SIDE*CALIBRATION_SIDE; i += 1){ + U8 c = buf[i]; + img[i*3 + 0] = c; + img[i*3 + 1] = c; + img[i*3 + 2] = c; + } + + glGenTextures(1, &calibration_texture); + glBindTexture(GL_TEXTURE_2D, calibration_texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, CALIBRATION_SIDE, CALIBRATION_SIDE, 0, + GL_RGB, GL_UNSIGNED_BYTE, img); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + //- check for setup errors if (glGetError() != 0){ error_message("error in opengl renderer initialization"); @@ -1091,6 +1139,9 @@ WinMain(HINSTANCE hInstance, F32 test7_y = graphics_h - 480.f; F32 test8_y = graphics_h - 800.f; + F32 calib_y = graphics_h - 10.f; + F32 calib_x = 10.f; + // render to canvas frame buffer { glBindFramebuffer(GL_FRAMEBUFFER, canvas_framebuffer); @@ -1593,6 +1644,31 @@ WinMain(HINSTANCE hInstance, } } } + + // 9: color calibration blocks + if (test_idx == 0){ + F32 y1 = calib_y; + F32 y0 = calib_y - CALIBRATION_SIDE; + F32 x0 = calib_x; + F32 x1 = calib_x + CALIBRATION_SIDE; + + Vertex v[6]; + v[0].px = x0; v[0].py = y0; + v[0].uvx = 0.f; v[0].uvy = 0.f; + v[1].px = x0; v[1].py = y1; + v[1].uvx = 0.f; v[1].uvy = 1.f; + v[2].px = x1; v[2].py = y0; + v[2].uvx = 1.f; v[2].uvy = 0.f; + v[3].px = x0; v[3].py = y1; + v[3].uvx = 0.f; v[3].uvy = 1.f; + v[4].px = x1; v[4].py = y0; + v[4].uvx = 1.f; v[4].uvy = 0.f; + v[5].px = x1; v[5].py = y1; + v[5].uvx = 1.f; v[5].uvy = 1.f; + + opengl_draw_texture_geometry(v, 6, calibration_texture); + } + } }