summaryrefslogtreecommitdiff
path: root/tests/bugs/fdo9833.c
blob: c14c0a6577fe3500b2c485b89e351873e7d1bed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
 * Test case from fd.o bug #9833.
 * https://bugs.freedesktop.org/show_bug.cgi?id=9833
 */

#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>

static int Automatic = 0;

static void display(void)
{
	static int goterrors = 0;
	static int frame = 0;
	GLuint error;

	frame++;
	glClear(GL_COLOR_BUFFER_BIT);

	glPushAttrib(GL_TEXTURE_BIT);
	while ( (error = glGetError()) != GL_NO_ERROR) {
		fprintf(stderr, "OpenGL error 0x%0x occured after glPushAttrib!\n", error);
		goterrors++;
	}


	glPopAttrib();
	while ( (error = glGetError()) != GL_NO_ERROR) {
		fprintf(stderr, "OpenGL error 0x%0x occured after glPopAttrib!\n", error);
		goterrors++;
	}

	if (Automatic && frame > 2) {
		printf("PIGLIT: {'result': '%s' }\n", goterrors ? "fail" : "pass");
		exit(0);
	}

	glutPostRedisplay();
}

int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	if (argc == 2 && !strcmp(argv[1], "-auto"))
		Automatic = 1;
	glutCreateWindow("fdo9833");
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}