summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura Ekstrand <laura@jlekstrand.net>2014-10-10 18:01:18 -0700
committerLaura Ekstrand <laura@jlekstrand.net>2014-10-10 18:01:18 -0700
commite7a347cfadc490838189059b074218486d2e0c62 (patch)
tree2ef941c57fbe1b5bf6dd23e16acff6069cde12ce
parent422ed34b7f943f87dd3367e5514c92238b3e02f3 (diff)
Changed the style of orthpos.c to match piglit variable styles.ldeks
-rw-r--r--tests/spec/laura_orthpos/orthpos.c270
1 files changed, 135 insertions, 135 deletions
diff --git a/tests/spec/laura_orthpos/orthpos.c b/tests/spec/laura_orthpos/orthpos.c
index b19e0a165..9dcf750c6 100644
--- a/tests/spec/laura_orthpos/orthpos.c
+++ b/tests/spec/laura_orthpos/orthpos.c
@@ -68,8 +68,8 @@
#include <stdlib.h>
#include <stdio.h>
-#define windowSize piglit_width
-#define drawingSize windowSize - 2
+#define window_size piglit_width
+#define drawing_size window_size - 2
PIGLIT_GL_TEST_CONFIG_BEGIN
@@ -80,22 +80,22 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
PIGLIT_GL_TEST_CONFIG_END
struct orthpos_result {
- bool hasGaps, hasOverlaps, hasBadEdges;
+ bool has_gaps, has_overlaps, has_bad_edges;
};
-static int imgBytes;
+static int img_bytes;
static GLubyte* img;
void
piglit_init(int argc, char **argv)
{
srand(0);
- imgBytes = windowSize * windowSize *
+ img_bytes = window_size * window_size *
piglit_num_components(GL_RGB) * sizeof(GLubyte);
- img = malloc(imgBytes);
+ img = malloc(img_bytes);
/* Common setup */
- piglit_ortho_projection(windowSize, windowSize, GL_FALSE);
+ piglit_ortho_projection(window_size, window_size, GL_FALSE);
glTranslatef(0.375f, 0.375f, 0);
glFrontFace(GL_CCW);
@@ -108,22 +108,22 @@ piglit_init(int argc, char **argv)
}
bool
-logStats1(const char* title, struct orthpos_result* r) {
+log_results(const char* title, struct orthpos_result* r) {
bool pass = true;
printf("\t%s: ", title);
- if (r->hasGaps || r->hasOverlaps || r->hasBadEdges) {
- printf("%s %s %s\n", (r->hasGaps? "Gaps.": ""),
- (r->hasOverlaps? " Overlaps.": ""),
- (r->hasBadEdges? " Incorrect edges.": ""));
+ if (r->has_gaps || r->has_overlaps || r->has_bad_edges) {
+ printf("%s %s %s\n", (r->has_gaps? "Gaps.": ""),
+ (r->has_overlaps? " Overlaps.": ""),
+ (r->has_bad_edges? " Incorrect edges.": ""));
pass = false;
} else {
printf(" No gaps, overlaps, or incorrect edges.\n");
}
return pass;
-} /* logStats1 */
+} /* log_results */
GLubyte
-logicalSum(GLubyte* start, int stride, int count) {
+logical_sum(GLubyte* start, int stride, int count) {
GLubyte* p = start;
GLubyte sum = 0;
int i;
@@ -137,13 +137,13 @@ logicalSum(GLubyte* start, int stride, int count) {
}
bool
-verifyOrthPos(const GLubyte* img, GLsizei imgRowSizeInBytes,
+verify_orth_pos(const GLubyte* img, GLsizei img_row_size_in_bytes,
const char* title) {
/*
* All of the tests in this group are constructed so that the
- * "correct" image covers a square of exactly drawingSize by
- * drawingSize pixels, embedded in a window that's two pixels
+ * "correct" image covers a square of exactly drawing_size by
+ * drawing_size pixels, embedded in a window that's two pixels
* larger in both dimensions. The border consists of pixels
* with all components set to zero. Within the image, all
* pixels should be either red (only the red component is
@@ -159,69 +159,69 @@ verifyOrthPos(const GLubyte* img, GLsizei imgRowSizeInBytes,
/* For examining edges */
GLubyte* row0 = (GLubyte*) img;
- GLubyte* row1 = row0 + imgRowSizeInBytes;
- GLubyte* rowLast = row0 + (windowSize - 1) * imgRowSizeInBytes;
- GLubyte* rowNextLast = rowLast - imgRowSizeInBytes;
+ GLubyte* row1 = row0 + img_row_size_in_bytes;
+ GLubyte* row_last = row0 + (window_size - 1) * img_row_size_in_bytes;
+ GLubyte* row_next_last = row_last - img_row_size_in_bytes;
/* For examining the drawing area */
int i, j, idx;
GLubyte red, green, blue;
/* Initialize results */
- res.hasGaps = false;
- res.hasOverlaps = false;
- res.hasBadEdges = false;
+ res.has_gaps = false;
+ res.has_overlaps = false;
+ res.has_bad_edges = false;
/* Check the bottom horizontal edge; it must be all zero. */
- if (logicalSum(row0, 3, windowSize)) {
+ if (logical_sum(row0, 3, window_size)) {
printf("\t%s: bottom border (at Y==0) was touched\n", title);
- res.hasBadEdges = true;
+ res.has_bad_edges = true;
}
/* Repeat the process for the top horizontal edge. */
- if (logicalSum(rowLast, 3, windowSize)) {
+ if (logical_sum(row_last, 3, window_size)) {
printf("\t%s: top border (at Y==%i) was touched\n",
- title, windowSize - 1);
- res.hasBadEdges = true;
+ title, window_size - 1);
+ res.has_bad_edges = true;
}
/*
* Check the second row; there must be at least one nonzero
* pixel in the "drawn" region (excluding the first and last
* column).
*/
- if (!logicalSum(row1 + 3/*skip first pixel's RGB*/, 3, drawingSize)) {
+ if (!logical_sum(row1 + 3/*skip first pixel's RGB*/, 3, drawing_size)) {
printf("\t%s: first row (at Y==1) was not drawn\n", title);
- res.hasBadEdges = true;
+ res.has_bad_edges = true;
}
/* Repeat the process for the last row. */
- if (!logicalSum(rowNextLast + 3, 3, drawingSize)) {
+ if (!logical_sum(row_next_last + 3, 3, drawing_size)) {
printf("\t%s: last row (at Y==%i) was not drawn\n",
- title, windowSize - 2);
- res.hasBadEdges = true;
+ title, window_size - 2);
+ res.has_bad_edges = true;
}
/* Check the left-hand vertical edge; it must be all zero. */
- if (logicalSum(row0, imgRowSizeInBytes, windowSize)) {
+ if (logical_sum(row0, img_row_size_in_bytes, window_size)) {
printf("\t%s: left border (at X==0) was touched\n", title);
- res.hasBadEdges = true;
+ res.has_bad_edges = true;
}
/* Repeat for the right-hand vertical edge. */
- if (logicalSum(row0 + 3 * (windowSize - 1), imgRowSizeInBytes,
- windowSize)) {
+ if (logical_sum(row0 + 3 * (window_size - 1), img_row_size_in_bytes,
+ window_size)) {
printf("\t%s: right border (at X==%i) was touched\n",
- title, windowSize - 1);
- res.hasBadEdges = true;
+ title, window_size - 1);
+ res.has_bad_edges = true;
}
/* Check the left-hand column; something must be nonzero. */
- if (!logicalSum(row1 + 3, imgRowSizeInBytes, drawingSize)) {
+ if (!logical_sum(row1 + 3, img_row_size_in_bytes, drawing_size)) {
printf("\t%s: first column (at X==1) was not drawn\n", title);
- res.hasBadEdges = true;
+ res.has_bad_edges = true;
}
/* And repeat for the right-hand column: */
- if (!logicalSum(row1 + 3 * (drawingSize - 1), imgRowSizeInBytes,
- drawingSize)) {
+ if (!logical_sum(row1 + 3 * (drawing_size - 1), img_row_size_in_bytes,
+ drawing_size)) {
printf("\t%s: last column (at X==%i) was not drawn\n",
- title, windowSize - 2);
- res.hasBadEdges = true;
+ title, window_size - 2);
+ res.has_bad_edges = true;
}
/*
@@ -230,36 +230,36 @@ verifyOrthPos(const GLubyte* img, GLsizei imgRowSizeInBytes,
* red and green components nonzero, that's an overlap.
*/
/* Not sure what was wrong with the original, but this works. */
- for (i = 1; i < windowSize - 1; ++i) {
- for (j = 1; j < windowSize - 1; ++j) {
- idx = 3*(windowSize*i + j);
+ for (i = 1; i < window_size - 1; ++i) {
+ for (j = 1; j < window_size - 1; ++j) {
+ idx = 3*(window_size*i + j);
red = img[idx + 0];
green = img[idx + 1];
blue = img[idx + 2];
if (!red && !green && !blue) {
- if (!res.hasGaps) {
+ if (!res.has_gaps) {
printf("\t%s: found first gap at X==%i, Y==%i\n",
title, j, i);
- res.hasGaps = true;
+ res.has_gaps = true;
}
}
if (red && green) {
- if (!res.hasOverlaps) {
+ if (!res.has_overlaps) {
printf("\t%s: found first overlap at X==%i, Y==%i\n",
title, j + 1, i + 1);
- res.hasOverlaps = true;
+ res.has_overlaps = true;
}
}
}
}
- return logStats1(title, &res);
-} /* verifyOrthPos */
+ return log_results(title, &res);
+} /* verify_orth_pos */
void
-subdivideRects(int minX, int maxX, int minY, int maxY,
- bool splitHoriz, bool drawInRed) {
+subdivide_rects(int minx, int maxx, int miny, int maxy,
+ bool split_horiz, bool draw_in_red) {
/*
* Basically we're just splitting the input rectangle
* recursively. At each step we alternate between splitting
@@ -271,32 +271,32 @@ subdivideRects(int minX, int maxX, int minY, int maxY,
*/
int split;
- int min = splitHoriz? minY: minX;
- int max = splitHoriz? maxY: maxX;
+ int min = split_horiz? miny: minx;
+ int max = split_horiz? maxy: maxx;
if (min + 30 > max) {
- glColor4f(drawInRed? 1.0: 0.0, drawInRed? 0.0: 1.0,
+ glColor4f(draw_in_red? 1.0: 0.0, draw_in_red? 0.0: 1.0,
0.0, 0.5);
glBegin(GL_QUADS);
- glVertex2i(minX, minY);
- glVertex2i(maxX, minY);
- glVertex2i(maxX, maxY);
- glVertex2i(minX, maxY);
+ glVertex2i(minx, miny);
+ glVertex2i(maxx, miny);
+ glVertex2i(maxx, maxy);
+ glVertex2i(minx, maxy);
glEnd();
return;
}
split = min + (int) ((max - min) *
((float) rand() / RAND_MAX)); /* Float in range [0.0f, 1.0f] */
- if (splitHoriz) {
- subdivideRects(minX, maxX, minY, split,
- !splitHoriz, drawInRed);
- subdivideRects(minX, maxX, split, maxY,
- !splitHoriz, !drawInRed);
+ if (split_horiz) {
+ subdivide_rects(minx, maxx, miny, split,
+ !split_horiz, draw_in_red);
+ subdivide_rects(minx, maxx, split, maxy,
+ !split_horiz, !draw_in_red);
} else {
- subdivideRects(minX, split, minY, maxY,
- !splitHoriz, drawInRed);
- subdivideRects(split, maxX, minY, maxY,
- !splitHoriz, !drawInRed);
+ subdivide_rects(minx, split, miny, maxy,
+ !split_horiz, draw_in_red);
+ subdivide_rects(split, maxx, miny, maxy,
+ !split_horiz, !draw_in_red);
}
}
@@ -322,14 +322,14 @@ subdivideRects(int minX, int maxX, int minY, int maxY,
*/
bool
-orthoPosPoints() {
+ortho_pos_points() {
int x, y;
/* Draw the image */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
- for (x = 1; x <= drawingSize; ++x) {
- for (y = 1; y <= drawingSize; ++y) {
+ for (x = 1; x <= drawing_size; ++x) {
+ for (y = 1; y <= drawing_size; ++y) {
if ((x ^ y) & 1) {
glColor4f(0.0, 1.0, 0.0, 0.5);
}
@@ -342,7 +342,7 @@ orthoPosPoints() {
glEnd();
/* Read the image */
- glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img);
+ glReadPixels(0, 0, window_size, window_size, GL_RGB, GL_UNSIGNED_BYTE, img);
/* Show the image */
if (!piglit_automatic) {
@@ -350,8 +350,8 @@ orthoPosPoints() {
}
/* Check the results */
- return verifyOrthPos(img, imgBytes/windowSize, "Immediate-mode points");
-} /* orthoPosPoints */
+ return verify_orth_pos(img, img_bytes/window_size, "Immediate-mode points");
+} /* ortho_pos_points */
/**
* This test checks the positioning of unit-width vertical lines
@@ -382,7 +382,7 @@ orthoPosPoints() {
* using OpenGL for 2D drawing.
*/
bool
-orthoPosVLines() {
+ortho_pos_vlines() {
/*
* Immediate-mode vertical lines
* Note that these are a little tricky, because of
@@ -398,18 +398,18 @@ orthoPosVLines() {
/* Draw the image */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
- for (x = 1; x <= drawingSize; ++x) {
+ for (x = 1; x <= drawing_size; ++x) {
if (x & 1)
glColor4f(0.0, 1.0, 0.0, 0.5);
else
glColor4f(1.0, 0.0, 0.0, 0.5);
glVertex2i(x, 1);
- glVertex2i(x, drawingSize + 1);
+ glVertex2i(x, drawing_size + 1);
}
glEnd();
/* Read the image */
- glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img);
+ glReadPixels(0, 0, window_size, window_size, GL_RGB, GL_UNSIGNED_BYTE, img);
/* Show the image */
if (!piglit_automatic) {
@@ -417,8 +417,8 @@ orthoPosVLines() {
}
/* Check the results */
- return verifyOrthPos(img, imgBytes/windowSize, "Immediate-mode vertical lines");
-} /* orthoPosVLines */
+ return verify_orth_pos(img, img_bytes/window_size, "Immediate-mode vertical lines");
+} /* ortho_pos_vlines */
/**
* This test checks the positioning of unit-width horizontal lines
@@ -449,7 +449,7 @@ orthoPosVLines() {
* using OpenGL for 2D drawing.
*/
bool
-orthoPosHLines() {
+ortho_pos_hlines() {
/*
* Immediate-mode horizontal lines
* See the comments in the vertical line case above.
@@ -459,18 +459,18 @@ orthoPosHLines() {
/* Draw the image */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
- for (y = 1; y <= drawingSize; ++y) {
+ for (y = 1; y <= drawing_size; ++y) {
if (y & 1)
glColor4f(0.0, 1.0, 0.0, 0.5);
else
glColor4f(1.0, 0.0, 0.0, 0.5);
glVertex2i(1, y);
- glVertex2i(drawingSize + 1, y);
+ glVertex2i(drawing_size + 1, y);
}
glEnd();
/* Read the image */
- glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img);
+ glReadPixels(0, 0, window_size, window_size, GL_RGB, GL_UNSIGNED_BYTE, img);
/* Show the image */
if (!piglit_automatic) {
@@ -478,8 +478,8 @@ orthoPosHLines() {
}
/* Check the results */
- return verifyOrthPos(img, imgBytes/windowSize, "Immediate-mode horizontal lines");
-} /* orthoPosHLines */
+ return verify_orth_pos(img, img_bytes/window_size, "Immediate-mode horizontal lines");
+} /* ortho_pos_hlines */
/**
* This test checks the positioning of 1x1-pixel quadrilaterals
@@ -502,7 +502,7 @@ orthoPosHLines() {
* pixels; this can cause gaps, overlaps, or bad edges.
*/
bool
-orthoPosTinyQuads() {
+ortho_pos_tiny_quads() {
/*
* Immediate-mode 1x1-pixel quads
*/
@@ -512,8 +512,8 @@ orthoPosTinyQuads() {
/* Draw the image */
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
- for (x = 1; x <= drawingSize; ++x)
- for (y = 1; y <= drawingSize; ++y) {
+ for (x = 1; x <= drawing_size; ++x)
+ for (y = 1; y <= drawing_size; ++y) {
if ((x ^ y) & 1)
glColor4f(0.0, 1.0, 0.0, 0.5);
else
@@ -526,7 +526,7 @@ orthoPosTinyQuads() {
glEnd();
/* Read the image */
- glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img);
+ glReadPixels(0, 0, window_size, window_size, GL_RGB, GL_UNSIGNED_BYTE, img);
/* Show the image */
if (!piglit_automatic) {
@@ -534,8 +534,8 @@ orthoPosTinyQuads() {
}
/* Check the results */
- return verifyOrthPos(img, imgBytes/windowSize, "Immediate-mode 1x1 quads");
-} /* orthoPosTinyQuads */
+ return verify_orth_pos(img, img_bytes/window_size, "Immediate-mode 1x1 quads");
+} /* ortho_pos_tiny_quads */
/**
* This test checks the positioning of axis-aligned rectangles
@@ -558,18 +558,18 @@ orthoPosTinyQuads() {
* pixels; this can cause gaps, overlaps, or bad edges.
*/
bool
-orthoPosRandRects() {
+ortho_pos_rand_rects() {
/*
* Immediate-mode random axis-aligned rectangles
*/
/* Draw the image */
glClear(GL_COLOR_BUFFER_BIT);
- subdivideRects(1, drawingSize + 1, 1, drawingSize + 1,
+ subdivide_rects(1, drawing_size + 1, 1, drawing_size + 1,
true, true);
/* Read the image */
- glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img);
+ glReadPixels(0, 0, window_size, window_size, GL_RGB, GL_UNSIGNED_BYTE, img);
/* Show the image */
if (!piglit_automatic) {
@@ -577,43 +577,43 @@ orthoPosRandRects() {
}
/* Check the results */
- return verifyOrthPos(img, imgBytes/windowSize,
+ return verify_orth_pos(img, img_bytes/window_size,
"Immediate-mode random axis-aligned rectangles");
-} /* orthoPosRandRects */
+} /* ortho_pos_rand_rects */
/* Factory for generating random mesh just like Glean's RandomMesh2D class */
float*
-randomMesh2D(float minX, float maxX, int xPoints,
- float minY, float maxY, int yPoints)
+random_mesh_2d(float minx, float maxx, int xpoints,
+ float miny, float maxy, int ypoints)
{
int x, y, idx;
- float* mesh = malloc(xPoints * yPoints * 2 * sizeof(float));
- double deltaX = 0.7 * (maxX - minX) / (xPoints - 1);
- double deltaY = 0.7 * (maxY - minY) / (yPoints - 1);
- float randNo;
+ float* mesh = malloc(xpoints * ypoints * 2 * sizeof(float));
+ double deltax = 0.7 * (maxx - minx) / (xpoints - 1);
+ double deltay = 0.7 * (maxy - miny) / (ypoints - 1);
+ float rand_no;
- for (y = 0; y < yPoints; ++y) {
- for (x = 0; x < xPoints; ++x) {
+ for (y = 0; y < ypoints; ++y) {
+ for (x = 0; x < xpoints; ++x) {
- idx = 2 * (xPoints * y + x);
+ idx = 2 * (xpoints * y + x);
/* Generate an unperturbed, uniform mesh */
- mesh[idx + 0] = minX + (x * (maxX - minX)) / (xPoints - 1);
- mesh[idx + 1] = minY + (y * (maxY - minY)) / (yPoints - 1);
+ mesh[idx + 0] = minx + (x * (maxx - minx)) / (xpoints - 1);
+ mesh[idx + 1] = miny + (y * (maxy - miny)) / (ypoints - 1);
/* Perturb the interior points of the mesh */
- if ((x != 0) && (y != 0) && (x != xPoints - 1) && (y != yPoints - 1))
+ if ((x != 0) && (y != 0) && (x != xpoints - 1) && (y != ypoints - 1))
{
- randNo = (float) rand() / RAND_MAX; /* Float in range [0.0f, 1.0f] */
- mesh[idx + 0] += deltaX * (randNo - 0.5);
- randNo = (float) rand() / RAND_MAX;
- mesh[idx + 1] += deltaY * (randNo - 0.5);
+ rand_no = (float) rand() / RAND_MAX; /* Float in range [0.0f, 1.0f] */
+ mesh[idx + 0] += deltax * (rand_no - 0.5);
+ rand_no = (float) rand() / RAND_MAX;
+ mesh[idx + 1] += deltay * (rand_no - 0.5);
}
}
}
return mesh;
-}
+} /* random_mesh_2d */
/**
* This test checks the positioning of random triangles under
@@ -636,32 +636,32 @@ randomMesh2D(float minX, float maxX, int xPoints,
* pixels; this can cause gaps, overlaps, or bad edges.
*/
bool
-orthoPosRandTris() {
+ortho_pos_rand_tris() {
/*
* Immediate-mode random triangles
*/
int i, j;
- int nPoints = 10;
+ int npoints = 10;
float* mesh;
/* Draw the image */
glClear(GL_COLOR_BUFFER_BIT);
- mesh = randomMesh2D(1, drawingSize + 1, nPoints,
- 1, drawingSize + 1, nPoints);
- for (i = nPoints - 1; i > 0; --i) {
+ mesh = random_mesh_2d(1, drawing_size + 1, npoints,
+ 1, drawing_size + 1, npoints);
+ for (i = npoints - 1; i > 0; --i) {
glBegin(GL_TRIANGLE_STRIP);
- for (j = 0; j < nPoints; ++j) {
+ for (j = 0; j < npoints; ++j) {
glColor4f(1.0, 0.0, 0.0, 0.5);
- glVertex2fv(mesh + 2 * (nPoints * i + j)); /* mesh[i, j] */
+ glVertex2fv(mesh + 2 * (npoints * i + j)); /* mesh[i, j] */
glColor4f(0.0, 1.0, 0.0, 0.5);
- glVertex2fv(mesh + 2 * (nPoints * (i - 1) + j)); /* mesh[i - 1, j] */
+ glVertex2fv(mesh + 2 * (npoints * (i - 1) + j)); /* mesh[i - 1, j] */
}
glEnd();
}
free(mesh);
/* Read the image */
- glReadPixels(0, 0, windowSize, windowSize, GL_RGB, GL_UNSIGNED_BYTE, img);
+ glReadPixels(0, 0, window_size, window_size, GL_RGB, GL_UNSIGNED_BYTE, img);
/* Show the image */
if (!piglit_automatic) {
@@ -669,21 +669,21 @@ orthoPosRandTris() {
}
/* Check the results */
- return verifyOrthPos(img, imgBytes/windowSize,
+ return verify_orth_pos(img, img_bytes/window_size,
"Immediate-mode random triangles");
-} /* orthoPosRandTris */
+} /* ortho_pos_rand_tris */
enum piglit_result
piglit_display(void)
{
bool pass = true;
- pass &= orthoPosPoints();
- pass &= orthoPosVLines();
- pass &= orthoPosHLines();
- pass &= orthoPosTinyQuads();
- pass &= orthoPosRandRects();
- pass &= orthoPosRandTris();
+ pass &= ortho_pos_points();
+ pass &= ortho_pos_vlines();
+ pass &= ortho_pos_hlines();
+ pass &= ortho_pos_tiny_quads();
+ pass &= ortho_pos_rand_rects();
+ pass &= ortho_pos_rand_tris();
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}