[Piglit] [PATCH 2/4] shader_runner: Added a variant of the "ortho" command that takes parameters
Paul Berry
stereotype441 at gmail.com
Fri Jun 24 14:41:54 PDT 2011
This allows shader_runner tests to specify explicit left, right,
bottom, and top values rather than the default of (0, window width, 0,
window height).
---
tests/shaders/shader_runner.c | 4 ++++
tests/util/piglit-util-gl.c | 24 ++++++++++++++++++------
tests/util/piglit-util.h | 3 +++
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index a008a6c..7de0603 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -886,6 +886,10 @@ piglit_display(void)
do_enable_disable(line + 7, false);
} else if (string_match("enable", line)) {
do_enable_disable(line + 6, true);
+ } 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],
+ -1, 1, GL_FALSE);
} else if (string_match("ortho", line)) {
piglit_ortho_projection(piglit_width, piglit_height,
GL_FALSE);
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 7a2a45b..b6ddf25 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -731,19 +731,18 @@ piglit_draw_rect_tex(float x, float y, float w, float h,
/**
- * Convenience function to configure projection matrix for window coordinates
+ * Convenience function to configure an abitrary orthogonal projection matrix
*/
void
-piglit_ortho_projection(int w, int h, GLboolean push)
+piglit_gen_ortho_projection(double left, double right, double bottom,
+ double top, double near_val, double far_val,
+ GLboolean push)
{
- /* Set up projection matrix so we can just draw using window
- * coordinates.
- */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (push)
glPushMatrix();
- glOrtho(0, w, 0, h, -1, 1);
+ glOrtho(left, right, bottom, top, near_val, far_val);
glMatrixMode(GL_MODELVIEW);
if (push)
@@ -752,6 +751,19 @@ piglit_ortho_projection(int w, int h, GLboolean push)
}
+/**
+ * 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);
+}
+
+
/**
* Generate a checkerboard texture
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 8073b04..f49349b 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -147,6 +147,9 @@ void piglit_escape_exit_key(unsigned char key, int x, int y);
char *piglit_load_text_file(const char *file_name, unsigned *size);
+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);
GLuint piglit_checkerboard_texture(GLuint tex, unsigned level,
--
1.7.5.4
More information about the Piglit
mailing list