-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ben Holmes wrote:
> ---
>  tests/all.tests           |    1 +
>  tests/bugs/CMakeLists.txt |    2 +
>  tests/bugs/point-sprite.c |  193 
> +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 196 insertions(+), 0 deletions(-)
>  create mode 100644 tests/bugs/point-sprite.c
> 
> diff --git a/tests/all.tests b/tests/all.tests
> index fcb9172..58e41f8 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -105,6 +105,7 @@ bugs['fdo14575'] = PlainExecTest([testBinDir + 
> 'fdo14575', '-auto'])
>  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'])
>  
>  texturing = Group()
>  texturing['copytexsubimage'] = PlainExecTest([testBinDir + 
> 'copytexsubimage', '-auto'])
> diff --git a/tests/bugs/CMakeLists.txt b/tests/bugs/CMakeLists.txt
> index b64ff47..99f67a6 100644
> --- a/tests/bugs/CMakeLists.txt
> +++ b/tests/bugs/CMakeLists.txt
> @@ -29,3 +29,5 @@ add_executable (fdo14575 fdo14575.c)
>  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)
> +
> diff --git a/tests/bugs/point-sprite.c b/tests/bugs/point-sprite.c
> new file mode 100644
> index 0000000..cf96ca3
> --- /dev/null
> +++ b/tests/bugs/point-sprite.c
> @@ -0,0 +1,193 @@
> +/*
> + * 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

Usually there should be some description of what the test is testing and
how it is doing it.  tests/bugs/fdo20701.c is a good example.  If
nothing else, this is the place to mention the bug that the test reproduces.

> +
> +
> +#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 float maxSize = 0.0f;
> +static GLuint tex;
> +
> +
> +extern void *glutGetProcAddress(const GLubyte *);

Since you use GLEW and there are no uses of glutGetProcAddress, this
prototype should go away.

> +
> +
> +static void
> +Init()
> +{
> +
> +     glewInit();

This is the place to test for required extensions.  It looks like this
test needs GL_ARB_point_sprite or OpenGL version 1.4.

> +     glMatrixMode(GL_PROJECTION);
> +        glPushMatrix();
> +        glLoadIdentity();
> +        glOrtho(0, 400, 0, 300, -1, 1);
> +     
> +        glMatrixMode(GL_MODELVIEW);
> +        glPushMatrix();
> +        glLoadIdentity();
> +
> +        glEnable(GL_TEXTURE_2D);
> +     glEnable(GL_POINT_SPRITE_ARB);
> +
> +        glGetFloatv(GL_POINT_SIZE_MAX, &maxSize);
> +        if (maxSize>100)
> +                maxSize = 100;
> +        glPointSize(maxSize);
> +
> +     glClearColor(0.2,0.2,0.2,1);
> +     glColor3f(1,1,1);
> +
> +}
> +
> +static void
> +display()
> +{
> +
> +     glClear(GL_COLOR_BUFFER_BIT);
> +     glBindTexture(GL_TEXTURE_2D, tex);
> +
> +     //opengl version must be at least 2.0 to support
> +        //modifying GL_POINT_SPRITE_COORD_ORIGIN

Should probably just use C-style /* */ comments.

> +     if (GLEW_VERSION_2_0)
> +             glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT);
> +
> +     glBegin(GL_POINTS);
> +             glVertex2f(175.0f,125.0f);
> +     glEnd();
> +
> +     GLfloat black[3] = {0.0, 0.0, 0.0};
> +     GLboolean pass = piglit_probe_pixel_rgb(200, 120, black);

I'll let someone else comment here to be sure.  I believe that we're not
counting on C99 (or C++) in piglit, so variable declarations cannot be
mixed with code.  Do we care?

> +
> +     glFinish();
> +     glutSwapBuffers();
> +     
> +

Rather than swap and clear between subtests, it is better to just
display both at once.  Otherwise a person won't be able to tell that the
first test failed in the non '-auto' case.

> +     glClear(GL_COLOR_BUFFER_BIT);
> +
> +     //opengl version must be at least 2.0 to support 
> +     //modifying GL_POINT_SPRITE_COORD_ORIGIN
> +     if (GLEW_VERSION_2_0) {
> +             glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT);
> +     
> +             glBegin(GL_POINTS);
> +                     glVertex2f(175.0f,125.0f);
> +             glEnd();
> +
> +             GLfloat white[3] = {1.0, 1.0, 1.0};
> +             pass = pass && piglit_probe_pixel_rgb(200, 120, white);
> +
> +             glFinish();
> +             glutSwapBuffers();
> +     }
> +
> +     if(Automatic)
> +             piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
> +
> +}
> +
> +
> +static void
> +loadTex()
> +{
> +     
> +     int height = 2;
> +     int width = 2;
> +     int i, j;
> +
> +     GLfloat texData[width][height][4];
> +     for (i = 0; i < width; i++) {
> +             for (j = 0; j < height; j++) {
> +                     if ((i + j) & 1) {
> +                             /* white */
> +                             texData[i][j][0] = 1;
> +                             texData[i][j][1] = 1;
> +                             texData[i][j][2] = 1;
> +                             texData[i][j][3] = 1;
> +                     }
> +                     else {
> +                             /* black */
> +                             texData[i][j][0] = 0;
> +                             texData[i][j][1] = 0;
> +                             texData[i][j][2] = 0;
> +                             texData[i][j][3] = 0;
> +                     }
> +             }
> +     }
> +
> +
> +     glGenTextures(1, &tex);
> +     glBindTexture(GL_TEXTURE_2D, tex);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
> +        glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
> +     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, 
> +                     GL_FLOAT, texData);
> +
> +}
> +
> +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("point_sprite");
> +     glutDisplayFunc(display);
> +     glutKeyboardFunc(Key);
> +
> +     Init();
> +
> +     loadTex();
> +
> +     glutMainLoop();
> +
> +     return 0;
> +}

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpWfNYACgkQX1gOwKyEAw8nmQCglpuaC/x0TJnlcn2qA2KpJZlV
OxYAoJ6JRbDxALClPAiMKueCGcHTvJj/
=IE+5
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to