summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2008-06-30 21:08:00 +0200
committerNicolai Haehnle <nhaehnle@gmail.com>2008-06-30 21:08:00 +0200
commit7a7fcc23e16c6f690e42db49bb9be44ec896edac (patch)
tree133078bb1fb8cb090d0f0b4ea289beacab327b3c
parent8900a6f0ec681045dc81715af2bd3778cd6e233d (diff)
Cleanup/Code sharing: Use piglit-util functions in a number of places
-rw-r--r--tests/shaders/fp-fragment-position.c48
-rw-r--r--tests/shaders/fp-generic.c28
-rw-r--r--tests/shaders/fp-incomplete-tex.c46
-rw-r--r--tests/shaders/fp-kil.c45
-rw-r--r--tests/shaders/fp-lit-mask.c99
-rw-r--r--tests/shaders/trinity-fp1.c72
-rw-r--r--tests/texturing/cubemap.c8
7 files changed, 29 insertions, 317 deletions
diff --git a/tests/shaders/fp-fragment-position.c b/tests/shaders/fp-fragment-position.c
index 9225e7d29..cbba0c596 100644
--- a/tests/shaders/fp-fragment-position.c
+++ b/tests/shaders/fp-fragment-position.c
@@ -347,52 +347,8 @@ static void Init(void)
piglit_require_fragment_program();
- /*
- * Fragment programs
- */
- pglGenProgramsARB(NUM_PROGRAMS, FragProg);
-
- for(i = 0; i < NUM_PROGRAMS; ++i) {
- GLint errorPos;
-
- check(FragProg[i]);
-
- pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[i]);
- pglProgramStringARB(
- GL_FRAGMENT_PROGRAM_ARB,
- GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(ProgramText[i]),
- (const GLubyte *)ProgramText[i]);
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
- if (glGetError() != GL_NO_ERROR || errorPos != -1) {
- int l = FindLine(ProgramText[i], errorPos);
- int a;
-
- fprintf(stderr, "%i: Fragment Program Error (pos=%d line=%d): %s\n",
- i, errorPos, l,
- (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
-
- for (a=-10; a<10; a++)
- {
- if (errorPos+a < 0)
- continue;
- if (errorPos+a >= strlen(ProgramText[i]))
- break;
- fprintf(stderr, "%c", ProgramText[i][errorPos+a]);
- }
- fprintf(stderr, "\n");
-
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- if (!pglIsProgramARB(FragProg[i])) {
- fprintf(stderr, "pglIsProgramARB failed\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- }
+ for(i = 0; i < NUM_PROGRAMS; ++i)
+ FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);
/*
* Texture unit 0: 200x200 RECTANGLE texture
diff --git a/tests/shaders/fp-generic.c b/tests/shaders/fp-generic.c
index 9736b9e98..4f1c7ce57 100644
--- a/tests/shaders/fp-generic.c
+++ b/tests/shaders/fp-generic.c
@@ -219,33 +219,7 @@ static void Reshape(int width, int height)
static void Init(void)
{
piglit_require_fragment_program();
-
- /*
- * Fragment programs
- */
- pglGenProgramsARB(1, &FragProg);
-
- GLint errorPos;
-
- pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg);
- pglProgramStringARB(
- GL_FRAGMENT_PROGRAM_ARB,
- GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(Testcase.programtext),
- (const GLubyte *)Testcase.programtext);
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
- if (glGetError() != GL_NO_ERROR || errorPos != -1) {
- int l = FindLine(Testcase.programtext, errorPos);
- fprintf(stderr, "Fragment Program Error (pos=%d line=%d): %s\n", errorPos, l,
- (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- if (!pglIsProgramARB(FragProg)) {
- fprintf(stderr, "pglIsProgramARB failed\n");
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
+ FragProg = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, Testcase.programtext);
Reshape(Width,Height);
}
diff --git a/tests/shaders/fp-incomplete-tex.c b/tests/shaders/fp-incomplete-tex.c
index 1a46da06b..571ba0554 100644
--- a/tests/shaders/fp-incomplete-tex.c
+++ b/tests/shaders/fp-incomplete-tex.c
@@ -238,50 +238,8 @@ static void Init(void)
piglit_require_fragment_program();
- /*
- * Fragment programs
- */
- pglGenProgramsARB(NUM_PROGRAMS, FragProg);
-
- for(i = 0; i < NUM_PROGRAMS; ++i) {
- GLint errorPos;
-
- check(FragProg[i]);
-
- pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[i]);
- pglProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(ProgramText[i]),
- (const GLubyte *)ProgramText[i]);
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
- if (glGetError() != GL_NO_ERROR || errorPos != -1) {
- int l = FindLine(ProgramText[i], errorPos);
- int a;
-
- fprintf(stderr, "%i: Fragment Program Error (pos=%d line=%d): %s\n",
- i, errorPos, l,
- (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
-
- for (a=-10; a<10; a++)
- {
- if (errorPos+a < 0)
- continue;
- if (errorPos+a >= strlen(ProgramText[i]))
- break;
- fprintf(stderr, "%c", ProgramText[i][errorPos+a]);
- }
- fprintf(stderr, "\n");
-
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- if (!pglIsProgramARB(FragProg[i])) {
- fprintf(stderr, "pglIsProgramARB failed\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- }
+ for(i = 0; i < NUM_PROGRAMS; ++i)
+ FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);
Reshape(Width,Height);
}
diff --git a/tests/shaders/fp-kil.c b/tests/shaders/fp-kil.c
index f272a8303..224c04288 100644
--- a/tests/shaders/fp-kil.c
+++ b/tests/shaders/fp-kil.c
@@ -316,49 +316,8 @@ static void Init(void)
/*
* Fragment programs
*/
- pglGenProgramsARB(NUM_PROGRAMS, FragProg);
-
- for(i = 0; i < NUM_PROGRAMS; ++i) {
- GLint errorPos;
-
- check(FragProg[i]);
-
- pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[i]);
- pglProgramStringARB(
- GL_FRAGMENT_PROGRAM_ARB,
- GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(ProgramText[i]),
- (const GLubyte *)ProgramText[i]);
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
- if (glGetError() != GL_NO_ERROR || errorPos != -1) {
- int l = FindLine(ProgramText[i], errorPos);
- int a;
-
- fprintf(stderr, "%i: Fragment Program Error (pos=%d line=%d): %s\n",
- i, errorPos, l,
- (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
-
- for (a=-10; a<10; a++)
- {
- if (errorPos+a < 0)
- continue;
- if (errorPos+a >= strlen(ProgramText[i]))
- break;
- fprintf(stderr, "%c", ProgramText[i][errorPos+a]);
- }
- fprintf(stderr, "\n");
-
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- if (!pglIsProgramARB(FragProg[i])) {
- fprintf(stderr, "pglIsProgramARB failed\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- }
+ for(i = 0; i < NUM_PROGRAMS; ++i)
+ FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);
/*
* Textures
diff --git a/tests/shaders/fp-lit-mask.c b/tests/shaders/fp-lit-mask.c
index 73827e682..c15a4410a 100644
--- a/tests/shaders/fp-lit-mask.c
+++ b/tests/shaders/fp-lit-mask.c
@@ -32,6 +32,7 @@
#include <math.h>
#include <GL/glut.h>
+#include "piglit-util.h"
static GLuint FragProg[15];
@@ -48,23 +49,14 @@ static int Automatic = 0;
static int Width = 200, Height = 200;
-static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pglProgramLocalParameter4fvARB;
-static PFNGLPROGRAMLOCALPARAMETER4DARBPROC pglProgramLocalParameter4dARB;
-static PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC pglGetProgramLocalParameterdvARB;
-static PFNGLGENPROGRAMSARBPROC pglGenProgramsARB;
-static PFNGLPROGRAMSTRINGARBPROC pglProgramStringARB;
-static PFNGLBINDPROGRAMARBPROC pglBindProgramARB;
-static PFNGLISPROGRAMARBPROC pglIsProgramARB;
-static PFNGLDELETEPROGRAMSARBPROC pglDeleteProgramsARB;
-
static void DoFrame(void)
{
int mask;
-
+
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
-
+
glEnable(GL_FRAGMENT_PROGRAM_ARB);
for(mask = 1; mask < 16; ++mask) {
@@ -89,10 +81,10 @@ static int DoTest( void )
{
int mask;
GLfloat dmax;
-
+
glReadBuffer( GL_FRONT );
dmax = 0;
-
+
for(mask = 1; mask < 16; ++mask) {
GLfloat probe[4];
GLfloat delta[4];
@@ -100,19 +92,19 @@ static int DoTest( void )
glReadPixels(Width*(2*(mask%4)+1)/8, Height*(2*(mask/4)+1)/8, 1, 1,
GL_RGBA, GL_FLOAT, probe);
-
+
printf("Probe %i: %f,%f,%f,%f\n", mask, probe[0], probe[1], probe[2], probe[3]);
-
+
for(i = 0; i < 4; ++i) {
if (mask & (1 << i))
delta[i] = probe[i] - LitExpected[i];
else
delta[i] = probe[i] - 0.8;
-
+
if (delta[i] > dmax) dmax = delta[i];
else if (-delta[i] > dmax) dmax = -delta[i];
}
-
+
printf(" Delta: %f,%f,%f,%f\n", delta[0], delta[1], delta[2], delta[3]);
}
@@ -128,10 +120,10 @@ static int DoTest( void )
static void Redisplay(void)
{
int succ;
-
+
DoFrame();
succ = DoTest();
-
+
if (Automatic) {
printf("\nPIGLIT: { 'result': '%s' }\n", succ ? "pass" : "fail");
exit(0);
@@ -169,84 +161,29 @@ static void Key(unsigned char key, int x, int y)
static void Init(void)
{
int mask;
-
+
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
-
- if (!glutExtensionSupported("GL_ARB_fragment_program")) {
- fprintf(stderr, "Sorry, this demo requires GL_ARB_fragment_program\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- /*
- * Get extension function pointers.
- */
- pglProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress("glProgramLocalParameter4fvARB");
- assert(pglProgramLocalParameter4fvARB);
-
- pglProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) glutGetProcAddress("glProgramLocalParameter4dARB");
- assert(pglProgramLocalParameter4dARB);
-
- pglGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) glutGetProcAddress("glGetProgramLocalParameterdvARB");
- assert(pglGetProgramLocalParameterdvARB);
-
- pglGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) glutGetProcAddress("glGenProgramsARB");
- assert(pglGenProgramsARB);
-
- pglProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB");
- assert(pglProgramStringARB);
-
- pglBindProgramARB = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
- assert(pglBindProgramARB);
-
- pglIsProgramARB = (PFNGLISPROGRAMARBPROC) glutGetProcAddress("glIsProgramARB");
- assert(pglIsProgramARB);
-
- pglDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) glutGetProcAddress("glDeleteProgramsARB");
- assert(pglDeleteProgramsARB);
-
+ piglit_require_fragment_program();
+
/*
* Fragment programs
*/
- pglGenProgramsARB(15, FragProg);
-
for(mask = 1; mask < 16; ++mask) {
GLint errorPos;
char programText[1024];
char maskstring[5];
-
+
maskstring[0] = 0;
if (mask & 1) strcat(maskstring, "x");
if (mask & 2) strcat(maskstring, "y");
if (mask & 4) strcat(maskstring, "z");
if (mask & 8) strcat(maskstring, "w");
sprintf(programText, fragProgramTemplate, maskstring);
-
- assert(FragProg[mask-1] > 0);
- pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[mask-1]);
- pglProgramStringARB(
- GL_FRAGMENT_PROGRAM_ARB,
- GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(programText),
- (const GLubyte *)programText);
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
- if (glGetError() != GL_NO_ERROR || errorPos != -1) {
- int l = FindLine(programText, errorPos);
- fprintf(stderr, "Fragment Program Error (pos=%d line=%d): %s\n", errorPos, l,
- (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- if (!pglIsProgramARB(FragProg[mask-1])) {
- fprintf(stderr, "pglIsProgramARB failed\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
+
+ FragProg[mask-1] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, programText);
}
-
+
Reshape(Width,Height);
}
diff --git a/tests/shaders/trinity-fp1.c b/tests/shaders/trinity-fp1.c
index 128737ee5..8ca85c128 100644
--- a/tests/shaders/trinity-fp1.c
+++ b/tests/shaders/trinity-fp1.c
@@ -33,6 +33,7 @@
#include <math.h>
#include <GL/glut.h>
+#include "piglit-util.h"
static GLuint TexDiffuse = 1;
static GLuint TexNormal = 2;
@@ -45,15 +46,6 @@ static int Automatic = 0;
static int Width = 200, Height = 100;
-static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pglProgramLocalParameter4fvARB;
-static PFNGLPROGRAMLOCALPARAMETER4DARBPROC pglProgramLocalParameter4dARB;
-static PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC pglGetProgramLocalParameterdvARB;
-static PFNGLGENPROGRAMSARBPROC pglGenProgramsARB;
-static PFNGLPROGRAMSTRINGARBPROC pglProgramStringARB;
-static PFNGLBINDPROGRAMARBPROC pglBindProgramARB;
-static PFNGLISPROGRAMARBPROC pglIsProgramARB;
-static PFNGLDELETEPROGRAMSARBPROC pglDeleteProgramsARB;
-
static void DoFrame(void)
{
@@ -280,66 +272,8 @@ static void Init(void)
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
- if (!glutExtensionSupported("GL_ARB_fragment_program")) {
- fprintf(stderr, "Sorry, this demo requires GL_ARB_fragment_program\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
-
- /*
- * Get extension function pointers.
- */
- pglProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress("glProgramLocalParameter4fvARB");
- assert(pglProgramLocalParameter4fvARB);
-
- pglProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) glutGetProcAddress("glProgramLocalParameter4dARB");
- assert(pglProgramLocalParameter4dARB);
-
- pglGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) glutGetProcAddress("glGetProgramLocalParameterdvARB");
- assert(pglGetProgramLocalParameterdvARB);
-
- pglGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) glutGetProcAddress("glGenProgramsARB");
- assert(pglGenProgramsARB);
-
- pglProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB");
- assert(pglProgramStringARB);
-
- pglBindProgramARB = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
- assert(pglBindProgramARB);
-
- pglIsProgramARB = (PFNGLISPROGRAMARBPROC) glutGetProcAddress("glIsProgramARB");
- assert(pglIsProgramARB);
-
- pglDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) glutGetProcAddress("glDeleteProgramsARB");
- assert(pglDeleteProgramsARB);
-
- /*
- * Fragment program
- */
- pglGenProgramsARB(1, &FragProg);
- assert(FragProg > 0);
- pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg);
- pglProgramStringARB(
- GL_FRAGMENT_PROGRAM_ARB,
- GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(fragProgramText),
- (const GLubyte *) fragProgramText);
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
- if (glGetError() != GL_NO_ERROR || errorPos != -1) {
- int l = FindLine(fragProgramText, errorPos);
- fprintf(stderr, "Fragment Program Error (pos=%d line=%d): %s\n", errorPos, l,
- (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
- if (!pglIsProgramARB(FragProg)) {
- fprintf(stderr, "pglIsProgramARB failed\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
+ piglit_require_fragment_program();
+ FragProg = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, fragProgramText);
/*
* Initialize textures
diff --git a/tests/texturing/cubemap.c b/tests/texturing/cubemap.c
index e98877d3d..2a180a2af 100644
--- a/tests/texturing/cubemap.c
+++ b/tests/texturing/cubemap.c
@@ -370,13 +370,7 @@ static void Key(unsigned char key, int x, int y)
static void init()
{
- if (!glutExtensionSupported("GL_ARB_texture_cube_map")) {
- fprintf(stderr,
- "Sorry, this demo requires GL_ARB_texture_cube_map\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
- }
+ piglit_require_extension("GL_ARB_texture_cube_map");
/* Set up projection matrix so we can just draw using window
* coordinates.