diff options
author | Paul Berry <stereotype441@gmail.com> | 2012-12-28 11:51:21 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-01-09 11:57:30 -0800 |
commit | 8efe5c526b5ca575767c2807b6f0783f7691dbf6 (patch) | |
tree | dcb5525b9e94033db63d400c71e89799275d7cd2 | |
parent | 4acbb6147f0964d18ecad34bdf842995750cd8a1 (diff) |
util: Add functions that provide glOrtho-like functionality.
This patch adds functions piglit_gen_ortho_uniform() and
piglit_ortho_uniform(), which can be used to set up an orthographic
projection when the legacy function glOrtho() is not available.
The functions work exactly like piglit_gen_ortho_projection() and
piglit_ortho_projection(), except that instead of programming the
legacy projection matrix, they program an arbitrary uniform matrix.
Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r-- | tests/util/piglit-util-gl-common.c | 34 | ||||
-rw-r--r-- | tests/util/piglit-util-gl-common.h | 4 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c index b4318152..92a0a4d3 100644 --- a/tests/util/piglit-util-gl-common.c +++ b/tests/util/piglit-util-gl-common.c @@ -527,3 +527,37 @@ piglit_compressed_pixel_offset(GLenum format, unsigned width, return offset; } + + +#ifndef PIGLIT_USE_OPENGL_ES1 +/** + * Convenience function to configure a shader uniform variable as an + * arbitrary orthogonal projection matrix. + */ +void +piglit_gen_ortho_uniform(GLint location, double l, double r, double b, + double t, double n, double f) +{ + float values[4][4] = { + { 2/(r-l), 0, 0, -(r+l)/(r-l) }, + { 0, 2/(t-b), 0, -(t+b)/(t-b) }, + { 0, 0, -2/(f-n), -(f+n)/(f-n) }, + { 0, 0, 0, 1 } + }; + glUniformMatrix4fv(location, 1, GL_TRUE, values); +} + + +/** + * Convenience function to configure a shader uniform variable as a + * projection matrix for window coordinates. + */ +void +piglit_ortho_uniform(GLint location, int w, int h) +{ + /* Set up projection matrix so we can just draw using window + * coordinates. + */ + piglit_gen_ortho_uniform(location, 0, w, 0, h, -1, 1); +} +#endif diff --git a/tests/util/piglit-util-gl-common.h b/tests/util/piglit-util-gl-common.h index 2d6bb1a8..336953d2 100644 --- a/tests/util/piglit-util-gl-common.h +++ b/tests/util/piglit-util-gl-common.h @@ -159,6 +159,10 @@ void piglit_gen_ortho_projection(double left, double right, double bottom, 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); +void piglit_gen_ortho_uniform(GLint location, double left, double right, + double bottom, double top, double near_val, + double far_val); +void piglit_ortho_uniform(GLint location, int w, int h); GLuint piglit_checkerboard_texture(GLuint tex, unsigned level, unsigned width, unsigned height, |