summaryrefslogtreecommitdiffstats
path: root/progs/tests
diff options
context:
space:
mode:
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/stencilwrap.c57
-rw-r--r--progs/tests/texwrap.c6
2 files changed, 51 insertions, 12 deletions
diff --git a/progs/tests/stencilwrap.c b/progs/tests/stencilwrap.c
index e65258b583a..da875412ada 100644
--- a/progs/tests/stencilwrap.c
+++ b/progs/tests/stencilwrap.c
@@ -16,6 +16,7 @@ static void RunTest(void)
const GLenum prim = GL_LINES;
GLubyte val;
int bits, max, i;
+ GLboolean failed;
glGetIntegerv(GL_STENCIL_BITS, &bits);
max = (1 << bits) - 1;
@@ -27,20 +28,29 @@ static void RunTest(void)
/* test GL_INCR (saturation) */
glClear(GL_STENCIL_BUFFER_BIT);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
+ failed = GL_FALSE;
printf("Testing GL_INCR...\n");
for (i = 1; i < max+10; i++) {
int expected = (i > max) ? max : i;
glBegin(prim);
glVertex2f(0.5, 0.5); glVertex2f(9.5, 0.5);
glEnd();
+
glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
- assert(val == expected);
+ if (val != expected) {
+ printf( "Failed GL_INCR test on iteration #%u "
+ "(got %u, expected %u)\n", i, val, expected );
+ failed = GL_TRUE;
+ }
}
- printf("OK!\n");
+
+ if ( !failed ) printf("OK!\n");
+
/* test GL_INCR_WRAP_EXT (wrap around) */
glClear(GL_STENCIL_BUFFER_BIT);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
+ failed = GL_FALSE;
printf("Testing GL_INCR_WRAP_EXT...\n");
for (i = 1; i < max+10; i++) {
int expected = i % (max + 1);
@@ -48,15 +58,20 @@ static void RunTest(void)
glVertex2f(0.5, 0.5); glVertex2f(9.5, 0.5);
glEnd();
glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
- assert(val == expected);
+ if (val != expected) {
+ printf( "Failed GL_INCR_WRAP test on iteration #%u "
+ "(got %u, expected %u)\n", i, val, expected );
+ failed = GL_TRUE;
+ }
}
- printf("OK!\n");
+ if ( !failed ) printf("OK!\n");
glClearStencil(max);
/* test GL_INCR (saturation) */
glClear(GL_STENCIL_BUFFER_BIT);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
+ failed = GL_FALSE;
printf("Testing GL_DECR...\n");
for (i = max-1; i > -10; i--) {
int expected = (i < 0) ? 0 : i;
@@ -64,13 +79,18 @@ static void RunTest(void)
glVertex2f(0.5, 0.5); glVertex2f(9.5, 0.5);
glEnd();
glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
- assert(val == expected);
+ if (val != expected) {
+ printf( "Failed GL_DECR test on iteration #%u "
+ "(got %u, expected %u)\n", max - i, val, expected );
+ failed = GL_TRUE;
+ }
}
- printf("OK!\n");
+ if ( !failed ) printf("OK!\n");
/* test GL_INCR_WRAP_EXT (wrap-around) */
glClear(GL_STENCIL_BUFFER_BIT);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
+ failed = GL_FALSE;
printf("Testing GL_DECR_WRAP_EXT...\n");
for (i = max-1; i > -10; i--) {
int expected = (i < 0) ? max + i + 1: i;
@@ -78,9 +98,13 @@ static void RunTest(void)
glVertex2f(0.5, 0.5); glVertex2f(9.5, 0.5);
glEnd();
glReadPixels(0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &val);
- assert(val == expected);
+ if (val != expected) {
+ printf( "Failed GL_DECR_WRAP test on iteration #%u "
+ "(got %u, expected %u)\n", max - i, val, expected );
+ failed = GL_TRUE;
+ }
}
- printf("OK!\n");
+ if ( !failed ) printf("OK!\n");
glDisable(GL_STENCIL_TEST);
}
@@ -122,9 +146,24 @@ static void Key( unsigned char key, int x, int y )
static void Init( void )
{
+ const char * ver_str;
+ float version;
+
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
- if (!glutExtensionSupported("GL_EXT_stencil_wrap")) {
+
+
+ /* Check for both the extension string and GL version 1.4 on the
+ * outside chance that some silly vendor exports version 1.4 but doesn't
+ * export the extension string. The stencil-wrap modes are a required
+ * part of GL 1.4.
+ */
+
+ ver_str = glGetString( GL_VERSION );
+ version = (ver_str == NULL) ? 1.0 : strtof( ver_str, NULL );
+
+ if ( !glutExtensionSupported("GL_EXT_stencil_wrap")
+ && (version < 1.4) ) {
printf("Sorry, GL_EXT_stencil_wrap not supported.\n");
exit(1);
}
diff --git a/progs/tests/texwrap.c b/progs/tests/texwrap.c
index 7751afd46b1..2602f3210de 100644
--- a/progs/tests/texwrap.c
+++ b/progs/tests/texwrap.c
@@ -1,4 +1,4 @@
-/* $Id: texwrap.c,v 1.5 2003/02/04 02:35:00 brianp Exp $ */
+/* $Id: texwrap.c,v 1.6 2003/05/30 15:30:17 brianp Exp $ */
/*
* Test texture wrap modes.
@@ -35,7 +35,7 @@
#define SIZE 8
static GLubyte BorderImage[SIZE+2][SIZE+2][4];
static GLubyte NoBorderImage[SIZE][SIZE][4];
-static GLuint Border = 1;
+static GLuint Border = 0;
#define WRAP_MODE(m) { m , # m, GL_TRUE, 1.0, { NULL, NULL } }
@@ -142,7 +142,7 @@ static void Display( void )
/* loop over border modes */
for (j = 0; j < modes[j].mode != 0; j++) {
const GLfloat x0 = 0, y0 = 0, x1 = 140, y1 = 140;
- const GLfloat b = 0.2;
+ const GLfloat b = 1.2;
const GLfloat s0 = -b, t0 = -b, s1 = 1.0+b, t1 = 1.0+b;
if ( modes[j].supported != GL_TRUE )