Пример #1
0
int main(
         int argc,
         char **argv
         )
{
    glutInit(&argc, argv);
    
    // To see OpenGL drawing, take out the GLUT_DOUBLE request.
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(Window_Width, Window_Height);
    
    // Open a window 
    Window_ID = glutCreateWindow( PROGRAM_TITLE );
    
    // Register the callback function to do the drawing. 
    glutDisplayFunc(&cbRenderScene);
    
    // If there's nothing to do, draw.
    glutIdleFunc(&cbRenderScene);
    
    // It's a good idea to know when our window's resized.
    glutReshapeFunc(&cbResizeScene);
    
    // And let's get some keyboard input.
    glutKeyboardFunc(&cbKeyPressed);
    glutSpecialFunc(&cbSpecialKeyPressed);
    
    // OK, OpenGL's ready to go.  Let's call our own init function.
    ourInit(Window_Width, Window_Height);
    
    // Print out a bit of help dialog.
    printf("\n" PROGRAM_TITLE "\n\n\
           Use arrow keys to rotate, 'R' to reverse, 'S' to stop.\n\
           Page up/down will move cube away from/towards camera.\n\n\
           Use first letter of shown display mode settings to alter.\n\n\
           Q or [Esc] to quit; OpenGL window must have focus for input.\n");
    
    // Pass off control to OpenGL.
    // Above functions are called as appropriate.
    glutMainLoop();
    
    return 1;
}
Пример #2
0
// The main() function.  Inits OpenGL.  Calls our own init function,
// then passes control onto OpenGL.
int main(int argc,char **argv)
{
    if (argc < 2)
    {
        printf("Usage: %s <directory>\n", argv[0]);
        return 1;
    }

    strcpy(dirString, argv[1]);

    DIR  *dip, *dic;
    struct dirent *dit;
    int n;
    char *dir_and_file[MAX_PIC];

    if ((dip = opendir(argv[1])) == NULL || (dic = opendir(".")) == NULL)
    {
        fprintf(stderr, "can't open directory %s\n", argv[1]);
        return 1;
    }

    printid = 0;

    while((dit = readdir(dic)) != NULL)
    {
        if(strstr(dit->d_name, "out_") != NULL)
        {
            printid++;
        }
    }
    closedir(dic);

    NUM_PIC = 0;

    while ((dit = readdir(dip)) != NULL)
    {
        if(strstr(dit->d_name, ".JPG") != NULL || strstr(dit->d_name, ".jpg") != NULL || strstr(dit->d_name, ".jpeg") != NULL || strstr(dit->d_name, ".JPEG") != NULL)
        {
            dir_and_file[NUM_PIC] = malloc(100);
            strcpy(dir_and_file[NUM_PIC], argv[1]);
            strcat(dir_and_file[NUM_PIC], "/");
            strcat(dir_and_file[NUM_PIC], dit->d_name);
//       fd[NUM_PIC] = fopen(dir_and_file, "rb"); // Opens up the files in arbitiary order, no good
            NUM_PIC++;
//       printf("READ %s %d\n", dir_and_file[NUM_PIC-1], NUM_PIC - 1);
        }

    }

    n = 0;

    sort_files(dir_and_file, NUM_PIC);

//  for(n=0; n<NUM_PIC; n++);
    while(n<NUM_PIC)
    {
        fd[n] = fopen(dir_and_file[n], "rb");
//     printf("OPEN %s %d\n", dir_and_file[n], n);
        n++;
    }
    closedir(dip);


    glutInit(&argc, argv);

    // To see OpenGL drawing, take out the GLUT_DOUBLE request.
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(Window_Width, Window_Height);

    // Open a window
    Window_ID = glutCreateWindow( PROGRAM_TITLE );

    // Register the callback function to do the drawing.
    glutDisplayFunc(&cbRenderScene);

    // If there's nothing to do, draw.
    glutIdleFunc(&cbRenderScene);

    // It's a good idea to know when our window's resized.
    glutReshapeFunc(&cbResizeScene);

    // And let's get some keyboard input.
    glutKeyboardFunc(&cbKeyPressed);
    glutSpecialFunc(&cbSpecialKeyPressed);

    // Process mouse input
    glutMotionFunc(&cbMouseHeldMoving);
    glutMouseFunc(&cbMouseClick);
    glutPassiveMotionFunc(&cbMouseMoving);

    // OK, OpenGL's ready to go.  Let's call our own init function.
    ourInit(Window_Width, Window_Height);

    // Print out a bit of help dialog.
    printf("\n" PROGRAM_TITLE "\n\n\
Use arrow keys to move.\n\
Page up/down will move away from/towards camera.\n\n\
Use first letter of shown display mode settings to alter.\n\n\
Q or [Esc] to quit; OpenGL window must have focus for input.\n");

    // Pass off control to OpenGL.
    // Above functions are called as appropriate.
    glutMainLoop();

    return 1;
}
Пример #3
0
int main(int argc,char **argv)
{

   
   DIR  *dip, *dic;
   struct dirent *dit;
   int n,i;
   char *dir_and_file[2][MAX_PIC];
   
   for (i = 0; i< 2; i ++)
   {
     switch(i)
     {
     case 0: strcpy(dirString, "lf/"); break;
     case 1: strcpy(dirString, "land/"); break;
     case 2: strcpy(dirString, "path/"); break;
     default: strcpy(dirString, "lf/"); break;
     }
     
   if ((dip = opendir(dirString)) == NULL || (dic = opendir(".")) == NULL)
   {
     fprintf(stderr, "can't open directory %s\n", dirString);
     return 1;
   }
   
   
   NUM_PIC[i] = 0;
   
   while ((dit = readdir(dip)) != NULL)
   {
     if(strstr(dit->d_name, ".JPG") != NULL || strstr(dit->d_name, ".jpg") != NULL || strstr(dit->d_name, ".jpeg") != NULL || strstr(dit->d_name, ".JPEG") != NULL)
     {
       int index = NUM_PIC[i];
       dir_and_file[i][index] = malloc(100);
       strcpy(dir_and_file[i][index], dirString);
       strcat(dir_and_file[i][index], dit->d_name);
//       fd[NUM_PIC] = fopen(dir_and_file, "rb"); // Opens up the files in arbitiary order, no good
       NUM_PIC[i]++;
//       printf("READ %s %d\n", dir_and_file[NUM_PIC-1], NUM_PIC - 1);
     }

   }

   n = 0;

  sort_files(dir_and_file[i], NUM_PIC[i]);

//  for(n=0; n<NUM_PIC; n++);
   while(n<NUM_PIC[i])
   {
     fd[i][n] = fopen(dir_and_file[i][n], "rb");
//     printf("OPEN %s %d\n", dir_and_file[n], n);
     n++;
   }
   closedir(dip);

//   printf("%s %d\n", "done", NUM_PIC - 1);
 }
    
   glutInit(&argc, argv);
  

   // To see OpenGL drawing, take out the GLUT_DOUBLE request.
   glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
   glutInitWindowSize(Window_Width, Window_Height);

   // Open a window
   Window_ID = glutCreateWindow( "Light Field Viewer" );

   // Register the callback function to do the drawing.
   glutDisplayFunc(&cbRenderScene);

   // If there's nothing to do, draw.
   glutIdleFunc(&cbRenderScene);

   // It's a good idea to know when our window's resized.
   glutReshapeFunc(&cbResizeScene);


   //glutSpecialFunc(&cbSpecialKeyPressed);
   glutMouseFunc(&cbMouseClick);

   // OK, OpenGL's ready to go.  Let's call our own init function.
   ourInit(Window_Width, Window_Height);

   // Print out a bit of help dialog.
   printf("Light Field Viewer\n");

   // Pass off control to OpenGL.
   // Above functions are called as appropriate.
   glutMainLoop();

   return 1;
}