[Piglit] [PATCH 3/4] copytemimage: Use glDrawArrays instead of piglit_draw_rect.
Fabian Bieler
fabianbieler at fastmail.fm
Wed Jun 19 06:13:52 PDT 2013
Don't mix piglit_draw_rect and additional attribute arrays.
---
tests/texturing/copyteximage.c | 45 ++++++++++++++++++++++++++----------------
1 file changed, 28 insertions(+), 17 deletions(-)
diff --git a/tests/texturing/copyteximage.c b/tests/texturing/copyteximage.c
index 432ebbc..8a5b534 100644
--- a/tests/texturing/copyteximage.c
+++ b/tests/texturing/copyteximage.c
@@ -430,6 +430,26 @@ static GLboolean probe_rect(int x, int y, int w, int h,
return piglit_probe_rect_rgba(x, y, w, h, expected_scaled);
}
+/**
+ * Draw a rectangle with texture coordiantes and width and height IMAGE_SIZE.
+ *
+ * texCoordDim -- the number of components of the texture coordinates
+ * texCoords -- an array of floats with texture coordinate data
+ * x, y -- the lower left corner of the rectangle
+ */
+static void
+draw_rect_tex(GLint texCoordDim, const GLvoid *texCoords, GLint x, GLint y)
+{
+ const float s = IMAGE_SIZE;
+ float verts[4][4] = { {x, y, 0, 1},
+ {x+s, y, 0, 1},
+ {x+s, y+s, 0, 1},
+ {x, y+s, 0, 1} };
+
+ glTexCoordPointer(texCoordDim, GL_FLOAT, 0, texCoords);
+ glVertexPointer(4, GL_FLOAT, 0, verts);
+ glDrawArrays(GL_QUADS, 0, 4);
+}
/**
* Test a specific texture target and format combination.
@@ -473,8 +493,7 @@ test_target_and_format(GLint x, GLint y, GLenum target, GLenum format,
&& pass;
glEnable(target);
- glTexCoordPointer(2, GL_FLOAT, 0, texCoords_2d);
- piglit_draw_rect(x, y, IMAGE_SIZE, IMAGE_SIZE);
+ draw_rect_tex(2, texCoords_2d, x, y);
pass = piglit_probe_rect_rgba(x, y, IMAGE_SIZE,
IMAGE_SIZE,
expected)
@@ -488,9 +507,7 @@ test_target_and_format(GLint x, GLint y, GLenum target, GLenum format,
pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
glEnable(target);
- glTexCoordPointer(2, GL_FLOAT, 0, texCoords_2d);
-
- piglit_draw_rect(x, y, IMAGE_SIZE, IMAGE_SIZE);
+ draw_rect_tex(2, texCoords_2d, x, y);
pass = piglit_probe_rect_rgba(x, y, IMAGE_SIZE,
IMAGE_SIZE,
expected)
@@ -512,8 +529,7 @@ test_target_and_format(GLint x, GLint y, GLenum target, GLenum format,
glEnable(target);
for (k = 0; k < 4; k++) {
- glTexCoordPointer(3, GL_FLOAT, 0, texCoords_3d[k]);
- piglit_draw_rect(x, y, IMAGE_SIZE, IMAGE_SIZE);
+ draw_rect_tex(3, texCoords_3d[k], x, y);
pass = probe_rect(x, y, IMAGE_SIZE, IMAGE_SIZE,
expected, 1.0 - k*0.2) && pass;
}
@@ -532,9 +548,7 @@ test_target_and_format(GLint x, GLint y, GLenum target, GLenum format,
glEnable(target);
for (k = 0; k < 6; k++) {
- glTexCoordPointer(3, GL_FLOAT, 0,
- cube_face_texcoords[k]);
- piglit_draw_rect(x, y, IMAGE_SIZE, IMAGE_SIZE);
+ draw_rect_tex(3, cube_face_texcoords[k], x, y);
pass = probe_rect(x, y, IMAGE_SIZE, IMAGE_SIZE,
expected, 1.0 - k*0.15) && pass;
}
@@ -555,8 +569,7 @@ test_target_and_format(GLint x, GLint y, GLenum target, GLenum format,
glEnable(target);
for (k = 0; k < 16; k++) {
- glTexCoordPointer(2, GL_FLOAT, 0, texCoords_1d_array[k]);
- piglit_draw_rect(x, y, IMAGE_SIZE, IMAGE_SIZE);
+ draw_rect_tex(2, texCoords_1d_array[k], x, y);
pass = probe_rect(x, y, IMAGE_SIZE, IMAGE_SIZE,
expected, 1.0 - 0.2*(k/4)) && pass;
}
@@ -577,8 +590,7 @@ test_target_and_format(GLint x, GLint y, GLenum target, GLenum format,
glEnable(target);
for (k = 0; k < 4; k++) {
- glTexCoordPointer(3, GL_FLOAT, 0, texCoords_2d_array[k]);
- piglit_draw_rect(x, y, IMAGE_SIZE, IMAGE_SIZE);
+ draw_rect_tex(3, texCoords_2d_array[k], x, y);
pass = probe_rect(x, y, IMAGE_SIZE, IMAGE_SIZE,
expected, 1.0 - k*0.2) && pass;
}
@@ -591,9 +603,7 @@ test_target_and_format(GLint x, GLint y, GLenum target, GLenum format,
pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
glEnable(target);
- glTexCoordPointer(2, GL_FLOAT, 0, texCoords_rect);
-
- piglit_draw_rect(x, y, IMAGE_SIZE, IMAGE_SIZE);
+ draw_rect_tex(2, texCoords_rect, x, y);
pass = piglit_probe_rect_rgba(x, y, IMAGE_SIZE,
IMAGE_SIZE,
expected)
@@ -632,6 +642,7 @@ piglit_display(void)
glClear(GL_COLOR_BUFFER_BIT);
+ glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
/* Do glCopyPixels and draw a textured rectangle for each format
--
1.8.1.2
More information about the Piglit
mailing list