To skip swapbuffers, or only test points/lines/quads. --- src/tests/calibrate_rast.c | 130 ++++++++++++++++++++++++++++++--------------- 1 file changed, 88 insertions(+), 42 deletions(-)
diff --git a/src/tests/calibrate_rast.c b/src/tests/calibrate_rast.c index ae9ff10..0bbbf84 100644 --- a/src/tests/calibrate_rast.c +++ b/src/tests/calibrate_rast.c @@ -17,15 +17,18 @@ #include <assert.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <GL/glew.h> #include "glut_wrap.h" +static bool NoSwap = false; static int Width = 100, Height = 100; static int Win; -static float Step = 0.125; +static float Step = 1.0 / 16.0; #if 0 /* This tiny offset fixes errors in Mesa/Xlib */ static float Xtrans = 0.5 * 0.125; @@ -35,6 +38,15 @@ static float Xtrans = 0.0; static float Ytrans = 0.0; #endif +enum prim { + PRIM_POINTS, + PRIM_LINES, + PRIM_QUADS, + PRIM_ALL +}; + +static enum prim TestPrim = PRIM_ALL; + static void PointCalibrate(int xpos, int ypos) @@ -64,11 +76,13 @@ PointCalibrate(int xpos, int ypos) if (y > ymax) ymax = y; } - glutSwapBuffers(); + + if (!NoSwap) + glutSwapBuffers(); } } - printf("Point at (%2d, %2d) drawn for x in [%6.3f, %6.3f] and y in [%6.3f, %6.3f]\n", + printf("Point at (%2d, %2d) drawn for x in [%7.4f, %7.4f] and y in [%7.4f, %7.4f]\n", xpos, ypos, xpos + xmin, xpos + xmax, ypos + ymin, ypos + ymax); @@ -127,10 +141,12 @@ HLineCalibrate(int xpos, int ypos, int len) if (y > ymax) ymax = y; } - glutSwapBuffers(); + + if (!NoSwap) + glutSwapBuffers(); } - printf("H-line at Y=%2d drawn for y in [%6.3f, %6.3f]\n", + printf("H-line at Y=%2d drawn for y in [%7.4f, %7.4f]\n", ypos, ypos + ymin, ypos + ymax); @@ -175,11 +191,13 @@ HLineCalibrate(int xpos, int ypos, int len) if (x > xmax_right) xmax_right = x; } - glutSwapBuffers(); + + if (!NoSwap) + glutSwapBuffers(); } - printf("H-line [%d..%d) hit left end for x in [%6.3f, %6.3f] " - "hit right end for x in [%6.3f, %6.3f]\n", + printf("H-line [%d..%d) hit left end for x in [%7.4f, %7.4f] " + "hit right end for x in [%7.4f, %7.4f]\n", xpos, xpos + len, xpos + xmin_left, xpos + xmax_left, xpos + len + xmin_right, xpos + len + xmax_right); @@ -202,10 +220,10 @@ HLineCalibrate(int xpos, int ypos, int len) if (xmin_right < 0.0) { printf(" => Coords should be X biased by about %f\n", xmin_right ); } - if (xmax_left >= 1.0) { - printf(" => Coords should be X biased by about %f\n", -xmax_right + 1.0); + if (xmax_left > 1.0) { + printf(" => Coords should be X biased by about %f\n", -xmax_left + 1.0); } - if (xmax_right >= 1.0) { + if (xmax_right > 1.0) { printf(" => Coords should be X biased by about %f\n", -xmax_right + 1.0); } @@ -245,10 +263,12 @@ VLineCalibrate(int xpos, int ypos, int len) if (x > xmax) xmax = x; } - glutSwapBuffers(); + + if (!NoSwap) + glutSwapBuffers(); } - printf("V-line at X=%d drawn for x in [%6.3f, %6.3f]\n", + printf("V-line at X=%d drawn for x in [%7.4f, %7.4f]\n", xpos, xpos + xmin, xpos + xmax); @@ -293,11 +313,13 @@ VLineCalibrate(int xpos, int ypos, int len) if (y > ymax_top) ymax_top = y; } - glutSwapBuffers(); + + if (!NoSwap) + glutSwapBuffers(); } - printf("V-line [%d..%d) hit bottom end for y in [%6.3f, %6.3f] " - "hit top end for y in [%6.3f, %6.3f]\n", + printf("V-line [%d..%d) hit bottom end for y in [%7.4f, %7.4f] " + "hit top end for y in [%7.4f, %7.4f]\n", ypos, ypos + len, ypos + ymin_bottom, ypos + ymax_bottom, ypos + len + ymin_top, ypos + len + ymax_top); @@ -321,7 +343,7 @@ VLineCalibrate(int xpos, int ypos, int len) printf(" => Coords should be Y biased by about %f\n", ymin_top ); } if (ymax_bottom > 1.0) { - printf(" => Coords should be Y biased by about %f\n", -ymax_top + 1.0); + printf(" => Coords should be Y biased by about %f\n", -ymax_bottom + 1.0); } if (ymax_top > 1.0) { printf(" => Coords should be Y biased by about %f\n", -ymax_top + 1.0); @@ -374,12 +396,13 @@ QuadCalibrate(int xpos, int ypos, int width, int height) ymax = y; } - glutSwapBuffers(); + if (!NoSwap) + glutSwapBuffers(); } } printf("Quad at (%2d, %2d)..(%2d, %2d) drawn" - " for x in [%6.3f, %6.3f] and y in [%6.3f, %6.3f]\n", + " for x in [%7.4f, %7.4f] and y in [%7.4f, %7.4f]\n", xpos, ypos, xpos + width, ypos + height, xpos + xmin, xpos + xmax, @@ -441,34 +464,43 @@ Draw(void) glPushMatrix(); glTranslatef(Xtrans, Ytrans, 0); - PointCalibrate(1, 1); - PointCalibrate(50, 50); - PointCalibrate(28, 17); - PointCalibrate(17, 18); - printf("\n"); - - HLineCalibrate(5, 10, 10); - HLineCalibrate(25, 22, 12); - HLineCalibrate(54, 33, 12); - HLineCalibrate(54+12, 33, 12); - printf("\n"); - - VLineCalibrate(5, 10, 10); - VLineCalibrate(25, 22, 12); - VLineCalibrate(54, 33, 12); - VLineCalibrate(54+12, 33, 12); - printf("\n"); - - QuadCalibrate(2, 2, 10, 10); - QuadCalibrate(50, 50, 10, 10); - QuadCalibrate(28, 17, 12, 12); - QuadCalibrate(17, 28, 12, 12); + printf("Probe step size: %f\n", Step); + + if (TestPrim == PRIM_POINTS || TestPrim == PRIM_ALL) { + PointCalibrate(1, 1); + PointCalibrate(50, 50); + PointCalibrate(28, 17); + PointCalibrate(17, 18); + printf("\n"); + } + + if (TestPrim == PRIM_LINES || TestPrim == PRIM_ALL) { + HLineCalibrate(5, 10, 10); + HLineCalibrate(25, 22, 12); + HLineCalibrate(54, 33, 12); + HLineCalibrate(54+12, 33, 12); + printf("\n"); + + VLineCalibrate(5, 10, 10); + VLineCalibrate(25, 22, 12); + VLineCalibrate(54, 33, 12); + VLineCalibrate(54+12, 33, 12); + printf("\n"); + } + + if (TestPrim == PRIM_QUADS || TestPrim == PRIM_ALL) { + QuadCalibrate(2, 2, 10, 10); + QuadCalibrate(50, 50, 10, 10); + QuadCalibrate(28, 17, 12, 12); + QuadCalibrate(17, 28, 12, 12); + } (void) DebugTest; glPopMatrix(); - // glutSwapBuffers(); + if (NoSwap) + glutSwapBuffers(); } @@ -513,7 +545,21 @@ Init(void) int main(int argc, char *argv[]) { + int i; + glutInit(&argc, argv); + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "--noswap") == 0) + NoSwap = true; + else if (strcmp(argv[i], "--points") == 0) + TestPrim = PRIM_POINTS; + else if (strcmp(argv[i], "--lines") == 0) + TestPrim = PRIM_LINES; + else if (strcmp(argv[i], "--quads") == 0) + TestPrim = PRIM_QUADS; + } + glutInitWindowPosition(0, 0); glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); -- 1.9.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev