static GLboolean
draw_and_test(const char *destination, int drawable_width, int drawable_height)
{
	const GLfloat red[4] = {1.0, 0.0, 0.0, 0.0};
	const GLfloat green[4] = {0.0, 1.0, 0.0, 0.0};
	const GLfloat blue[4] = {0.0, 0.0, 1.0, 0.0};
	int i;
	int center_x_start = (drawable_width - fdo_bitmap_width) / 2;
	int center_y_start = (drawable_height - fdo_bitmap_height) / 2;
	int start_x, start_y;
	struct probes probes;
	GLboolean pass = GL_TRUE;

	memset(&probes, 0, sizeof(probes));

	/* Set up projection matrix so we can just draw using window
	 * coordinates.
	 */
	glViewport(0, 0, drawable_width, drawable_height);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, drawable_width, 0, drawable_height, -1, 1);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	/* Clear to black */
	glClearColor(0, 0, 0, 0);
	glClear(GL_COLOR_BUFFER_BIT);
	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	glColor4fv(red);
	/* Center: full image */
	glRasterPos2f(center_x_start, center_y_start);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "center full", red,
		  center_x_start, center_y_start,
		  fdo_bitmap_width, fdo_bitmap_height,
		  0, 0);

	glEnable(GL_SCISSOR_TEST);
	glColor4fv(green);
	/* Left clipped */
	start_x = center_x_start - fdo_bitmap_width - 10;
	start_y = center_y_start;
	glScissor(start_x + fdo_bitmap_width / 4,
		  start_y,
		  fdo_bitmap_width,
		  fdo_bitmap_height);
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "left glscissor clipped area", NULL,
		  start_x, start_y,
		  fdo_bitmap_width / 4, fdo_bitmap_height,
		  0, 0);
	add_probe(&probes, "left glscissor unclipped area", green,
		  start_x + fdo_bitmap_width / 4, start_y,
		  fdo_bitmap_width * 3 / 4, fdo_bitmap_height,
		  fdo_bitmap_width / 4, 0);

	/* Right clipped */
	start_x = center_x_start + fdo_bitmap_width + 10;
	start_y = center_y_start;
	glScissor(start_x,
		  start_y,
		  fdo_bitmap_width * 3 / 4,
		  fdo_bitmap_height);
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "right glscissor clipped area", NULL,
		  start_x + fdo_bitmap_width * 3 /4,
		  start_y,
		  fdo_bitmap_width / 4,
		  fdo_bitmap_height,
		  0, 0);
	add_probe(&probes, "right glscissor unclipped area", green,
		  start_x, start_y,
		  fdo_bitmap_width * 3 / 4, fdo_bitmap_height,
		  0, 0);

	/* Top clipped */
	start_x = center_x_start;
	start_y = center_y_start + fdo_bitmap_height + 10;
	glScissor(start_x,
		  start_y,
		  fdo_bitmap_width,
		  fdo_bitmap_height * 3 / 4);
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "top glscissor clipped area", NULL,
		  start_x,
		  start_y + fdo_bitmap_height * 3 /4,
		  fdo_bitmap_width,
		  fdo_bitmap_height / 4,
		  0, 0);
	add_probe(&probes, "top glscissor unclipped area", green,
		  start_x, start_y,
		  fdo_bitmap_width, fdo_bitmap_height * 3 / 4,
		  0, 0);

	/* Bottom clipped */
	start_x = center_x_start;
	start_y = center_y_start - fdo_bitmap_height - 10;
	glScissor(start_x,
		  start_y + fdo_bitmap_height / 4,
		  fdo_bitmap_width,
		  fdo_bitmap_height);
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "bottom glscissor clipped area", NULL,
		  start_x, start_y,
		  fdo_bitmap_width, fdo_bitmap_height / 4,
		  0, 0);
	add_probe(&probes, "bottom glscissor unclipped area", green,
		  start_x, start_y + fdo_bitmap_height / 4,
		  fdo_bitmap_width, fdo_bitmap_height * 3 / 4,
		  0, fdo_bitmap_height / 4);

	glDisable(GL_SCISSOR_TEST);
	glColor4fv(blue);
	/* Left side of drawable (not drawn due to invalid pos) */
	start_x = -fdo_bitmap_width / 4;
	start_y = center_y_start;
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "left drawable clipped area", NULL,
		  start_x + fdo_bitmap_width / 4, start_y,
		  fdo_bitmap_width * 3 / 4, fdo_bitmap_height,
		  fdo_bitmap_width / 4, 0);
	/* Right side of drawable */
	start_x = drawable_width - fdo_bitmap_width * 3 / 4;
	start_y = center_y_start;
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "right drawable unclipped area", blue,
		  start_x, start_y,
		  fdo_bitmap_width * 3 / 4, fdo_bitmap_height,
		  0, 0);

	/* Top of drawable */
	start_x = center_x_start;
	start_y = drawable_height - fdo_bitmap_height * 3 / 4;
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "top drawable unclipped area", blue,
		  start_x, start_y,
		  fdo_bitmap_width, fdo_bitmap_height * 3 / 4,
		  0, 0);
	/* Bottom of drawable (not drawn due to invalid pos) */
	start_x = center_x_start;
	start_y = -fdo_bitmap_height / 4;
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "bottom drawable clipped area", NULL,
		  start_x, start_y,
		  fdo_bitmap_width, fdo_bitmap_height * 3 / 4,
		  0, 0);

	for (i = 0; i < probes.n_probes; i++)
		pass &= verify_bitmap_contents(&probes,
					       drawable_width, drawable_height,
					       i);

	return pass;
}
示例#2
0
enum piglit_result
piglit_display()
{
	const GLfloat red[4] = {1.0, 0.0, 0.0, 0.0};
	const GLfloat green[4] = {0.0, 1.0, 0.0, 0.0};
	const GLfloat blue[4] = {0.0, 0.0, 1.0, 0.0};
	int i;
	int center_x_start = (piglit_width - fdo_bitmap_width) / 2;
	int center_y_start = (piglit_height - fdo_bitmap_height) / 2;
	int start_x, start_y;
	struct probes probes;
	GLboolean pass = GL_TRUE;
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	memset(&probes, 0, sizeof(probes));

	glClearColor(0, 0, 0, 0);
	glClear(GL_COLOR_BUFFER_BIT);

	glColor4fv(red);
	/* Center: full image */
	glRasterPos2f(center_x_start, center_y_start);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "center full", red,
		  center_x_start, center_y_start,
		  fdo_bitmap_width, fdo_bitmap_height,
		  0, 0);

	glEnable(GL_SCISSOR_TEST);
	glColor4fv(green);
	/* Left clipped */
	start_x = center_x_start - fdo_bitmap_width - 10;
	start_y = center_y_start;
	glScissor(start_x + fdo_bitmap_width / 4,
		  start_y,
		  fdo_bitmap_width,
		  fdo_bitmap_height);
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "left glscissor clipped area", NULL,
		  start_x, start_y,
		  fdo_bitmap_width / 4, fdo_bitmap_height,
		  0, 0);
	add_probe(&probes, "left glscissor unclipped area", green,
		  start_x + fdo_bitmap_width / 4, start_y,
		  fdo_bitmap_width * 3 / 4, fdo_bitmap_height,
		  fdo_bitmap_width / 4, 0);

	/* Right clipped */
	start_x = center_x_start + fdo_bitmap_width + 10;
	start_y = center_y_start;
	glScissor(start_x,
		  start_y,
		  fdo_bitmap_width * 3 / 4,
		  fdo_bitmap_height);
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "right glscissor clipped area", NULL,
		  start_x + fdo_bitmap_width * 3 /4,
		  start_y,
		  fdo_bitmap_width / 4,
		  fdo_bitmap_height,
		  0, 0);
	add_probe(&probes, "right glscissor unclipped area", green,
		  start_x, start_y,
		  fdo_bitmap_width * 3 / 4, fdo_bitmap_height,
		  0, 0);

	/* Top clipped */
	start_x = center_x_start;
	start_y = center_y_start + fdo_bitmap_height + 10;
	glScissor(start_x,
		  start_y,
		  fdo_bitmap_width,
		  fdo_bitmap_height * 3 / 4);
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "top glscissor clipped area", NULL,
		  start_x,
		  start_y + fdo_bitmap_height * 3 /4,
		  fdo_bitmap_width,
		  fdo_bitmap_height / 4,
		  0, 0);
	add_probe(&probes, "top glscissor unclipped area", green,
		  start_x, start_y,
		  fdo_bitmap_width, fdo_bitmap_height * 3 / 4,
		  0, 0);

	/* Bottom clipped */
	start_x = center_x_start;
	start_y = center_y_start - fdo_bitmap_height - 10;
	glScissor(start_x,
		  start_y + fdo_bitmap_height / 4,
		  fdo_bitmap_width,
		  fdo_bitmap_height);
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "bottom glscissor clipped area", NULL,
		  start_x, start_y,
		  fdo_bitmap_width, fdo_bitmap_height / 4,
		  0, 0);
	add_probe(&probes, "bottom glscissor unclipped area", green,
		  start_x, start_y + fdo_bitmap_height / 4,
		  fdo_bitmap_width, fdo_bitmap_height * 3 / 4,
		  0, fdo_bitmap_height / 4);

	glDisable(GL_SCISSOR_TEST);
	glColor4fv(blue);
	/* Left side of window (not drawn due to invalid pos) */
	start_x = -fdo_bitmap_width / 4;
	start_y = center_y_start;
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "left window clipped area", NULL,
		  start_x + fdo_bitmap_width / 4, start_y,
		  fdo_bitmap_width * 3 / 4, fdo_bitmap_height,
		  fdo_bitmap_width / 4, 0);
	/* Right side of window */
	start_x = piglit_width - fdo_bitmap_width * 3 / 4;
	start_y = center_y_start;
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "right window unclipped area", blue,
		  start_x, start_y,
		  fdo_bitmap_width * 3 / 4, fdo_bitmap_height,
		  0, 0);

	/* Top of window */
	start_x = center_x_start;
	start_y = piglit_height - fdo_bitmap_height * 3 / 4;
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "top window unclipped area", blue,
		  start_x, start_y,
		  fdo_bitmap_width, fdo_bitmap_height * 3 / 4,
		  0, 0);
	/* Bottom of window (not drawn due to invalid pos) */
	start_x = center_x_start;
	start_y = -fdo_bitmap_height / 4;
	glRasterPos2f(start_x, start_y);
	glBitmap(fdo_bitmap_width, fdo_bitmap_height, 0, 0, 0, 0, fdo_bitmap);
	add_probe(&probes, "bottom window clipped area", NULL,
		  start_x, start_y,
		  fdo_bitmap_width, fdo_bitmap_height * 3 / 4,
		  0, 0);

	for (i = 0; i < probes.n_probes; i++) {
		pass = pass && verify_bitmap_contents(&probes, i);
	}

	glutSwapBuffers();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}