From 4cfbe82bc3278321a90d30cc768f09525bd68328 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 29 Sep 2009 14:43:41 -0700 Subject: 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. --- tests/shaders/glsl-vs-if-bool.c | 75 ++++++----------------------------------- 1 file changed, 11 insertions(+), 64 deletions(-) (limited to 'tests/shaders/glsl-vs-if-bool.c') 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; -} -- cgit v1.2.3