enum piglit_result
piglit_display(void)
{
	GLboolean pass = GL_TRUE;
	int dim;
	GLuint tex;
	int x;
	float blend[] = {0.5, 0.5, 0.0, 1.0};

	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT);

	tex = create_tex();

	x = 1;
	for (dim = TEX_WIDTH; dim > 1; dim /= 2) {
		draw_mipmap(x, 1, dim);
		x += dim + 1;
	}

	x = 1;
	for (dim = TEX_WIDTH; dim > 1; dim /= 2) {
		if (dim < TEX_WIDTH / 4) {
			pass &= piglit_probe_rect_rgba(x, 1, dim, dim,
						       blend);
		}

		x += dim + 1;
	}

	glDeleteTextures(1, &tex);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Example #2
0
static enum piglit_result
test_format(const struct format_desc *format)
{
	int dim;
	GLuint tex;
	int x;
	int level;
	GLboolean pass = GL_TRUE;

	printf("Testing %s", format->name);

	if (clear_stencil && format->base_internal_format != GL_DEPTH_STENCIL) {
		printf(" - no stencil.\n");
		return PIGLIT_SKIP;
	}

	tex = create_tex(format->internalformat, format->base_internal_format);
	if (tex == 0) {
		printf(" - FBO incomplete\n");
		piglit_report_subtest_result(PIGLIT_SKIP,
					     "%s (fbo incomplete)",
					     format->name);
		return PIGLIT_SKIP;
	}
	printf("\n");

	if (clear_stencil) {
		glClearStencil(0x0);
		glClear(GL_STENCIL_BUFFER_BIT);
	}

	glViewport(0, 0, piglit_width, piglit_height);
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	x = 1;
	level = 0;
	for (dim = TEX_WIDTH; dim > 1; dim /= 2) {
		if (clear_stencil)
			draw_stencil_mipmap(x, 1, dim, tex, level);
		else
			draw_mipmap(x, 1, dim);
		x += dim + 1;
		level++;
	}

	if (clear_stencil)
		visualize_stencil();

	x = 1;
	level = 0;
	for (dim = TEX_WIDTH; dim > 1; dim /= 2) {
		pass = pass && test_mipmap_drawing(x, 1, dim, level,
						   format->internalformat);
		x += dim + 1;
		level++;
	}

	glDeleteTextures(1, &tex);

	piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,
				     format->name);
	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Example #3
0
int main(int argc, char **argv)
{
    int flags = SDL_OPENGL;
    int bpp = 0;
    int carry_on = 1;
    Uint32 c_frame = 0;
    Uint32 interval;
    Uint32 start_t, last_t, curr_t;
    Uint32 rendered_frames = 0;
    SDL_Surface *screen;
    GLuint bg, bird;
    SDL_Event selection;
	const SDL_VideoInfo* info = NULL;

    initialise();

    info = SDL_GetVideoInfo();
	bpp = info->vfmt->BitsPerPixel;

    screen = SDL_SetVideoMode(MAP_W, MAP_H, bpp, flags); 
    if(!screen){
        fprintf(stderr, "Failed to open screen!\n");
        return 1;
    }
    create_tex("images/sky.png", &bg);
    create_tex("images/bird.png", &bird);


   /* paint section */

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0, MAP_W,
           MAP_H, 0, -1, 1);
   //glViewport(0.0, 0.0,
    //       MAP_W, MAP_H);
   


   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();

   glEnable(GL_TEXTURE_2D);
   glBindTexture(GL_TEXTURE_2D, bg);

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glTranslatef(0, 0, 0);

   glBegin(GL_QUADS);

   glTexCoord2f(0.0, 0.0);
   glVertex3f(0, 0, 0);

   glTexCoord2f(0.0, 1.0);
   glVertex3f(0, MAP_H, 0);

   glTexCoord2f(1.0, 1.0);
   glVertex3f(MAP_W, MAP_H, 0);

   glTexCoord2f(1.0, 0.0);
   glVertex3f(MAP_W, 0 , 0);

   glEnd();
   
   /*
   glBindTexture(GL_TEXTURE_2D, bird);

   glBegin(GL_QUADS);

   glTexCoord2f(0.0, 0.0);
   glVertex3f(0, 0, 0);

   glTexCoord2f(0.0, 1.0);
   glVertex3f(0, BIRD_H, 0);

   glTexCoord2f(1.0, 1.0);
   glVertex3f(BIRD_W, BIRD_H, 0);

   glTexCoord2f(1.0, 0.0);
   glVertex3f(BIRD_W, 0 , 0);

   glEnd();
*/
   glDisable(GL_TEXTURE_2D);

   glFlush();
   SDL_GL_SwapBuffers();

   start_t = last_t = SDL_GetTicks();
   while(carry_on){

       while(SDL_PollEvent(&selection)){
           if(selection.type == SDL_QUIT){
               carry_on = 0;
           }
       }

       curr_t = SDL_GetTicks();
       if(floor((double)(curr_t - start_t) /1000. * FPS) > c_frame){
      //     c_frame = floor((double)(curr_t - start_t) / 1000. * FPS);
           c_frame++;
           paint(bg, 0, MAP_W, MAP_H, curr_t);
           paint(bird, 0.1, BIRD_W, BIRD_H, curr_t);
           rendered_frames++;
       }
       glFlush();
       SDL_GL_SwapBuffers();
           
   }

   fprintf(stdout, "frames: %d\n", rendered_frames);
   fprintf(stdout, "seconds: %d \n", (curr_t - start_t) / 1000);
   fprintf(stderr, "FPS: %f\n", (float)rendered_frames/((float)(curr_t - start_t) / 1000));

   return 0;

}