[Piglit] [PATCHv2 08/10] util: fix piglit-util for GLES1

Chia-I Wu olvaffe at gmail.com
Sun Sep 4 19:44:59 PDT 2011


Assorted minor changes to make sure piglit-util compile and work against
GLES1.
---
 tests/util/piglit-util-gles.c |   58 +++++++++++++++++++++++++++++++++++++++++
 tests/util/piglit-util.c      |    6 +++-
 2 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/tests/util/piglit-util-gles.c b/tests/util/piglit-util-gles.c
index 3f7addd..dd7a21a 100644
--- a/tests/util/piglit-util-gles.c
+++ b/tests/util/piglit-util-gles.c
@@ -188,6 +188,24 @@ piglit_escape_exit_key(unsigned char key, int x, int y)
 static void
 draw_arrays(const GLvoid *verts, const GLvoid *tex)
 {
+#if defined(USE_OPENGL_ES1)
+	if (verts) {
+		glVertexPointer(4, GL_FLOAT, 0, verts);
+		glEnableClientState(GL_VERTEX_ARRAY);
+	}
+
+	if (tex) {
+		glTexCoordPointer(2, GL_FLOAT, 0, tex);
+		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+	}
+
+	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+	if (verts)
+		glDisableClientState(GL_VERTEX_ARRAY);
+	if (tex)
+		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+#elif defined(USE_OPENGL_ES2)
 	if (verts) {
 		glVertexAttribPointer(PIGLIT_ATTRIB_POS, 4, GL_FLOAT, GL_FALSE, 0, verts);
 		glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);
@@ -204,6 +222,9 @@ draw_arrays(const GLvoid *verts, const GLvoid *tex)
 		glDisableVertexAttribArray(PIGLIT_ATTRIB_POS);
 	if (tex)
 		glDisableVertexAttribArray(PIGLIT_ATTRIB_TEX);
+#else
+#	error "don't know how to draw arrays"
+#endif
 }
 
 /**
@@ -499,3 +520,40 @@ piglit_checkerboard_texture(GLuint tex, unsigned level,
 
 	return tex;
 }
+
+#if defined(USE_OPENGL_ES1)
+
+/**
+ * Convenience function to configure an abitrary orthogonal projection matrix
+ */
+void
+piglit_gen_ortho_projection(double left, double right, double bottom,
+			    double top, double near_val, double far_val,
+			    GLboolean push)
+{
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	if (push)
+		glPushMatrix();
+	glOrthof(left, right, bottom, top, near_val, far_val);
+
+	glMatrixMode(GL_MODELVIEW);
+	if (push)
+		glPushMatrix();
+	glLoadIdentity();
+}
+
+
+/**
+ * Convenience function to configure projection matrix for window coordinates
+ */
+void
+piglit_ortho_projection(int w, int h, GLboolean push)
+{
+	/* Set up projection matrix so we can just draw using window
+	 * coordinates.
+	 */
+	piglit_gen_ortho_projection(0, w, 0, h, -1, 1, push);
+}
+
+#endif /* USE_OPENGL_ES1 */
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 85cab9e..f59814f 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -48,6 +48,8 @@ void piglit_glutInit(int argc, char **argv)
 
 #if defined USE_EGLUT && defined USE_OPENGL
 	glutInitAPIMask(GLUT_OPENGL_BIT);
+#elif defined USE_EGLUT && defined USE_OPENGL_ES1
+	glutInitAPIMask(GLUT_OPENGL_ES1_BIT);
 #elif defined USE_EGLUT && defined USE_OPENGL_ES2
 	glutInitAPIMask(GLUT_OPENGL_ES2_BIT);
 #elif defined USE_EGLUT
@@ -129,7 +131,6 @@ const char* piglit_get_gl_error_name(GLenum error)
 #define CASE(x) case x: return #x; 
     switch (error) {
     CASE(GL_INVALID_ENUM)
-    CASE(GL_INVALID_FRAMEBUFFER_OPERATION)
     CASE(GL_INVALID_OPERATION)
     CASE(GL_INVALID_VALUE)
     CASE(GL_NO_ERROR)
@@ -141,6 +142,9 @@ const char* piglit_get_gl_error_name(GLenum error)
 #if defined(GL_STACK_UNDERFLOW)
     CASE(GL_STACK_UNDERFLOW)
 #endif
+#if defined(GL_INVALID_FRAMEBUFFER_OPERATION)
+    CASE(GL_INVALID_FRAMEBUFFER_OPERATION)
+#endif
     default:
         return "(unrecognized error)";
     }
-- 
1.7.5.4



More information about the Piglit mailing list