From: Ian Romanick <[email protected]>

This will be used in future commits.

Signed-off-by: Ian Romanick <[email protected]>
Cc: Matt Turner <[email protected]>
Cc: Paul Berry <[email protected]>
---
 tests/util/piglit-util-gl-common.c | 86 ++++++++++++++++++++++++--------------
 tests/util/piglit-util-gl-common.h |  3 +-
 2 files changed, 56 insertions(+), 33 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index b5e87bf..c097d8f 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -599,46 +599,68 @@ required_gl_version_from_glsl_version(unsigned 
glsl_version)
  *   float tex[4][2];
  *
  * if not NULL.
+ *
+ * \param fixed_function_attribute  Should fixed-function attributes (e.g.,
+ *                                  \c glVertexPointer) be used?  In an OpenGL
+ *                                  core profile this must be \c true.  In
+ *                                  OpenGL ES the value is ignored.
  */
 void
-piglit_draw_rect_from_arrays(const void *verts, const void *tex)
+piglit_draw_rect_from_arrays(const void *verts, const void *tex,
+                             bool fixed_function_attributes)
 {
+#if defined(PIGLIT_USE_OPENGL_ES1)
+#define USE_FF(x) true
+#elif defined(PIGLIT_USE_OPENGL_ES2) ||  defined(PIGLIT_USE_OPENGL_ES3)
+#define USE_FF(x) false
+#elif defined(PIGLIT_USE_OPENGL)
+#define USE_FF(x) x
+#else
+#error "don't know how to draw arrays"
+#endif
+
 #if defined(PIGLIT_USE_OPENGL_ES1) || defined(PIGLIT_USE_OPENGL)
-       if (verts) {
-               glVertexPointer(4, GL_FLOAT, 0, verts);
-               glEnableClientState(GL_VERTEX_ARRAY);
-       }
+       if (USE_FF(fixed_function_attributes)) {
+               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);
-       }
+               if (tex) {
+                       glTexCoordPointer(2, GL_FLOAT, 0, tex);
+                       glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+               }
 
-       glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+               glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
-       if (verts)
-               glDisableClientState(GL_VERTEX_ARRAY);
-       if (tex)
-               glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-#elif defined(PIGLIT_USE_OPENGL_ES2) ||defined(PIGLIT_USE_OPENGL_ES3)
-       if (verts) {
-               glVertexAttribPointer(PIGLIT_ATTRIB_POS, 4, GL_FLOAT, GL_FALSE, 
0, verts);
-               glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);
+               if (verts)
+                       glDisableClientState(GL_VERTEX_ARRAY);
+               if (tex)
+                       glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        }
+#endif
+#if defined(PIGLIT_USE_OPENGL_ES2) || defined(PIGLIT_USE_OPENGL_ES3) \
+       || defined(PIGLIT_USE_OPENGL)
+       if (!USE_FF(fixed_function_attributes)) {
+               if (verts) {
+                       glVertexAttribPointer(PIGLIT_ATTRIB_POS, 4, GL_FLOAT,
+                                             GL_FALSE, 0, verts);
+                       glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);
+               }
 
-       if (tex) {
-               glVertexAttribPointer(PIGLIT_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 
0, tex);
-               glEnableVertexAttribArray(PIGLIT_ATTRIB_TEX);
-       }
+               if (tex) {
+                       glVertexAttribPointer(PIGLIT_ATTRIB_TEX, 2, GL_FLOAT,
+                                             GL_FALSE, 0, tex);
+                       glEnableVertexAttribArray(PIGLIT_ATTRIB_TEX);
+               }
 
-       glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+               glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
-       if (verts)
-               glDisableVertexAttribArray(PIGLIT_ATTRIB_POS);
-       if (tex)
-               glDisableVertexAttribArray(PIGLIT_ATTRIB_TEX);
-#else
-#      error "don't know how to draw arrays"
+               if (verts)
+                       glDisableVertexAttribArray(PIGLIT_ATTRIB_POS);
+               if (tex)
+                       glDisableVertexAttribArray(PIGLIT_ATTRIB_TEX);
+       }
 #endif
 }
 
@@ -667,7 +689,7 @@ piglit_draw_rect(float x, float y, float w, float h)
        verts[3][2] = 0.0;
        verts[3][3] = 1.0;
 
-       piglit_draw_rect_from_arrays(verts, NULL);
+       piglit_draw_rect_from_arrays(verts, NULL, true);
 }
 
 /**
@@ -695,7 +717,7 @@ piglit_draw_rect_z(float z, float x, float y, float w, 
float h)
        verts[3][2] = z;
        verts[3][3] = 1.0;
 
-       piglit_draw_rect_from_arrays(verts, NULL);
+       piglit_draw_rect_from_arrays(verts, NULL, true);
 }
 
 /**
@@ -734,5 +756,5 @@ piglit_draw_rect_tex(float x, float y, float w, float h,
        tex[3][0] = tx + tw;
        tex[3][1] = ty + th;
 
-       piglit_draw_rect_from_arrays(verts, tex);
+       piglit_draw_rect_from_arrays(verts, tex, true);
 }
diff --git a/tests/util/piglit-util-gl-common.h 
b/tests/util/piglit-util-gl-common.h
index ef87514..44e46ac 100644
--- a/tests/util/piglit-util-gl-common.h
+++ b/tests/util/piglit-util-gl-common.h
@@ -162,7 +162,8 @@ GLvoid piglit_draw_rect_z(float z, float x, float y, float 
w, float h);
 GLvoid piglit_draw_rect_tex(float x, float y, float w, float h,
                             float tx, float ty, float tw, float th);
 GLvoid piglit_draw_rect_back(float x, float y, float w, float h);
-void piglit_draw_rect_from_arrays(const void *verts, const void *tex);
+void piglit_draw_rect_from_arrays(const void *verts, const void *tex,
+                                  bool fixed_function_attributes);
 
 unsigned short piglit_half_from_float(float val);
 
-- 
1.8.1.4

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to