Ejemplo n.º 1
0
void ToggleAutomaticSlideshow()
{

     float icon_z = frame.vz-6.5;
     if ( icon_z < -5 ) { icon_z = -4.5; }


     if ( frame.transitions.automatic_slideshow_on==0 )
      {
          SoundLibrary_PlaySound(SLIDESHOW_START);
          SetDestinationOverPicture(frame.active_image_place);
          frame.time_ms_before_last_slide_change=frame.tick_count;
          frame.transitions.automatic_slideshow_on=1;
          Add_3DObject(//0,0,0,
                       frame.vx,frame.vy,icon_z,
                       //frame.vx,frame.vy,frame.vz,
                       5,5,/*PLAY*/ 3 ,1000000);

      } else
      {
          SoundLibrary_PlaySound(SLIDESHOW_STOP);
          frame.transitions.automatic_slideshow_on=0;
          Add_3DObject(//0,0,0,
                       frame.vx,frame.vy,icon_z,
                       //frame.vx,frame.vy,frame.vz,
                       5,5,/*PAUSE*/ 4 ,1000000);
      }
}
Ejemplo n.º 2
0
int make_texture(struct Picture * picturedata,int enable_mipmaping)
{

	if ( picturedata == 0 ) { fprintf(stderr,"Error making texture from picture , accomodation structure is not allocated\n");
	                          return 0; }

    unsigned long this_texture = picturedata->width * picturedata->height * /*RGBA ->*/ 4 /* <- RGBA*/ ;
    if ( !GPU_Memory_can_accomodate(this_texture) ) {
                                                      fprintf(stderr,"Abort making texture , GPU cant accomodate it ( %u KB ) \n",(unsigned int) this_texture/1024);
                                                      SignalGPUFull=1;
                                                      return 0;
                                                    }



    glEnable(GL_TEXTURE_2D);

     PrintDirectoryListItem(picturedata->directory_list_index);

     GLuint new_tex_id=0;
     if (PrintOpenGLDebugMsg()) fprintf(stderr,"OpenGL Generating new Texture \n");
     glGenTextures(1,&new_tex_id);
     if ( complain_about_errors() ) { return 0; }

     if (PrintOpenGLDebugMsg()) fprintf(stderr,"OpenGL Binding new Texture \n");
     glBindTexture(GL_TEXTURE_2D,new_tex_id);
     if ( complain_about_errors() ) { return 0; }
     glFlush();

    picturedata->gpu.gl_rgb_texture=new_tex_id;


    unsigned int depth_flag=GL_RGB;
    char * rgba_data = picturedata->system.rgb_data;

/* RGBA Software conversion for debugging :p   HAS ANOTHER PART (line 150+ ) THAT DOES THE FREE CALL
    rgba_data = (char*) malloc(picturedata->width*picturedata->height*4*sizeof(unsigned char));
    if (rgba_data==0)
      {
       rgba_data = picturedata->rgb_data;
      } else
      {
       depth_flag=GL_RGBA;
       software_add_alpha_channel(picturedata->rgb_data,rgba_data,picturedata->width,picturedata->height);
       fprintf(stderr,"Using Alpha texture conversion\n");
      }
*/
  unsigned int error_num=0;

  if ( ( enable_mipmaping == 1 ) || ( frame.force_mipmap_generation ==1 ) )
   {
      /* LOADING TEXTURE --WITH-- MIPMAPING */
      glPixelStorei(GL_UNPACK_ALIGNMENT,1);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);                      // GL_RGB
      glTexImage2D(GL_TEXTURE_2D, 0, depth_flag, picturedata->width , picturedata->height, 0, depth_flag, GL_UNSIGNED_BYTE, (const GLvoid *) rgba_data);
      error_num=glGetError();
      if  ( error_num!=0 ) { printoutOGLErr(error_num); fprintf(stderr,"Creating texture %ux%u:%u ( initial %ux%u )\n",picturedata->width,picturedata->height,depth_flag,picturedata->initial_width,picturedata->initial_height); return 0; }
   } else
   {
      /* LOADING TEXTURE --WITHOUT-- MIPMAPING - IT IS LOADED RAW*/
      glPixelStorei(GL_UNPACK_ALIGNMENT,1);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);                       //GL_RGB
      glTexImage2D(GL_TEXTURE_2D, 0, depth_flag, picturedata->width , picturedata->height, 0, depth_flag, GL_UNSIGNED_BYTE,(const GLvoid *) rgba_data);
      error_num=glGetError();
      if  ( error_num!=0 ) { printoutOGLErr(error_num); fprintf(stderr,"Creating texture %ux%u:%u ( initial %ux%u )\n",picturedata->width,picturedata->height,depth_flag,picturedata->initial_width,picturedata->initial_height); return 0; }
   }

/* RGBA Software conversion for debugging :p HAS A PREVIOUS PART
   if ( (rgba_data != 0)&&(depth_flag=GL_RGBA) )  { free(rgba_data); }
*/


   if (enable_mipmaping)
    {
     if (PrintDevMsg()) fprintf(stderr,"Using mipmaps there is a lot more memory consumption , needs work..\n");
    }





    /* PICTURE IS LOADED IN GPU SO WE CAN UNLOAD IT FROM MAIN RAM MEMORY */
      if ( picturedata->system.rgb_data != 0 )
        {
          frame.system.usedRAM-=picturedata->system.rgb_data_size;
          free(picturedata->system.rgb_data);
          picturedata->system.rgb_data=0;
          picturedata->system.rgb_data_size=0;
        }

    frame.gpu.lastTexture=this_texture;
    frame.gpu.usedRAM+=frame.gpu.lastTexture;

    picturedata->gpu.texture_data_size=this_texture;
    picturedata->gpu.marked_for_texture_loading=0;
    picturedata->gpu.texture_loaded=1;

    if ( complain_about_errors() ) { return 0; }

    if (PrintOpenGLDebugMsg()) fprintf(stderr,"OpenGL Texture of size ( %u %u ) id is %u\n", picturedata->width , picturedata->height,picturedata->gpu.gl_rgb_texture);

    glFlush();

         SoundLibrary_PlaySound(LOADED_PICTURE);
    return 1;
}