---
 tests/all.tests           |    1 +
 tests/bugs/CMakeLists.txt |    1 +
 tests/bugs/fdo22540.c     |  142 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 144 insertions(+), 0 deletions(-)
 create mode 100644 tests/bugs/fdo22540.c

diff --git a/tests/all.tests b/tests/all.tests
index 58e41f8..75fe61e 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -106,6 +106,7 @@ bugs['fdo20701'] = PlainExecTest([testBinDir + 'fdo20701', 
'-auto'])
 bugs['r300-readcache'] = PlainExecTest([testBinDir + 'r300-readcache'])
 bugs['tex1d-2dborder'] = PlainExecTest([testBinDir + 'tex1d-2dborder', 
'-auto'])
 bugs['point-sprite'] = PlainExecText([testBinDir + 'point-sprite', '-auto'])
+bugs['fdo22540'] = PlainExecText([testBinDir + 'fdo22540', '-auto'])
 
 texturing = Group()
 texturing['copytexsubimage'] = PlainExecTest([testBinDir + 'copytexsubimage', 
'-auto'])
diff --git a/tests/bugs/CMakeLists.txt b/tests/bugs/CMakeLists.txt
index 99f67a6..3efa91b 100644
--- a/tests/bugs/CMakeLists.txt
+++ b/tests/bugs/CMakeLists.txt
@@ -30,4 +30,5 @@ add_executable (r300-readcache r300-readcache.c)
 add_executable (tex1d-2dborder tex1d-2dborder.c)
 add_executable (fdo20701 fdo20701.c)
 add_executable (point-sprite point-sprite.c)
+add_executable (fdo22540 fdo22540.c)
 
diff --git a/tests/bugs/fdo22540.c b/tests/bugs/fdo22540.c
new file mode 100644
index 0000000..3d10fd4
--- /dev/null
+++ b/tests/bugs/fdo22540.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright © 2009 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.
+ */
+
+// author: Ben Holmes
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <GL/glew.h>
+#if defined(__APPLE__)
+#include <GLUT/glut.h>
+#else
+#include <GL/glut.h>
+#endif
+
+#include "piglit-util.h"
+
+static GLboolean Automatic = GL_FALSE;
+static GLuint vBuffer;
+
+extern void *glutGetProcAddress(const GLubyte *);
+
+static void
+Init()
+{
+
+        glewInit();
+        glMatrixMode(GL_PROJECTION);
+        glPushMatrix();
+        glLoadIdentity();
+        glOrtho(0, 400, 0, 300, -1, 1);
+
+        glMatrixMode(GL_MODELVIEW);
+        glPushMatrix();
+        glLoadIdentity();
+}
+
+static void
+vboInit()
+{
+       GLfloat vArray[12] = {225, 125, 0,
+                            225, 175, 0,
+                            175, 125, 0,
+                            175, 175, 0};
+       glGenBuffersARB(1, &vBuffer);
+       glBindBufferARB(GL_ARRAY_BUFFER_ARB, vBuffer);
+       glBufferDataARB(GL_ARRAY_BUFFER_ARB, 12*sizeof(GLfloat), 
+                       vArray, GL_STATIC_DRAW_ARB);
+
+}
+
+static GLboolean
+vboMap()
+{
+        float *ptr = (float*)glMapBufferARB(GL_ARRAY_BUFFER_ARB, 
+                                               GL_READ_WRITE_ARB);
+       glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
+        if (glGetError() == 0)
+                return GL_TRUE;
+        else
+                return GL_FALSE;
+}
+
+static void
+display()
+{
+
+       glBindBufferARB(GL_ARRAY_BUFFER_ARB, vBuffer);
+       glEnableClientState(GL_VERTEX_ARRAY);
+       glVertexPointer(3, GL_FLOAT, 0 ,0);
+
+       glColor3f(0.5, 0.5, 0.5);
+       glClear(GL_COLOR_BUFFER_BIT);
+       glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+       GLfloat gray[3] = {0.5, 0.5, 0.5};
+
+       GLboolean pass = vboMap();
+       pass = pass && piglit_probe_pixel_rgb(200, 150, gray);
+
+       glFinish();
+       glutSwapBuffers();
+
+        if (Automatic)
+                piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
+
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+        (void) x;
+        (void) y;
+        switch (key) {
+        case 27:
+                exit(0);
+                break;
+        }
+        glutPostRedisplay();
+}
+
+
+int main(int argc, char  **argv)
+{
+       glutInit(&argc, argv);
+       if(argc==2 && !strncmp(argv[1],"-auto", 5))
+               Automatic = GL_TRUE;
+       
+       glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
+        glutInitWindowSize(400, 300);
+        glutCreateWindow("VBO map");
+        glutDisplayFunc(display);
+       glutKeyboardFunc(Key);
+       
+       Init();
+       vboInit();
+
+       glutMainLoop();
+
+       glDeleteBuffersARB(1, &vBuffer);
+       return 0;
+}
-- 
1.6.3.3


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to