[Piglit] [PATCH] drawbuffer.c: Verify specifying which color buffers are to be drawn into with drawbuffer function.

Yi Sun yi.sun at intel.com
Mon Dec 26 16:43:49 PST 2011


From: Sun Yi <yi.sun at intel.com>

This test works by call the function glDrawBuffer twice for each color buffer.
All the calls should ensure no error.

Signed-off-by: Yi Sun <yi.sun at intel.com>
---
 tests/spec/gl-3.0/api/CMakeLists.gl.txt |    1 +
 tests/spec/gl-3.0/api/drawbuffer.c      |   79 +++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/gl-3.0/api/drawbuffer.c

diff --git a/tests/spec/gl-3.0/api/CMakeLists.gl.txt b/tests/spec/gl-3.0/api/CMakeLists.gl.txt
index 564d6bc..10c2961 100644
--- a/tests/spec/gl-3.0/api/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.0/api/CMakeLists.gl.txt
@@ -21,5 +21,6 @@ add_executable (clearbuffer-invalid-drawbuffer clearbuffer-invalid-drawbuffer.c)
 add_executable (clearbuffer-invalid-buffer clearbuffer-invalid-buffer.c)
 add_executable (clearbuffer-stencil clearbuffer-common.c clearbuffer-stencil.c)
 add_executable (getfragdatalocation getfragdatalocation.c)
+add_executable (drawbuffer drawbuffer.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/gl-3.0/api/drawbuffer.c b/tests/spec/gl-3.0/api/drawbuffer.c
new file mode 100644
index 0000000..4462089
--- /dev/null
+++ b/tests/spec/gl-3.0/api/drawbuffer.c
@@ -0,0 +1,79 @@
+/* Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * \file drawbuffer.c
+ * Verify specifying which color buffers are to be drawn into with drawbuffer function.
+ *
+ * This test works by call the function glDrawBuffer twice for each color buffer.
+ * All the calls should ensure no error.
+ *
+ * \author Yi Sun <yi.sun at intel.com>
+ */
+#include "piglit-util.h"
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+int bufferlist[] = {
+	GL_FRONT_AND_BACK,
+	GL_FRONT, GL_BACK, 
+	GL_LEFT, GL_RIGHT,
+	GL_FRONT_LEFT, GL_FRONT_RIGHT,
+	GL_BACK_LEFT, GL_BACK_RIGHT,
+	GL_NONE
+};
+
+enum piglit_result                         
+piglit_display(void)
+{
+    return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+	int i, repeat;
+	GLenum err;
+
+	for ( i=0; i < sizeof(bufferlist)/sizeof(bufferlist[0]); i++)
+	{
+		for ( repeat = 0; repeat < 2; repeat++ )
+		{
+			glDrawBuffer( bufferlist[i] );
+			glRectf(-1.0,-1.0,1.0,1.0);
+		}
+
+		err = glGetError();
+	
+		if (err != GL_NO_ERROR) {
+			fprintf(stderr,
+				"Generated a error while drawing buffer %d (%s, 0x%04x)\n",
+				bufferlist[i],
+				piglit_get_gl_error_name(err), err);
+
+			pass = false;
+		}
+
+	}
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.7.6.4



More information about the Piglit mailing list