[Piglit] [PATCH 02/23] texline: Convert to use piglit framework
Chad Versace
chad.versace at linux.intel.com
Fri Sep 28 10:44:48 PDT 2012
This test was oldschool. It rolled its own main with a handful of GLUT
functions. This patch converts it to use the PIGLIT_GL_TEST_MAIN macro.
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
tests/mesa/tests/texline.c | 83 +++++++++++++++++-----------------------------
1 file changed, 30 insertions(+), 53 deletions(-)
diff --git a/tests/mesa/tests/texline.c b/tests/mesa/tests/texline.c
index 1c99953..726c51f 100644
--- a/tests/mesa/tests/texline.c
+++ b/tests/mesa/tests/texline.c
@@ -12,14 +12,17 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
-#include <GL/glut.h>
-#include "../util/readtex.h"
-#include "../util/writeimg.h"
+
+#include "piglit-util-gl-common.h"
+#include "readtex.h"
+#include "writeimg.h"
#define TEXTURE_FILE "mesa/girl.rgb"
-static int Width = 400, Height = 300;
-static int Automatic = 0;
+PIGLIT_GL_TEST_MAIN(400 /*window_width*/,
+ 300 /*window_height*/,
+ GLUT_RGB | GLUT_DOUBLE);
+
static const char* ScreenshotFile = 0;
static void DoStar(int texture)
@@ -124,22 +127,25 @@ static void Screenshot(void)
WritePNGImage(ScreenshotFile, GL_RGB, 400, 300, (GLubyte*)shot, 1);
}
-static void Display(void)
+enum piglit_result
+piglit_display(void)
{
DoFrame();
- if (Automatic) {
+ if (piglit_automatic) {
Screenshot();
- printf("PIGLIT: { }\n");
- exit(0);
+ return PIGLIT_SKIP;
+ } else {
+ return PIGLIT_PASS;
}
}
static void Reshape(int width, int height)
{
- Width = width;
- Height = height;
- glViewport(0, 0, Width, Height);
+ piglit_width = width;
+ piglit_height = height;
+
+ glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 4.0, 0.0, 3.0, -1.0, 1.0);
@@ -147,22 +153,20 @@ static void Reshape(int width, int height)
glLoadIdentity();
}
-
-static void Key( unsigned char key, int x, int y )
+void
+piglit_init(int argc, char **argv)
{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- exit(0);
- break;
+ GLuint u;
+
+ if (argc == 1) {
+ ScreenshotFile = argv[1];
+ } else {
+ printf("usage error\n");
+ piglit_report_result(PIGLIT_FAIL);
}
-}
+ glutReshapeFunc(Reshape);
-static void Init( int argc, char *argv[] )
-{
- GLuint u;
for (u = 0; u < 2; u++) {
char filename[256];
@@ -187,9 +191,7 @@ static void Init( int argc, char *argv[] )
strcpy(filename, TEXTURE_FILE);
if (!LoadRGBMipmaps(filename, GL_RGB)) {
printf("Error: couldn't load texture image\n");
- if (Automatic)
- printf("PIGLIT: {'result': 'fail' }\n");
- exit(1);
+ piglit_report_result(PIGLIT_FAIL);
}
}
@@ -200,30 +202,5 @@ static void Init( int argc, char *argv[] )
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
- Reshape(Width, Height);
-}
-
-
-int main( int argc, char *argv[] )
-{
- glutInit( &argc, argv );
- if (argc == 3 && !strcmp(argv[1], "-auto")) {
- Automatic = 1;
- ScreenshotFile = argv[2];
- }
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
-
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
-
- glutCreateWindow("texline");
-
- Init(argc, argv);
-
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Display);
-
- glutMainLoop();
- return 0;
+ Reshape(piglit_width, piglit_height);
}
--
1.7.12.1
More information about the Piglit
mailing list