Exemplo n.º 1
0
void ourInit(
             int Width,
             int Height
             ) 
{
    ourBuildTextures();   
    
    // Color to clear color buffer to.
    glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
    
    // Depth to clear depth buffer to; type of test.
    glClearDepth(1.0);
    glDepthFunc(GL_LESS); 
    
    // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun.
    glShadeModel(GL_SMOOTH);
    
    // Load up the correct perspective matrix; using a callback directly.
    cbResizeScene(Width,Height);
    
    // Set up a light, turn it on.
    glLightfv(GL_LIGHT1, GL_POSITION, Light_Position);
    glLightfv(GL_LIGHT1, GL_AMBIENT,  Light_Ambient);
    glLightfv(GL_LIGHT1, GL_DIFFUSE,  Light_Diffuse); 
    glEnable (GL_LIGHT1); 
    
    // A handy trick -- have surface material mirror the color.
    glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_COLOR_MATERIAL);
}
Exemplo n.º 2
0
// Does everything needed before losing control to the main
// OpenGL event loop.
void ourInit(int Width, int Height)
{
    int n,i;

    struct jpeg_decompress_struct cinfo;
    struct jpeg_error_mgr jerr;
    JSAMPROW row_pointer[1];
    unsigned long location = 0;

    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_decompress(&cinfo);


    for (n = 0; n<NUM_PIC; n++)
    {
        jpeg_stdio_src(&cinfo, fd[n]);
        jpeg_read_header(&cinfo, 0);
        cinfo.scale_num = 1;
        cinfo.scale_denom = SCALE;
        jpeg_start_decompress(&cinfo);
        wid[n] = cinfo.output_width;
        hei[n] = cinfo.output_height;
        dep[n] = cinfo.num_components; //should always be 3
        image[n] = (unsigned char *) malloc(wid[n] * hei[n] * dep[n]);
        row_pointer[0] = (unsigned char *) malloc(wid[n] * dep[n]);
        /* read one scan line at a time */
        while( cinfo.output_scanline < cinfo.output_height )
        {
            jpeg_read_scanlines( &cinfo, row_pointer, 1 );
            for( i=0; i< (wid[n] * dep[n]); i++)
                image[n][location++] = row_pointer[0][i];
        }
        location = 0;
        fclose(fd[n]);
        jpeg_finish_decompress(&cinfo);
    }

    jpeg_destroy_decompress(&cinfo);

    ourBuildTextures();

    // Color to clear color buffer to.
    glClearColor(0.1f, 0.1f, 0.1f, 0.0f);

    // Depth to clear depth buffer to; type of test.
    glClearDepth(1.0);
    glDepthFunc(GL_LESS);

    // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun.
    glShadeModel(GL_SMOOTH);

    // Load up the correct perspective matrix; using a callback directly.
    cbResizeScene(Width,Height);

    // Set up a light, turn it on.
    glLightfv(GL_LIGHT1, GL_POSITION, Light_Position);
    glLightfv(GL_LIGHT1, GL_AMBIENT,  Light_Ambient);
    glLightfv(GL_LIGHT1, GL_DIFFUSE,  Light_Diffuse);
    glEnable (GL_LIGHT1);

    // A handy trick -- have surface material mirror the color.
    glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_COLOR_MATERIAL);

}
Exemplo n.º 3
0
void ourInit(int Width, int Height)
{
   int n,i,j;

  loadOffsets();

  struct jpeg_decompress_struct cinfo;
  struct jpeg_error_mgr jerr;
  JSAMPROW row_pointer[1];
  unsigned long location = 0;

  cinfo.err = jpeg_std_error(&jerr);
  jpeg_create_decompress(&cinfo);

  for (i = 0; i<2; i++)
  for (n = 0; n<NUM_PIC[i]; n++)
  {
    jpeg_stdio_src(&cinfo, fd[i][n]);
    jpeg_read_header(&cinfo, 0);
    cinfo.scale_num = 1;
    cinfo.scale_denom = SCALE;
    jpeg_start_decompress(&cinfo);
    wid[i][n] = cinfo.output_width;
    hei[i][n] = cinfo.output_height;
    dep[i][n] = cinfo.num_components; //should always be 3
    image[i][n] = (unsigned char *) malloc(wid[i][n] * hei[i][n] * dep[i][n]);
    row_pointer[0] = (unsigned char *) malloc(wid[i][n] * dep[i][n]);
    /* read one scan line at a time */
    while( cinfo.output_scanline < cinfo.output_height )
    {
        jpeg_read_scanlines( &cinfo, row_pointer, 1 );
        for( j=0; j< (wid[i][n] * dep[i][n]); j++)
                image[i][n][location++] = row_pointer[0][j];
    }
    location = 0;
    fclose(fd[i][n]);
    jpeg_finish_decompress(&cinfo);
  }

  jpeg_destroy_decompress(&cinfo);

  ourBuildTextures();


   // Color to clear color buffer to.
   glClearColor(0.1f, 0.1f, 0.1f, 0.0f);

   // Depth to clear depth buffer to; type of test.
   glClearDepth(1.0);
   glDepthFunc(GL_LESS);

   // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun.
   glShadeModel(GL_SMOOTH);

   // Load up the correct perspective matrix; using a callback directly.
   cbResizeScene(Width,Height);

   // Set up a light, turn it on.
   glLightfv(GL_LIGHT1, GL_POSITION, Light_Position);
   glLightfv(GL_LIGHT1, GL_AMBIENT,  Light_Ambient);
//   glLightfv(GL_LIGHT1, GL_DIFFUSE,  Light_Diffuse);
   glEnable (GL_LIGHT1);

   // A handy trick -- have surface material mirror the color.
   glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
   glEnable(GL_COLOR_MATERIAL);
   
   glutSetCursor(GLUT_CURSOR_NONE);
   

      glEnable(GL_TEXTURE_RECTANGLE_ARB);


      glDisable(GL_LIGHTING);
      glEnable(GL_LIGHTING);

       glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    // If we're blending, we don't want z-buffering.

       glDisable(GL_DEPTH_TEST);
       glEnable(GL_BLEND);



       glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,
                                           GL_NEAREST_MIPMAP_NEAREST);
       glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
  
   
}