[Piglit] [PATCH 4/4] Unify projection utility functions across GL and GLES
Josh Triplett
josh at joshtriplett.org
Wed Jul 2 17:27:55 PDT 2014
piglit_gen_ortho_projection and piglit_ortho_projection already had a
similar implementation for GL and GLES1; common it up and remove the
ifdefs.
Move piglit_frustum_projection out of GL-only code as well, and add
support for GLES1 using glFrustumf.
Signed-off-by: Josh Triplett <josh at joshtriplett.org>
---
tests/util/piglit-util-gl-common.c | 58 ++++++++++++++++++++++++++++++++++++++
tests/util/piglit-util-gl.c | 54 -----------------------------------
tests/util/piglit-util-gles.c | 37 ------------------------
3 files changed, 58 insertions(+), 91 deletions(-)
diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c
index a0be726..32bddf8 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -520,6 +520,64 @@ piglit_compressed_pixel_offset(GLenum format, unsigned width,
return offset;
}
+/**
+ * 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();
+
+ if (piglit_is_gles())
+ glOrthof(left, right, bottom, top, near_val, far_val);
+ else
+ glOrtho(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);
+}
+
+/**
+ * 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();
+
+ if (piglit_is_gles())
+ glFrustumf(l, r, b, t, n, f);
+ else
+ glFrustum(l, r, b, t, n, f);
+
+ glMatrixMode(GL_MODELVIEW);
+ if (push)
+ glPushMatrix();
+ glLoadIdentity();
+}
#ifndef PIGLIT_USE_OPENGL_ES1
/**
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 773e09f..91f3dc0 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -894,60 +894,6 @@ piglit_draw_triangle_z(float z, float x1, float y1, float x2, float y2,
}
/**
- * 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();
- glOrtho(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);
-}
-
-/**
- * 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();
-}
-
-
-
-/**
* Generate a checkerboard texture
*
* \param tex Name of the texture to be used. If \c tex is
diff --git a/tests/util/piglit-util-gles.c b/tests/util/piglit-util-gles.c
index 6789aeb..26c3fa3 100644
--- a/tests/util/piglit-util-gles.c
+++ b/tests/util/piglit-util-gles.c
@@ -386,40 +386,3 @@ piglit_checkerboard_texture(GLuint tex, unsigned level,
return tex;
}
-
-#if defined(PIGLIT_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 /* PIGLIT_USE_OPENGL_ES1 */
--
2.0.1
More information about the Piglit
mailing list