예제 #1
0
enum piglit_result
test_clearing(void)
{
   static const GLfloat purple[] = {1.0, 0.0, 1.0};
   static const GLfloat blue[] = {0.0, 0.0, 1.0};
   static const GLfloat green[] = {0.0, 1.0, 0.0};
   GLenum err;
   GLboolean pass = GL_TRUE;

   while (glGetError() != GL_NO_ERROR)
      ;

   /* Front buffer. */
   glDrawBuffer(GL_FRONT);
   glClearBufferfv(GL_COLOR, 0, purple);
   err = glGetError();
   if (err) {
      printf("%s: glClearBufferfv(GL_FRONT) generated error 0x%x.\n", Prog, err);
      return PIGLIT_FAIL;
   }

   glReadBuffer(GL_FRONT);
   if (!piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, purple)) {
      printf("  from glClearBufferfv(GL_FRONT) failed.\n");
      pass = GL_FALSE;
   }

   /* Back buffer. */
   glDrawBuffer(GL_BACK);
   glClearBufferfv(GL_COLOR, 0, blue);
   err = glGetError();
   if (err) {
      printf("%s: glClearBufferfv(GL_BACK) generated error 0x%x.\n", Prog, err);
      return PIGLIT_FAIL;
   }

   glReadBuffer(GL_BACK);
   if (!piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, blue)) {
      printf("  from glClearBufferfv(GL_BACK) failed.\n");
      pass = GL_FALSE;
   }

   /* Front and back buffer. */
   glDrawBuffer(GL_FRONT_AND_BACK);
   glClearBufferfv(GL_COLOR, 0, green);
   err = glGetError();
   if (err) {
      printf("%s: glClearBufferfv(GL_FRONT_AND_BACK) generated error 0x%x.\n", Prog, err);
      return PIGLIT_FAIL;
   }

   glReadBuffer(GL_FRONT);
   if (!piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, green)) {
      printf("  the front buffer from glClearBufferfv(GL_FRONT_AND_BACK) failed.\n");
      pass = GL_FALSE;
   }

   glReadBuffer(GL_BACK);
   if (!piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, green)) {
      printf("  the back buffer from glClearBufferfv(GL_FRONT_AND_BACK) failed.\n");
      pass = GL_FALSE;
   }

   /* Depth & Stencil */
   glClearBufferfi(GL_DEPTH_STENCIL, 0, 0.5, 3);
   err = glGetError();
   if (err) {
      printf("%s: glClearBufferfi() generated error 0x%x.\n", Prog, err);
      return PIGLIT_FAIL;
   }

   if (!piglit_probe_rect_depth(0, 0, piglit_width, piglit_height, 0.5)) {
      printf("  from glClearBufferfi() failed.\n");
      pass = GL_FALSE;
   }

   if (!piglit_probe_rect_stencil(0, 0, piglit_width, piglit_height, 3)) {
      printf("  from glClearBufferfi() failed.\n");
      pass = GL_FALSE;
   }

   return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
예제 #2
0
PIGLIT_GL_TEST_CONFIG_END

enum piglit_result
piglit_display(void)
{
	GLint i, j;
	GLuint width = 16, height = 16;
	GLint x = 12, y = 12;
	GLfloat buf[IMAGE_WIDTH][IMAGE_HEIGHT];
	GLfloat depth_val = 0.75, stencil_val = 2.0;
	GLfloat green[4] = {0.0, 1.0, 0.0, 0.0};
	bool pass = true;

	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	glColor4fv(green);
	piglit_draw_rect(0, 0, width, height);

	glRasterPos2i(x, y);
	glCopyPixels(0, 0, width, height, GL_COLOR);
	pass = pass && piglit_probe_rect_rgba(x, y, width, height, green);

	/* Initialize depth data */
	for (i = 0; i < IMAGE_HEIGHT; i++) {
		for(j = 0; j < IMAGE_WIDTH; j++)
			buf[i][j] = depth_val;
	}

	glClearDepth(0.0);
	glClear(GL_DEPTH_BUFFER_BIT);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_ALWAYS);

	glRasterPos2i(0, 0);
	glDrawPixels(width, height,
		     GL_DEPTH_COMPONENT, GL_FLOAT, buf);
	glRasterPos2i(x, y);
	glCopyPixels(0, 0, width, height, GL_DEPTH);
	pass = piglit_probe_rect_depth(x, y, width, height, depth_val)
	       && pass;

	/* Initialize stencil data */
	for (i = 0; i < IMAGE_HEIGHT; i++) {
		for(j = 0; j < IMAGE_WIDTH; j++)
			buf[i][j] = stencil_val;
	}

	glClearStencil(0.0);
	glClear(GL_STENCIL_BUFFER_BIT);

	glRasterPos2i(0, 0);
	glDrawPixels(width, height,
		     GL_STENCIL_INDEX, GL_FLOAT, buf);
	glRasterPos2i(x, y);
	glCopyPixels(0, 0, width, height, GL_STENCIL);
	pass = piglit_probe_rect_stencil(x, y, width, height, stencil_val)
	       && pass;

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}