aboutsummaryrefslogtreecommitdiff
path: root/tests/shaders/glsl-vs-if-bool.c
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/glsl-vs-if-bool.c
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/glsl-vs-if-bool.c')
-rw-r--r--tests/shaders/glsl-vs-if-bool.c75
1 files changed, 11 insertions, 64 deletions
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;
-}