[Piglit] [PATCH 4/6] Add a "frustum" command to shader_runner.

Paul Berry stereotype441 at gmail.com
Thu Oct 20 14:12:26 PDT 2011


---
 tests/shaders/shader_runner.c |    4 ++++
 tests/util/piglit-util-gl.c   |   19 +++++++++++++++++++
 tests/util/piglit-util.h      |    2 ++
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 1a77cc0..8a585a6 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1009,6 +1009,10 @@ piglit_display(void)
 			do_enable_disable(line + 7, false);
 		} else if (string_match("enable", line)) {
 			do_enable_disable(line + 6, true);
+		} else if (string_match("frustum", line)) {
+			get_floats(line + 7, c, 6);
+			piglit_frustum_projection(false, c[0], c[1], c[2],
+						  c[3], c[4], c[5]);
 		} else if (sscanf(line, "ortho %f %f %f %f",
 				  c + 0, c + 1, c + 2, c + 3) == 4) {
 			piglit_gen_ortho_projection(c[0], c[1], c[2], c[3],
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 1dead63..b743a08 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -763,6 +763,25 @@ piglit_ortho_projection(int w, int h, GLboolean push)
 	piglit_gen_ortho_projection(0, w, 0, h, -1, 1, push);
 }
 
+/**
+ * Convenience function to configure frustum projection.
+ */
+void
+piglit_frustum_projection(GLboolean push, double l, double r, double b,
+			  double t, double n, double f)
+{
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	if (push)
+		glPushMatrix();
+	glFrustum(l, r, b, t, n, f);
+
+	glMatrixMode(GL_MODELVIEW);
+	if (push)
+		glPushMatrix();
+	glLoadIdentity();
+}
+
 
 
 /**
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 67a960d..8238aca 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -182,6 +182,8 @@ void piglit_gen_ortho_projection(double left, double right, double bottom,
 				 double top, double near_val, double far_val,
 				 GLboolean push);
 void piglit_ortho_projection(int w, int h, GLboolean push);
+void piglit_frustum_projection(GLboolean push, double l, double r, double b,
+			       double t, double n, double f);
 
 GLuint piglit_checkerboard_texture(GLuint tex, unsigned level,
     unsigned width, unsigned height,
-- 
1.7.6.4



More information about the Piglit mailing list