aboutsummaryrefslogtreecommitdiff
path: root/tests/shaders
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-09-29 14:43:41 -0700
committerEric Anholt <eric@anholt.net>2009-09-29 17:26:48 -0700
commit4cfbe82bc3278321a90d30cc768f09525bd68328 (patch)
tree7880c49576216d853fd1f5124fba0b22fd32cf8b /tests/shaders
parente144c21b764068baddc639657f965decd7102993 (diff)
Move most piglit tests to using the framework.
This saves a giant pile of code, and should encourage cleaner testcases from people writing tests in the future.
Diffstat (limited to 'tests/shaders')
-rw-r--r--tests/shaders/fp-abs-01.c2
-rw-r--r--tests/shaders/fp-abs-02.c2
-rw-r--r--tests/shaders/fp-condition_codes-01.c2
-rw-r--r--tests/shaders/fp-fog.c65
-rw-r--r--tests/shaders/fp-fragment-position.c69
-rw-r--r--tests/shaders/fp-generic.c50
-rw-r--r--tests/shaders/fp-incomplete-tex.c69
-rw-r--r--tests/shaders/fp-indirections.c33
-rw-r--r--tests/shaders/fp-indirections2.c3
-rw-r--r--tests/shaders/fp-kil.c69
-rw-r--r--tests/shaders/fp-lit-mask.c68
-rw-r--r--tests/shaders/fp-rfl.c2
-rw-r--r--tests/shaders/fp-set-01.c2
-rw-r--r--tests/shaders/fp-set-02.c2
-rw-r--r--tests/shaders/fp-unpack-01.c2
-rw-r--r--tests/shaders/glsl-bug-22603.c59
-rw-r--r--tests/shaders/glsl-deriv-varyings.c66
-rw-r--r--tests/shaders/glsl-derivs.c66
-rw-r--r--tests/shaders/glsl-dlist-getattriblocation.c2
-rw-r--r--tests/shaders/glsl-empty-vs-no-fs.c31
-rw-r--r--tests/shaders/glsl-fs-exp2.c63
-rw-r--r--tests/shaders/glsl-fs-fragcoord.c68
-rw-r--r--tests/shaders/glsl-fs-log2.c63
-rw-r--r--tests/shaders/glsl-fwidth.c68
-rw-r--r--tests/shaders/glsl-lod-bias.c64
-rw-r--r--tests/shaders/glsl-uniform-update.c64
-rw-r--r--tests/shaders/glsl-unused-varying.c62
-rw-r--r--tests/shaders/glsl-vs-if-bool.c75
-rw-r--r--tests/shaders/glsl-vs-if.c76
-rw-r--r--tests/shaders/glsl-vs-loop.c60
-rw-r--r--tests/shaders/trinity-fp1.c73
-rw-r--r--tests/shaders/vp-bad-program.c34
-rw-r--r--tests/shaders/vp-ignore-input.c48
-rw-r--r--tests/shaders/vpfp-generic.cpp12
34 files changed, 363 insertions, 1131 deletions
diff --git a/tests/shaders/fp-abs-01.c b/tests/shaders/fp-abs-01.c
index ff929816..5ff3a2a9 100644
--- a/tests/shaders/fp-abs-01.c
+++ b/tests/shaders/fp-abs-01.c
@@ -113,7 +113,7 @@ static GLint vert_prog;
/*@}*/
-int
+enum piglit_result
piglit_display(void)
{
static const GLfloat color[4] = { 0.0, 1.0, 0.0, 0.0 };
diff --git a/tests/shaders/fp-abs-02.c b/tests/shaders/fp-abs-02.c
index 3d495f6c..2bacf75e 100644
--- a/tests/shaders/fp-abs-02.c
+++ b/tests/shaders/fp-abs-02.c
@@ -135,7 +135,7 @@ static GLint vert_prog;
/*@}*/
-int
+enum piglit_result
piglit_display(void)
{
static const GLfloat color[4] = { 0.0, 1.0, 0.0, 0.0 };
diff --git a/tests/shaders/fp-condition_codes-01.c b/tests/shaders/fp-condition_codes-01.c
index d5836d59..c240db24 100644
--- a/tests/shaders/fp-condition_codes-01.c
+++ b/tests/shaders/fp-condition_codes-01.c
@@ -182,7 +182,7 @@ generate_shader(unsigned cc, unsigned good_mask)
}
-int
+enum piglit_result
piglit_display(void)
{
static const GLfloat good_color[4] = { 0.9, 0.5, 0.7, 1.0 };
diff --git a/tests/shaders/fp-fog.c b/tests/shaders/fp-fog.c
index 25b4cd33..1287124e 100644
--- a/tests/shaders/fp-fog.c
+++ b/tests/shaders/fp-fog.c
@@ -41,9 +41,8 @@ static const char* const program_text =
"END\n"
;
-static int Automatic = 0;
-
-static int Width = 50, Height = 50;
+int piglit_width = 50, piglit_height = 50;
+int piglit_window_mode = GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE;
#if defined(__APPLE__)
static void (*pglFogCoordf)(GLfloat coord) = NULL;
@@ -51,7 +50,8 @@ static void (*pglFogCoordf)(GLfloat coord) = NULL;
static PFNGLFOGCOORDFPROC pglFogCoordf = NULL;
#endif
-static void Redisplay(void)
+enum piglit_result
+piglit_display(void)
{
static const struct {
float x, y, r;
@@ -107,25 +107,22 @@ static void Redisplay(void)
expected_color[2] = 0.0;
expected_color[3] = 1.0;
- pass &= piglit_probe_pixel_rgba(probes[i].x * Width / 2,
- probes[i].y * Height / 2,
+ pass &= piglit_probe_pixel_rgba(probes[i].x * piglit_width / 2,
+ probes[i].y * piglit_height / 2,
expected_color);
}
glutSwapBuffers();
- if (Automatic) {
- printf("\nPIGLIT: { 'result': '%s' }\n",
- pass ? "pass" : "fail");
- exit(0);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
static void Reshape(int width, int height)
{
- Width = width;
- Height = height;
+ piglit_width = width;
+ piglit_height = height;
+
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -135,24 +132,13 @@ static void Reshape(int width, int height)
glLoadIdentity();
}
-
-static void Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
-
- if (key) {
- exit(0);
- }
-
- glutPostRedisplay();
-}
-
-
-static void Init(void)
+void
+piglit_init(int argc, char **argv)
{
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ glutReshapeFunc(Reshape);
+
glClearColor(0.3, 0.3, 0.3, 0.3);
if (atof((const char *) glGetString(GL_VERSION)) >= 1.4) {
@@ -187,26 +173,5 @@ static void Init(void)
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
- Reshape(Width, Height);
-}
-
-
-int main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
-
- if ((argc > 1) && (strcmp(argv[1], "-auto") == 0)) {
- Automatic = 1;
- }
-
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE);
- glutCreateWindow(argv[0]);
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Redisplay);
- Init();
- glutMainLoop();
- return 0;
+ Reshape(piglit_width, piglit_height);
}
diff --git a/tests/shaders/fp-fragment-position.c b/tests/shaders/fp-fragment-position.c
index e79a986a..0abb6d93 100644
--- a/tests/shaders/fp-fragment-position.c
+++ b/tests/shaders/fp-fragment-position.c
@@ -27,6 +27,9 @@
#include "piglit-util.h"
+int piglit_width = 200, piglit_height = 200;
+int piglit_window_mode = GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH;
+
#define NUM_PROGRAMS 4
static GLuint FragProg[NUM_PROGRAMS];
@@ -61,11 +64,6 @@ static const char* const ProgramText[NUM_PROGRAMS] = {
"END",
};
-static int Automatic = 0;
-
-static int Width = 200, Height = 200;
-
-
/**
* Draw four quadrilaterals, one for each fragment program:
* +--------+--------+
@@ -248,12 +246,12 @@ static int DoTest( void )
/*
printf("ReadPixels at %d, %d\n",
- (int)(Probes[idx].x*Width/2),
- (int)(Probes[idx].y*Height/2));
+ (int)(Probes[idx].x*piglit_width/2),
+ (int)(Probes[idx].y*piglit_height/2));
*/
- glReadPixels((int)(Probes[idx].x*Width/2),
- (int)(Probes[idx].y*Height/2),
+ glReadPixels((int)(Probes[idx].x*piglit_width/2),
+ (int)(Probes[idx].y*piglit_height/2),
1, 1,
GL_RGBA, GL_FLOAT, probe);
@@ -283,24 +281,22 @@ static int DoTest( void )
}
-static void Redisplay(void)
+enum piglit_result
+piglit_display(void)
{
- int succ;
+ int pass;
DoFrame();
- succ = DoTest();
+ pass = DoTest();
- if (Automatic) {
- printf("\nPIGLIT: { 'result': '%s' }\n", succ ? "pass" : "fail");
- exit(0);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
static void Reshape(int width, int height)
{
- Width = width;
- Height = height;
+ piglit_width = width;
+ piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -310,12 +306,18 @@ static void Reshape(int width, int height)
glLoadIdentity();
}
-static void Init(void)
+void
+piglit_init(int argc, char **argv)
{
int i, x, y;
GLubyte rectangle[200][200][4];
GLubyte tex[256*256][4];
+ if (!GLEW_VERSION_1_3) {
+ printf("Requires OpenGL 1.3\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
piglit_require_fragment_program();
@@ -373,32 +375,5 @@ static void Init(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- Reshape(Width,Height);
+ Reshape(piglit_width, piglit_height);
}
-
-int main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- if (argc == 2 && !strcmp(argv[1], "-auto"))
- Automatic = 1;
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH);
- glutCreateWindow(argv[0]);
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(Redisplay);
- glewInit();
-
- if (!GLEW_VERSION_1_3) {
- printf("Requires OpenGL 1.3\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- Init();
- glutMainLoop();
- return 0;
-}
-
-
diff --git a/tests/shaders/fp-generic.c b/tests/shaders/fp-generic.c
index 05c4d6c6..d923b9bf 100644
--- a/tests/shaders/fp-generic.c
+++ b/tests/shaders/fp-generic.c
@@ -139,7 +139,8 @@ GL program
*/
-static int Width = 100, Height = 100;
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA;
static const char* Filename = 0;
static struct testcase Testcase;
@@ -178,27 +179,27 @@ static void TestInstance(struct testinstance* instance)
glutSwapBuffers();
glReadBuffer(GL_FRONT);
- if (!piglit_probe_pixel_rgba(Width/2, Height/2, instance->expected)) {
+ if (!piglit_probe_pixel_rgba(piglit_width/2, piglit_height/2, instance->expected)) {
fprintf(stderr, "Test %s, instance #%i failed\n", Filename, instance-Testcase.instances);
piglit_report_result(PIGLIT_FAILURE);
}
}
-
-static void Redisplay(void)
+enum piglit_result
+piglit_display(void)
{
int i;
for(i = 0; i < Testcase.nrInstances; ++i)
TestInstance(&Testcase.instances[i]);
- piglit_report_result(PIGLIT_SUCCESS);
+ return PIGLIT_SUCCESS;
}
static void Reshape(int width, int height)
{
- Width = width;
- Height = height;
+ piglit_width = width;
+ piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -208,19 +209,18 @@ static void Reshape(int width, int height)
}
-static void Init(void)
+void
+piglit_init(int argc, char **argv)
{
- piglit_require_fragment_program();
- FragProg = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, Testcase.programtext);
+ int i;
- Reshape(Width,Height);
-}
+ piglit_automatic = GL_TRUE;
+ if (!GLEW_VERSION_1_3) {
+ printf("Requires OpenGL 1.3\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
-int main(int argc, char *argv[])
-{
- int i;
- glutInit(&argc, argv);
for(i = 1; i < argc; ++i) {
if (!Filename)
Filename = argv[i];
@@ -232,22 +232,10 @@ int main(int argc, char *argv[])
}
readTestcase(&Testcase, Filename);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA);
- glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
- glutDisplayFunc(Redisplay);
- glewInit();
- if (!GLEW_VERSION_1_3) {
- printf("Requires OpenGL 1.3\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
+ piglit_require_fragment_program();
+ FragProg = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, Testcase.programtext);
- Init();
- glutMainLoop();
- return 0;
+ Reshape(piglit_width, piglit_height);
}
-
diff --git a/tests/shaders/fp-incomplete-tex.c b/tests/shaders/fp-incomplete-tex.c
index 3fa0d27a..abf7c827 100644
--- a/tests/shaders/fp-incomplete-tex.c
+++ b/tests/shaders/fp-incomplete-tex.c
@@ -28,6 +28,9 @@
#include "piglit-util.h"
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH;
+
#define NUM_PROGRAMS 5
static GLuint FragProg[NUM_PROGRAMS];
@@ -54,10 +57,6 @@ static const char* const ProgramText[NUM_PROGRAMS] = {
"END"
};
-static int Automatic = 0;
-
-static int Width = 300, Height = 200;
-
static void DoFrame(void)
{
int i;
@@ -143,9 +142,9 @@ static int DoTest( void )
GLfloat delta[4];
int i;
- glReadPixels((int)(Probes[idx].x*Width/3),
- (int)(Probes[idx].y*Height/2),
- 1, 1,
+ glReadPixels((int)(Probes[idx].x * piglit_width / 3),
+ (int)(Probes[idx].y * piglit_height / 2),
+ 1, 1,
GL_RGBA, GL_FLOAT, probe);
printf("%20s (%3.1f,%3.1f): %f,%f,%f,%f",
@@ -174,24 +173,22 @@ static int DoTest( void )
}
-static void Redisplay(void)
+enum piglit_result
+piglit_display(void)
{
- int succ;
+ int pass;
DoFrame();
- succ = DoTest();
+ pass = DoTest();
- if (Automatic) {
- printf("\nPIGLIT: { 'result': '%s' }\n", succ ? "pass" : "fail");
- exit(0);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
static void Reshape(int width, int height)
{
- Width = width;
- Height = height;
+ piglit_width = width;
+ piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -201,50 +198,20 @@ static void Reshape(int width, int height)
glLoadIdentity();
}
-
-static void Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void Init(void)
+void
+piglit_init(int argc, char **argv)
{
int i;
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ glutReshapeFunc(Reshape);
+
piglit_require_fragment_program();
for(i = 0; i < NUM_PROGRAMS; ++i)
FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);
- Reshape(Width,Height);
+ Reshape(piglit_width, piglit_height);
}
-int main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- if (argc == 2 && !strcmp(argv[1], "-auto"))
- Automatic = 1;
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH);
- glutCreateWindow(argv[0]);
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Redisplay);
- Init();
- glutMainLoop();
- return 0;
-}
-
-
-
diff --git a/tests/shaders/fp-indirections.c b/tests/shaders/fp-indirections.c
index 608a00d5..dc49b36a 100644
--- a/tests/shaders/fp-indirections.c
+++ b/tests/shaders/fp-indirections.c
@@ -27,10 +27,8 @@
#include "piglit-util.h"
-static int Automatic = 0;
-
-#define WIN_WIDTH 100
-#define WIN_HEIGHT 100
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static int get_program_i(GLenum pname)
{
@@ -264,17 +262,19 @@ GLboolean test_temporary_source_indirections(void)
return pass;
}
-void display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
pass = test_temporary_dest_indirections() && pass;
pass = test_temporary_source_indirections() && pass;
- piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- exit(0);
+
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-void init(void)
+void
+piglit_init(int argc, char **argv)
{
piglit_require_fragment_program();
@@ -289,20 +289,3 @@ void init(void)
printf("Maximum native tex indirections: %d\n",
get_program_i(GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB));
}
-
-int main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- if (argc == 2 && !strcmp(argv[1], "-auto"))
- Automatic = 1;
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutInitDisplayMode(GLUT_DOUBLE);
- glutCreateWindow(argv[0]);
- glutDisplayFunc(display);
-
- init();
-
- glutMainLoop();
- return 0;
-}
diff --git a/tests/shaders/fp-indirections2.c b/tests/shaders/fp-indirections2.c
index f125d5bd..3541d754 100644
--- a/tests/shaders/fp-indirections2.c
+++ b/tests/shaders/fp-indirections2.c
@@ -202,7 +202,8 @@ static int test(unsigned int dim, unsigned int samples)
return PIGLIT_SUCCESS;
}
-int piglit_display()
+enum piglit_result
+piglit_display(void)
{
int result;
unsigned int dim;
diff --git a/tests/shaders/fp-kil.c b/tests/shaders/fp-kil.c
index d82c0eca..eb886e4c 100644
--- a/tests/shaders/fp-kil.c
+++ b/tests/shaders/fp-kil.c
@@ -27,6 +27,9 @@
#include "piglit-util.h"
+int piglit_width = 200, piglit_height = 200;
+int piglit_window_mode = GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH;
+
#define NUM_PROGRAMS 2
static GLuint FragProg[NUM_PROGRAMS];
@@ -46,11 +49,6 @@ static const char* const ProgramText[NUM_PROGRAMS] = {
"END"
};
-static int Automatic = 0;
-
-static int Width = 200, Height = 200; // space for more tests
-
-
static void DoFrame(void)
{
glClearColor(0.0, 0.0, 0.0, 1.0);
@@ -219,8 +217,8 @@ static int DoTest( void )
GLfloat delta[4];
int i;
- glReadPixels((int)(Probes[idx].x*Width/2),
- (int)(Probes[idx].y*Height/2),
+ glReadPixels((int)(Probes[idx].x*piglit_width/2),
+ (int)(Probes[idx].y*piglit_height/2),
1, 1,
GL_RGBA, GL_FLOAT, probe);
@@ -249,25 +247,22 @@ static int DoTest( void )
return 1;
}
-
-static void Redisplay(void)
+enum piglit_result
+piglit_display(void)
{
- int succ;
+ int pass;
DoFrame();
- succ = DoTest();
+ pass = DoTest();
- if (Automatic) {
- printf("\nPIGLIT: { 'result': '%s' }\n", succ ? "pass" : "fail");
- exit(0);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
static void Reshape(int width, int height)
{
- Width = width;
- Height = height;
+ piglit_width = width;
+ piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -277,11 +272,19 @@ static void Reshape(int width, int height)
glLoadIdentity();
}
-static void Init(void)
+void
+piglit_init(int argc, char **argv)
{
int i, x, y;
GLubyte tex[4][4][4];
+ glutReshapeFunc(Reshape);
+
+ if (!GLEW_VERSION_1_3) {
+ printf("Requires OpenGL 1.3\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
piglit_require_fragment_program();
@@ -313,33 +316,5 @@ static void Init(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- Reshape(Width,Height);
+ Reshape(piglit_width, piglit_height);
}
-
-int main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- if (argc == 2 && !strcmp(argv[1], "-auto"))
- Automatic = 1;
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
- glutCreateWindow(argv[0]);
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(Redisplay);
- glewInit();
-
- if (!GLEW_VERSION_1_3) {
- printf("Requires OpenGL 1.3\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- Init();
- glutMainLoop();
- return 0;
-}
-
-
-
diff --git a/tests/shaders/fp-lit-mask.c b/tests/shaders/fp-lit-mask.c
index e9550c80..47cc5a2c 100644
--- a/tests/shaders/fp-lit-mask.c
+++ b/tests/shaders/fp-lit-mask.c
@@ -27,6 +27,9 @@
#include "piglit-util.h"
+int piglit_width = 200, piglit_height = 200;
+int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH;
+
static GLuint FragProg[15];
static const char fragProgramTemplate[] =
@@ -38,11 +41,6 @@ static const char fragProgramTemplate[] =
"END\n";
static float LitExpected[4] = { 1.0, 0.65, 0.433, 1.0 };
-static int Automatic = 0;
-
-static int Width = 200, Height = 200;
-
-
static void DoFrame(void)
{
int mask;
@@ -83,7 +81,8 @@ static int DoTest( void )
GLfloat delta[4];
int i;
- glReadPixels(Width*(2*(mask%4)+1)/8, Height*(2*(mask/4)+1)/8, 1, 1,
+ glReadPixels(piglit_width * (2*(mask%4)+1)/8,
+ piglit_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]);
@@ -109,25 +108,22 @@ static int DoTest( void )
return 1;
}
-
-static void Redisplay(void)
+enum piglit_result
+piglit_display(void)
{
- int succ;
+ int pass;
DoFrame();
- succ = DoTest();
+ pass = DoTest();
- if (Automatic) {
- printf("\nPIGLIT: { 'result': '%s' }\n", succ ? "pass" : "fail");
- exit(0);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
static void Reshape(int width, int height)
{
- Width = width;
- Height = height;
+ piglit_width = width;
+ piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -136,25 +132,12 @@ static void Reshape(int width, int height)
glLoadIdentity();
}
-
-static void Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- pglDeleteProgramsARB(15, FragProg);
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void Init(void)
+void piglit_init(int argc, char **argv)
{
int mask;
+ glutReshapeFunc(Reshape);
+
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
piglit_require_fragment_program();
@@ -176,24 +159,5 @@ static void Init(void)
FragProg[mask-1] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, programText);
}
- Reshape(Width,Height);
-}
-
-
-int main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- if (argc == 2 && !strcmp(argv[1], "-auto"))
- Automatic = 1;
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH);
- glutCreateWindow(argv[0]);
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Redisplay);
- Init();
- glutMainLoop();
- return 0;
+ Reshape(piglit_width, piglit_height);
}
-
diff --git a/tests/shaders/fp-rfl.c b/tests/shaders/fp-rfl.c
index ffc0bffb..d8713284 100644
--- a/tests/shaders/fp-rfl.c
+++ b/tests/shaders/fp-rfl.c
@@ -120,7 +120,7 @@ static GLfloat position[4 * TEST_ROWS * TEST_COLS];
static const float green[4] = { 0.0, 1.0, 0.0, 0.0 };
-int
+enum piglit_result
piglit_display(void)
{
int result = PIGLIT_SUCCESS;
diff --git a/tests/shaders/fp-set-01.c b/tests/shaders/fp-set-01.c
index cb075c55..7495a1cc 100644
--- a/tests/shaders/fp-set-01.c
+++ b/tests/shaders/fp-set-01.c
@@ -77,7 +77,7 @@ static GLint progs[2];
/*@}*/
-int
+enum piglit_result
piglit_display(void)
{
const GLfloat comparitor[4] = { 0.5, 0.5, 0.5, 0.5 };
diff --git a/tests/shaders/fp-set-02.c b/tests/shaders/fp-set-02.c
index e969c791..a5a86246 100644
--- a/tests/shaders/fp-set-02.c
+++ b/tests/shaders/fp-set-02.c
@@ -153,7 +153,7 @@ tr_func(float a, float b)
}
-int
+enum piglit_result
piglit_display(void)
{
const GLfloat comparitor[4] = { 0.5, 0.5, 0.5, 0.5 };
diff --git a/tests/shaders/fp-unpack-01.c b/tests/shaders/fp-unpack-01.c
index 684c96f9..a3e35420 100644
--- a/tests/shaders/fp-unpack-01.c
+++ b/tests/shaders/fp-unpack-01.c
@@ -255,7 +255,7 @@ pack(float *packed, const float *color, GLenum type)
}
-int
+enum piglit_result
piglit_display(void)
{
unsigned i;
diff --git a/tests/shaders/glsl-bug-22603.c b/tests/shaders/glsl-bug-22603.c
index 972f5ed6..69695317 100644
--- a/tests/shaders/glsl-bug-22603.c
+++ b/tests/shaders/glsl-bug-22603.c
@@ -32,10 +32,8 @@
#include "piglit-util.h"
-static GLboolean Automatic;
-
-#define WIN_WIDTH 800
-#define WIN_HEIGHT 600
+int piglit_width = 800, piglit_height = 600;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
/* Misbehaviour: first: the quads are not drawn in the correct order
* (darker equals closer to the viewer), second: the middle one is strangely
@@ -46,8 +44,8 @@ static GLuint vs, fs, prog, shadow_vs, shadow_fs, shadow_prog;
static GLint shadowMap_location;
static GLint eye_projection_location, light_projection_location;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLuint shadow_texture;
GLuint fbo;
@@ -156,14 +154,13 @@ display(void)
/* check that rect2 where less than rect1 is rendered */
pass &= piglit_probe_pixel_rgb(450, 250, rect2_color_bottom_rect1);
- if (Automatic)
- piglit_report_result (pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
-
glutSwapBuffers();
+
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void
-init(void)
+void
+piglit_init(int argc, char **argv)
{
const char *vs_source =
"uniform mat4 eye_projection;"
@@ -193,6 +190,11 @@ init(void)
" gl_FragDepth = gl_FragCoord.z;"
"}";
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
vs = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
glShaderSourceARB(vs, 1, &vs_source, NULL);
glCompileShaderARB(vs);
@@ -217,38 +219,3 @@ init(void)
"light_projection");
shadowMap_location = glGetUniformLocationARB(shadow_prog, "shadowMap");
}
-
-int
-main(int argc, char** argv)
-{
- /* far = 11, near = 1 */
- int i;
-
- glutInit(&argc, argv);
-
- for (i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-bug-22603");
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/glsl-deriv-varyings.c b/tests/shaders/glsl-deriv-varyings.c
index 30e33056..f5e19a46 100644
--- a/tests/shaders/glsl-deriv-varyings.c
+++ b/tests/shaders/glsl-deriv-varyings.c
@@ -30,7 +30,12 @@
#include "piglit-util.h"
-static GLboolean Automatic = GL_FALSE;
+static void compileLinkProg(void);
+static void loadTex(void);
+
+int piglit_width = 400, piglit_height = 300;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
static GLuint tex[1];
static GLint prog1;
static GLint vs1;
@@ -79,17 +84,19 @@ static const char *fragShaderText2 =
-static void
-Init(void)
+void
+piglit_init(int argc, char **argv)
{
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, 400, 0, 300, -1, 1);
+ compileLinkProg();
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ loadTex();
+
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
glEnable(GL_TEXTURE_2D);
glClearColor(0.6, 0.6, 0.6, 1.0);
@@ -202,8 +209,8 @@ loadTex(void)
}
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
@@ -227,42 +234,9 @@ display(void)
pass = pass && piglit_probe_pixel_rgb(132, 125, green);
pass = pass && piglit_probe_pixel_rgb(205, 125, deriv);
- if(Automatic) {
- piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- exit(pass ? 0 : 1);
- }
-
glFinish();
glutSwapBuffers();
-}
-
-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("glsl-deriv-varyings");
- glutDisplayFunc(display);
- glutKeyboardFunc(piglit_escape_exit_key);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- Init();
-
- compileLinkProg();
-
- loadTex();
-
- glutMainLoop();
-
- return 0;
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
diff --git a/tests/shaders/glsl-derivs.c b/tests/shaders/glsl-derivs.c
index 44eb1670..80d8464c 100644
--- a/tests/shaders/glsl-derivs.c
+++ b/tests/shaders/glsl-derivs.c
@@ -30,7 +30,12 @@
#include "piglit-util.h"
-static GLboolean Automatic = GL_FALSE;
+static void compileLinkProg(void);
+static void loadTex(void);
+
+int piglit_width = 400, piglit_height = 300;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
static GLuint tex[1];
static GLint prog1;
static GLint vs1;
@@ -78,17 +83,19 @@ static const char *fragShaderText2 =
-static void
-Init(void)
+void
+piglit_init(int argc, char **argv)
{
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, 400, 0, 300, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ compileLinkProg();
+
+ loadTex();
glEnable(GL_TEXTURE_2D);
glClearColor(0.6, 0.6, 0.6, 1.0);
@@ -201,8 +208,8 @@ loadTex(void)
}
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
@@ -226,42 +233,9 @@ display(void)
pass = pass && piglit_probe_pixel_rgb(132, 125, green);
pass = pass && piglit_probe_pixel_rgb(205, 125, deriv);
- if(Automatic) {
- piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- exit(pass ? 0 : 1);
- }
-
glFinish();
glutSwapBuffers();
-}
-
-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("glsl-derivs");
- glutDisplayFunc(display);
- glutKeyboardFunc(piglit_escape_exit_key);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- Init();
-
- compileLinkProg();
-
- loadTex();
-
- glutMainLoop();
-
- return 0;
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
diff --git a/tests/shaders/glsl-dlist-getattriblocation.c b/tests/shaders/glsl-dlist-getattriblocation.c
index 378e1009..8a49114a 100644
--- a/tests/shaders/glsl-dlist-getattriblocation.c
+++ b/tests/shaders/glsl-dlist-getattriblocation.c
@@ -45,7 +45,7 @@ static const GLchar *vertShaderText =
"} \n";
-int
+enum piglit_result
piglit_display(void)
{
GLboolean pass = GL_TRUE;
diff --git a/tests/shaders/glsl-empty-vs-no-fs.c b/tests/shaders/glsl-empty-vs-no-fs.c
index e317fa13..0f5cd05b 100644
--- a/tests/shaders/glsl-empty-vs-no-fs.c
+++ b/tests/shaders/glsl-empty-vs-no-fs.c
@@ -35,11 +35,13 @@
#include "piglit-util.h"
-static GLboolean Automatic;
+int piglit_width = 250, piglit_height = 250;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
static const char *vs_source = "void main() {}";
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLint vs;
GLint prog;
@@ -65,31 +67,14 @@ display(void)
glDeleteShader(vs);
}
- if (Automatic) {
- piglit_report_result(PIGLIT_SUCCESS);
- }
+ return PIGLIT_SUCCESS;
}
-int
-main(int argc, char** argv)
+void
+piglit_init(int argc, char **argv)
{
- glutInit(&argc, argv);
- if (argc == 2 && !strcmp(argv[1], "-auto"))
- Automatic = 1;
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(250, 250);
- glutCreateWindow("glsl-empty-vs-no-fs");
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(display);
- glewInit();
-
if (!GLEW_VERSION_2_0) {
printf("Requires OpenGL 2.0\n");
piglit_report_result(PIGLIT_SKIP);
- exit(1);
}
-
- glutMainLoop();
-
- return 0;
}
diff --git a/tests/shaders/glsl-fs-exp2.c b/tests/shaders/glsl-fs-exp2.c
index 3082a15f..5d105376 100644
--- a/tests/shaders/glsl-fs-exp2.c
+++ b/tests/shaders/glsl-fs-exp2.c
@@ -32,15 +32,14 @@
#include "piglit-util.h"
-#define WIN_WIDTH 100
-#define WIN_HEIGHT 100
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static int args1_location, args2_location;
static GLint prog;
-static GLboolean Automatic;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
/* result = 2 ^ args1 + args2 */
@@ -59,26 +58,20 @@ display(void)
glutSwapBuffers();
- if (Automatic) {
- piglit_report_result (pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void init(void)
+void
+piglit_init(int argc, char **argv)
{
GLint vs, fs;
- /* Set up projection matrix so we can just draw using window
- * coordinates.
- */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, WIN_WIDTH, 0, WIN_HEIGHT, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
vs = piglit_compile_shader(GL_VERTEX_SHADER,
SOURCE_DIR "tests/shaders/glsl-fs-exp2.vert");
@@ -92,35 +85,3 @@ static void init(void)
args1_location = glGetUniformLocation(prog, "args1");
args2_location = glGetUniformLocation(prog, "args2");
}
-
-int main(int argc, char**argv)
-{
- int i;
-
- glutInit(&argc, argv);
-
- for(i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-fs-exp2");
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/glsl-fs-fragcoord.c b/tests/shaders/glsl-fs-fragcoord.c
index ec351a83..c78a6cc8 100644
--- a/tests/shaders/glsl-fs-fragcoord.c
+++ b/tests/shaders/glsl-fs-fragcoord.c
@@ -32,14 +32,13 @@
#include "piglit-util.h"
-#define WIN_WIDTH 256
-#define WIN_HEIGHT 256
+int piglit_width = 256, piglit_height = 256;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static GLint prog;
-static GLboolean Automatic;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
int x, y;
@@ -47,10 +46,10 @@ display(void)
glClearColor(0.5, 0.5, 0.5, 0.5);
glClear(GL_COLOR_BUFFER_BIT);
- piglit_draw_rect(0, 0, WIN_WIDTH, WIN_HEIGHT);
+ piglit_draw_rect(0, 0, piglit_width, piglit_height);
- for (y = 0; y < WIN_HEIGHT; y++) {
- for (x = 0; x < WIN_WIDTH; x++) {
+ for (y = 0; y < piglit_height; y++) {
+ for (x = 0; x < piglit_width; x++) {
float color[3];
color[0] = x / 256.0;
@@ -65,25 +64,20 @@ display(void)
glutSwapBuffers();
- if (Automatic)
- piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void init(void)
+void
+piglit_init(int argc, char **argv)
{
GLint vs, fs;
- /* Set up projection matrix so we can just draw using window
- * coordinates.
- */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, WIN_WIDTH, 0, WIN_HEIGHT, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
vs = piglit_compile_shader(GL_VERTEX_SHADER,
SOURCE_DIR "tests/shaders/glsl-fs-fragcoord.vert");
@@ -94,35 +88,3 @@ static void init(void)
glUseProgram(prog);
}
-
-int main(int argc, char**argv)
-{
- int i;
-
- glutInit(&argc, argv);
-
- for(i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-fs-fragcoord");
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/glsl-fs-log2.c b/tests/shaders/glsl-fs-log2.c
index de147f99..331ba1f6 100644
--- a/tests/shaders/glsl-fs-log2.c
+++ b/tests/shaders/glsl-fs-log2.c
@@ -32,15 +32,14 @@
#include "piglit-util.h"
-#define WIN_WIDTH 100
-#define WIN_HEIGHT 100
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static int args1_location, args2_location;
static GLint prog;
-static GLboolean Automatic;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
/* result = log2(args1) + args2 */
@@ -59,26 +58,20 @@ display(void)
glutSwapBuffers();
- if (Automatic) {
- piglit_report_result (pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void init(void)
+void
+piglit_init(int argc, char **argv)
{
GLint vs, fs;
- /* Set up projection matrix so we can just draw using window
- * coordinates.
- */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, WIN_WIDTH, 0, WIN_HEIGHT, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
vs = piglit_compile_shader(GL_VERTEX_SHADER,
SOURCE_DIR "tests/shaders/glsl-fs-log2.vert");
@@ -92,35 +85,3 @@ static void init(void)
args1_location = glGetUniformLocation(prog, "args1");
args2_location = glGetUniformLocation(prog, "args2");
}
-
-int main(int argc, char**argv)
-{
- int i;
-
- glutInit(&argc, argv);
-
- for(i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-fs-log2");
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/glsl-fwidth.c b/tests/shaders/glsl-fwidth.c
index a63becba..b3553add 100644
--- a/tests/shaders/glsl-fwidth.c
+++ b/tests/shaders/glsl-fwidth.c
@@ -30,7 +30,12 @@
#include "piglit-util.h"
-static GLboolean Automatic = GL_FALSE;
+int piglit_width = 400, piglit_height = 300;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static void loadTex(void);
+static void compileLinkProg(void);
+
static GLuint tex[1];
static GLint prog1;
static GLint vs1;
@@ -38,7 +43,6 @@ static GLint fs1;
static GLint prog2;
static GLint fs2;
-
static GLfloat verts[12] = {175.0, 125.0, 0.0,
175.0, 175.0, 0.0,
125.0, 125.0, 0.0,
@@ -77,17 +81,19 @@ static const char *fragShaderText2 =
-static void
-Init(void)
+void
+piglit_init(int argc, char **argv)
{
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, 400, 0, 300, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ compileLinkProg();
+
+ loadTex();
+
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
glEnable(GL_TEXTURE_2D);
glClearColor(0.6, 0.6, 0.6, 1.0);
@@ -200,8 +206,8 @@ loadTex(void)
}
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
@@ -225,42 +231,8 @@ display(void)
pass = pass && piglit_probe_pixel_rgb(132, 125, green);
pass = pass && piglit_probe_pixel_rgb(205, 125, mostlyBlack);
- if(Automatic) {
- piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- exit(pass ? 0 : 1);
- }
-
glFinish();
glutSwapBuffers();
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-
-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("glsl-fwidth");
- glutDisplayFunc(display);
- glutKeyboardFunc(piglit_escape_exit_key);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- Init();
-
- compileLinkProg();
-
- loadTex();
-
- glutMainLoop();
-
- return 0;
-}
-
diff --git a/tests/shaders/glsl-lod-bias.c b/tests/shaders/glsl-lod-bias.c
index b0a7b036..a2e3faf7 100644
--- a/tests/shaders/glsl-lod-bias.c
+++ b/tests/shaders/glsl-lod-bias.c
@@ -30,7 +30,9 @@
#include "piglit-util.h"
-static GLboolean Automatic = GL_FALSE;
+int piglit_width = 400, piglit_height = 300;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
static GLuint tex[1];
static GLint prog1;
static GLint vs1;
@@ -38,6 +40,8 @@ static GLint fs1;
static GLint prog2;
static GLint fs2;
+static void loadTex(void);
+static void compileLinkProg(void);
static GLfloat verts[12] = {175.0, 125.0, 0.0,
175.0, 175.0, 0.0,
@@ -76,18 +80,18 @@ static const char *fragShaderText2 =
-static void
-Init(void)
+void
+piglit_init(int argc, char **argv)
{
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, 400, 0, 300, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ loadTex();
+ compileLinkProg();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
glEnable(GL_TEXTURE_2D);
glClearColor(0.6, 0.6, 0.6, 1.0);
}
@@ -201,8 +205,8 @@ loadTex(void)
}
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
@@ -226,42 +230,8 @@ display(void)
pass = pass && piglit_probe_pixel_rgb(132, 125, grey);
pass = pass && piglit_probe_pixel_rgb(205, 125, green);
- if(Automatic) {
- piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- exit(pass ? 0 : 1);
- }
-
glFinish();
glutSwapBuffers();
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-
-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("glsl-lod-bias");
- glutDisplayFunc(display);
- glutKeyboardFunc(piglit_escape_exit_key);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- Init();
-
- compileLinkProg();
-
- loadTex();
-
- glutMainLoop();
-
- return 0;
-}
-
diff --git a/tests/shaders/glsl-uniform-update.c b/tests/shaders/glsl-uniform-update.c
index 2ecb291e..15d2407c 100644
--- a/tests/shaders/glsl-uniform-update.c
+++ b/tests/shaders/glsl-uniform-update.c
@@ -35,16 +35,16 @@
*/
#include "piglit-util.h"
+#include "piglit-framework.h"
-#define WIN_WIDTH 100
-#define WIN_HEIGHT 100
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static int color_location;
static GLint prog;
-static GLboolean Automatic;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
@@ -65,26 +65,20 @@ display(void)
glutSwapBuffers();
- if (Automatic) {
- piglit_report_result (pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void init(void)
+void
+piglit_init(int argc, char **argv)
{
GLint vs, fs;
- /* Set up projection matrix so we can just draw using window
- * coordinates.
- */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, WIN_WIDTH, 0, WIN_HEIGHT, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
vs = piglit_compile_shader(GL_VERTEX_SHADER,
SOURCE_DIR "tests/shaders/glsl-uniform-update.vert");
@@ -97,35 +91,3 @@ static void init(void)
color_location = glGetUniformLocation(prog, "color");
}
-
-int main(int argc, char**argv)
-{
- int i;
-
- glutInit(&argc, argv);
-
- for(i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-uniform-update");
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/glsl-unused-varying.c b/tests/shaders/glsl-unused-varying.c
index 46c9a28f..4082fc93 100644
--- a/tests/shaders/glsl-unused-varying.c
+++ b/tests/shaders/glsl-unused-varying.c
@@ -36,17 +36,16 @@
#include "piglit-util.h"
-#define WIN_WIDTH 100
-#define WIN_HEIGHT 100
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static int do_red_location;
static int red_location;
static int green_location;
static GLint prog;
-static GLboolean Automatic;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
static const float red[] = {1.0, 0.0, 0.0, 0.0};
static const float green[] = {0.0, 1.0, 0.0, 0.0};
@@ -69,26 +68,19 @@ display(void)
glutSwapBuffers();
- if (Automatic) {
- piglit_report_result (pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void init(void)
+void piglit_init(int argc, char **argv)
{
GLint vs, fs;
- /* Set up projection matrix so we can just draw using window
- * coordinates.
- */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, WIN_WIDTH, 0, WIN_HEIGHT, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
vs = piglit_compile_shader(GL_VERTEX_SHADER,
SOURCE_DIR "tests/shaders/glsl-unused-varying.vert");
@@ -103,35 +95,3 @@ static void init(void)
green_location = glGetUniformLocation(prog, "green");
do_red_location = glGetUniformLocation(prog, "do_red");
}
-
-int main(int argc, char**argv)
-{
- int i;
-
- glutInit(&argc, argv);
-
- for(i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-unused-varying");
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/glsl-vs-if-bool.c b/tests/shaders/glsl-vs-if-bool.c
index a7d0378c..49642671 100644
--- a/tests/shaders/glsl-vs-if-bool.c
+++ b/tests/shaders/glsl-vs-if-bool.c
@@ -32,15 +32,14 @@
#include "piglit-util.h"
-#define WIN_WIDTH 100
-#define WIN_HEIGHT 100
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static GLint prog;
-static GLboolean Automatic;
static int red_location;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
static const float red[] = {1.0, 0.0, 0.0, 0.0};
@@ -59,39 +58,19 @@ display(void)
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();
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-
-static void init(void)
+void piglit_init(int argc, char **argv)
{
GLint vs, fs;
- /* Set up projection matrix so we can just draw using window
- * coordinates.
- */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, WIN_WIDTH, 0, WIN_HEIGHT, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
vs = piglit_compile_shader(GL_VERTEX_SHADER,
SOURCE_DIR "tests/shaders/glsl-vs-if-bool.vert");
@@ -104,35 +83,3 @@ static void init(void)
glUseProgram(prog);
}
-
-int main(int argc, char**argv)
-{
- int i;
-
- glutInit(&argc, argv);
-
- for(i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-vs-if-bool");
- glutKeyboardFunc(key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/glsl-vs-if.c b/tests/shaders/glsl-vs-if.c
index 1babacd7..63b90dd4 100644
--- a/tests/shaders/glsl-vs-if.c
+++ b/tests/shaders/glsl-vs-if.c
@@ -32,14 +32,13 @@
#include "piglit-util.h"
-#define WIN_WIDTH 100
-#define WIN_HEIGHT 100
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static GLint prog;
-static GLboolean Automatic;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
static const float red[] = {1.0, 0.0, 0.0, 0.0};
@@ -56,39 +55,20 @@ display(void)
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();
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-
-static void init(void)
+void
+piglit_init(int argc, char **argv)
{
GLint vs, fs;
- /* Set up projection matrix so we can just draw using window
- * coordinates.
- */
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, WIN_WIDTH, 0, WIN_HEIGHT, -1, 1);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
vs = piglit_compile_shader(GL_VERTEX_SHADER,
SOURCE_DIR "tests/shaders/glsl-vs-if.vert");
@@ -99,35 +79,3 @@ static void init(void)
glUseProgram(prog);
}
-
-int main(int argc, char**argv)
-{
- int i;
-
- glutInit(&argc, argv);
-
- for(i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-vs-if");
- glutKeyboardFunc(key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/glsl-vs-loop.c b/tests/shaders/glsl-vs-loop.c
index 72ca56fe..e0fee41f 100644
--- a/tests/shaders/glsl-vs-loop.c
+++ b/tests/shaders/glsl-vs-loop.c
@@ -39,15 +39,14 @@
#include "piglit-util.h"
-#define WIN_WIDTH 100
-#define WIN_HEIGHT 100
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
static int color_location;
static GLint prog;
-static GLboolean Automatic;
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
@@ -90,26 +89,23 @@ display(void)
glutSwapBuffers();
- if (Automatic) {
- piglit_report_result (pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- }
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
-static void init(void)
+void
+piglit_init(int argc, char **argv)
{
GLint vs, fs;
/* Set up projection matrix so we can just draw using window
* coordinates.
*/
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, WIN_WIDTH, 0, WIN_HEIGHT, -1, 1);
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
vs = piglit_compile_shader(GL_VERTEX_SHADER,
SOURCE_DIR "tests/shaders/glsl-vs-loop.vert");
@@ -122,35 +118,3 @@ static void init(void)
color_location = glGetUniformLocation(prog, "color");
}
-
-int main(int argc, char**argv)
-{
- int i;
-
- glutInit(&argc, argv);
-
- for(i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "-auto"))
- Automatic = 1;
- else
- printf("Unknown option: %s\n", argv[i]);
- }
-
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("glsl-vs-loop");
- glutKeyboardFunc(piglit_escape_exit_key);
- glutDisplayFunc(display);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
- init();
-
- glutMainLoop();
-
- return 0;
-}
diff --git a/tests/shaders/trinity-fp1.c b/tests/shaders/trinity-fp1.c
index e44767af..16a3f450 100644
--- a/tests/shaders/trinity-fp1.c
+++ b/tests/shaders/trinity-fp1.c
@@ -28,6 +28,9 @@
#include "piglit-util.h"
+int piglit_width = 200, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH;
+
static GLuint TexDiffuse = 1;
static GLuint TexNormal = 2;
static GLuint TexSpecular = 3;
@@ -35,11 +38,6 @@ static GLuint TexLookup = 4;
static GLuint FragProg;
-static int Automatic = 0;
-
-static int Width = 200, Height = 100;
-
-
static void DoFrame(void)
{
static float Local[3][4] = {
@@ -129,7 +127,7 @@ static int DoTest( void )
GLfloat delta[3];
int j;
- glReadPixels(Width*(2*i+1)/4, Height/2, 1, 1, GL_RGBA, GL_FLOAT, probe);
+ glReadPixels(piglit_width*(2*i+1)/4, piglit_height/2, 1, 1, GL_RGBA, GL_FLOAT, probe);
printf("Probe: %f,%f,%f\n", probe[0], probe[1], probe[2]);
for(j = 0; j < 3; ++j) {
@@ -149,24 +147,22 @@ static int DoTest( void )
}
-static void Redisplay(void)
+enum piglit_result
+piglit_display(void)
{
int succ;
DoFrame();
succ = DoTest();
- if (Automatic) {
- printf("\nPIGLIT: { 'result': '%s' }\n", succ ? "pass" : "fail");
- exit(0);
- }
+ return succ ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
static void Reshape(int width, int height)
{
- Width = width;
- Height = height;
+ piglit_width = width;
+ piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@@ -175,22 +171,8 @@ static void Reshape(int width, int height)
glLoadIdentity();
}
-
-static void Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- pglDeleteProgramsARB(1, &FragProg);
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void Init(void)
+void
+piglit_init(int argc, char **argv)
{
GLubyte data[256][256][4];
int x,y;
@@ -262,6 +244,11 @@ static void Init(void)
"END";
+ if (!GLEW_VERSION_1_3) {
+ printf("Requires OpenGL 1.3\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
piglit_require_fragment_program();
@@ -330,31 +317,5 @@ static void Init(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
- Reshape(Width,Height);
-}
-
-
-int main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- if (argc == 2 && !strcmp(argv[1], "-auto"))
- Automatic = 1;
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
- glutCreateWindow(argv[0]);
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Redisplay);
- glewInit();
-
- if (!GLEW_VERSION_1_3) {
- printf("Requires OpenGL 1.3\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- Init();
- glutMainLoop();
- return 0;
+ Reshape(piglit_width, piglit_height);
}
diff --git a/tests/shaders/vp-bad-program.c b/tests/shaders/vp-bad-program.c
index 09fe2be5..1a891d0a 100644
--- a/tests/shaders/vp-bad-program.c
+++ b/tests/shaders/vp-bad-program.c
@@ -36,13 +36,11 @@
#include "piglit-util.h"
-static int automatic = 0;
+int piglit_width = 128, piglit_height = 128;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
-#define WIN_WIDTH 128
-#define WIN_HEIGHT 128
-
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
static const char *badprog =
"!!ARBvp1.0\n"
@@ -119,30 +117,12 @@ display(void)
err = glGetError();
}
- if (automatic) {
- if (failed == 0)
- piglit_report_result(PIGLIT_SUCCESS);
- else
- piglit_report_result(PIGLIT_FAILURE);
- }
-
- exit(0);
+ return failed ? PIGLIT_FAILURE : PIGLIT_SUCCESS;
}
-int
-main(int argc, char**argv)
+void piglit_init(int argc, char **argv)
{
- glutInit(&argc, argv);
- if (argc == 2 && !strcmp(argv[1], "-auto"))
- automatic = 1;
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
- glutInitWindowPosition(WIN_WIDTH, WIN_HEIGHT);
- glutCreateWindow("vp-bad-program");
- glutDisplayFunc(display);
+ piglit_automatic = GL_TRUE;
piglit_require_vertex_program();
-
- glutMainLoop();
- return 0;
}
diff --git a/tests/shaders/vp-ignore-input.c b/tests/shaders/vp-ignore-input.c
index 9885ad70..aeb893b9 100644
--- a/tests/shaders/vp-ignore-input.c
+++ b/tests/shaders/vp-ignore-input.c
@@ -30,7 +30,9 @@
#include "piglit-util.h"
-static GLboolean Automatic = GL_FALSE;
+int piglit_width = 400, piglit_height = 300;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
static GLint prog;
static GLint fs;
static GLint vs;
@@ -55,8 +57,8 @@ static const char *fragShaderText =
static void compileLinkProg(void);
-static void
-Init(void)
+void
+piglit_init(int argc, char **argv)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@@ -69,6 +71,11 @@ Init(void)
glClearColor(0.2, 0.2, 0.2, 1.0);
+ if (!GLEW_VERSION_2_0) {
+ printf("Requires OpenGL 2.0\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
compileLinkProg();
}
@@ -107,8 +114,8 @@ compileLinkProg(void)
}
-static void
-display(void)
+enum piglit_result
+piglit_display(void)
{
GLboolean pass = GL_TRUE;
@@ -123,37 +130,8 @@ display(void)
glPopMatrix();
- if(Automatic) {
- piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE);
- exit(pass ? 0 : 1);
- }
-
glFinish();
glutSwapBuffers();
-}
-
-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("vp-ignore-inputs");
- glutDisplayFunc(display);
- glutKeyboardFunc(piglit_escape_exit_key);
- glewInit();
-
- if (!GLEW_VERSION_2_0) {
- printf("Requires OpenGL 2.0\n");
- piglit_report_result(PIGLIT_SKIP);
- exit(1);
- }
-
- Init();
-
- glutMainLoop();
-
- return 0;
+ return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
}
diff --git a/tests/shaders/vpfp-generic.cpp b/tests/shaders/vpfp-generic.cpp
index 9e047c1a..0dd2f489 100644
--- a/tests/shaders/vpfp-generic.cpp
+++ b/tests/shaders/vpfp-generic.cpp
@@ -51,18 +51,6 @@
* [0..3].
*/
-#include <assert.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <GL/glew.h>
-#if defined(__APPLE__)
-#include <GLUT/glut.h>
-#else
-#include <GL/glut.h>
-#endif
-
#include <string>
#include <sstream>
#include <vector>