Esempio n. 1
0
void process_file(char *filename){
   SDL_Event event;
   int done = 0;
   float **space;
   int frame = 0;
   int i;
   FILE *depthfile;
   char *line = NULL;
   size_t size;
   int playing = 1;

  space = malloc(sizeof(float*) * 1000);

  depthfile = fopen(filename,"r");
  while(getline(&line, &size, depthfile) != -1){
     space[frame] = malloc(sizeof(float) * 640 * 480);

     space[frame][0] = atof(strtok(line, " "));
     for(i = 1; i < 640*480; i++){
        space[frame][i] = atof(strtok(NULL," \n"));
     }

     frame++;
  }
  fclose(depthfile);
  frame = 0;

   while(!done){
      /* Event handling */
      while( SDL_PollEvent( &event) ){
         switch(event.type){
            case SDL_KEYDOWN:
               if (event.key.keysym.sym == SDLK_ESCAPE) done=1;
               break;
            case SDL_KEYUP:
               if (event.key.keysym.sym == SDLK_SPACE) playing = !playing;
               if (event.key.keysym.sym == SDLK_LEFT)  frame--;
               if (event.key.keysym.sym == SDLK_RIGHT) frame++;
               break;
         }
      }

      draw_depth(space[frame]);

      if(playing){
printf("%d\n", frame);
         frame++;
      }

      if(frame == 1000) break;
   }

   /* Free resources */
   for(i = 0; i < frame; i++){
      free(space[i]);
   }

   free(space);

}
Esempio n. 2
0
static void draw(GLenum format, float scale)
{
	if (is_depth_format(format))
		draw_depth(scale);
	else
		draw_pixels(scale);
}
Esempio n. 3
0
enum piglit_result
piglit_display(void)
{
	GLboolean pass = GL_TRUE;
	int depth;
	GLuint tex;

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

	tex = create_3d_fbo();

	for (depth = 0; depth < NUM_DEPTHS; depth++) {
		int x = 1 + depth * (BUF_WIDTH + 1);
		int y = 1;
		draw_depth(x, y, depth);
	}

	for (depth = 0; depth < NUM_DEPTHS; depth++) {
		int x = 1 + depth * (BUF_WIDTH + 1);
		int y = 1;
		pass &= test_depth_drawing(x, y, depth_color[depth]);
	}

	glDeleteTextures(1, &tex);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}