Changeset 12

Show
Ignore:
Timestamp:
02/28/08 10:15:08 (4 years ago)
Author:
sokoow
Message:

Added :
- c and a keys are animating forward and back
- code reduction - got rid of some arrays [zoom, faces]
- 30 frames animations
- solid rendering, fog
- got rid of normalization
- added quick_reset() for view update
- added blending with polygon merge workaround
- did some code cleanup

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/pdfcube-0.0.3/src/pdfcube.cc

    r11 r12  
    2525#include <cmath> 
    2626#include <cassert> 
     27#include <sstream> 
    2728 
    2829// Gtk+ (pkg-config gtk+-2.0) 
     
    3637#include <GL/gl.h> 
    3738#include <GL/glu.h> 
     39#include <GL/glx.h> 
    3840 
    3941// PDF to GdkPixbuf (pkg-config poppler-glib) 
     
    4850#define DEFAULT_HEIGHT 480 
    4951#define DEFAULT_TITLE  "PDF-Cube" 
    50  
     52#define N_FRAMES 30 
    5153#define TIMEOUT_INTERVAL 38 
    5254 
     
    5456// Globals (will be moved inside classes some day) 
    5557 
    56 static gboolean fullscreen = TRUE; 
    57 static gboolean animating = FALSE; 
    5858 
    5959enum animation { ANIM_NONE,  
    60                  CUBE,  
     60                 CUBE_NEXT, CUBE_PREV,  
    6161                 ZOOM0, ZOOM1, ZOOM2, ZOOM3, ZOOM4, ZOOMC,  
    6262                 SWITCH_FW, SWITCH_BW  
    6363}; 
    6464 
     65 
     66static gboolean fullscreen = TRUE; 
     67static gboolean animating = FALSE; 
    6568animation active_animation = ANIM_NONE; 
    6669animation previous_animation = ANIM_NONE; 
     
    7174// depending on the values in this array 
    7275static bool *page_transition; 
    73  
    74 // TODO: customize background color on command line 
    75 static float bgcolor[] = {0.4, 0.0, 0.0}; 
    76 static GdkPixbuf* cube_top = NULL; 
    77  
    7876////////////////////////////////////////////////////////////////////////// 
    7977// Forward declarations 
    8078 
     79 
    8180static void         timeout_add       (GtkWidget   *widget); 
    8281static void         timeout_remove    (GtkWidget   *widget); 
     
    8483static void         start_animation  (GtkWidget   *widget, animation); 
    8584static void         stop_animation  (GtkWidget   *widget); 
     85 
    8686 
    8787static GdkGLConfig *configure_gl      (void); 
     
    116116    pixmap =  
    117117      gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, tex_width, tex_height); 
     118      steps = new GLfloat[N_FRAMES]; 
     119      xsteps = new double[N_FRAMES]; 
     120      zsteps = new double[N_FRAMES]; 
     121      zoomsteps = new double[N_FRAMES]; 
     122      perspsteps = new double[N_FRAMES]; 
     123      perspstepsc = new double[N_FRAMES]; 
     124  } 
     125   
     126  ~pdfcube() 
     127  { 
     128    delete []steps; 
     129    delete []xsteps; 
     130    delete []zsteps; 
     131    delete []zoomsteps; 
     132    delete []perspsteps; 
     133    delete []perspstepsc; 
    118134  } 
    119135 
     
    121137 
    122138  int pages() { return total_pages; } 
    123  
     139  // Cube Normals 
     140  static GLfloat n[6][3]; 
     141  // Cube Faces 
     142  static GLint faces[6][4]; 
     143  // Cube vertex (filled in pdfcube->initialize()) 
     144  GLfloat v[8][3];   
     145  // Cube texture mapping 
     146  static GLfloat mapping[6][8]; 
     147  // Cube Rotation Animation steps (17 frames) 
     148  // Cube rotation at each frame 
     149 
     150  GLfloat *steps; 
     151  // x camera movement  
     152  double *xsteps; 
     153  // z camera movement 
     154  double *zsteps; 
     155  double *zoomsteps; 
     156  double *perspsteps; 
     157  double *perspstepsc; 
     158   
    124159  void restart(GtkWidget* widget)  
    125   { current_page = 0; update_textures(widget); } 
     160  {  
     161    current_page = 0; update_textures(widget);  
     162  } 
    126163 
    127164  void go_to(GtkWidget* widget, int page)  
     
    154191  initialize(GtkWidget *widget) 
    155192  { 
    156     glClearColor (bgcolor[0], bgcolor[1], bgcolor[2], 0.0); 
     193    GLfloat position[] = { 1.0, 1.0, 0.0, 1.0 }; 
     194    GLfloat local_view[] = { 0.0 }; 
    157195     
    158     // glEnable(GL_NORMALIZE); 
    159     glShadeModel(GL_FLAT); 
     196    glShadeModel(GL_SMOOTH); 
    160197    glEnable(GL_TEXTURE_RECTANGLE_ARB); 
    161198 
    162     // glEnable(GL_DEPTH_TEST); 
    163     // or 
    164     glEnable(GL_CULL_FACE); 
     199    GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 1.00 }; 
     200    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.00 }; 
     201    GLfloat mat_shininess[] = { 15.0 }; 
     202 
     203    glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); 
     204    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); 
     205    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); 
     206 
     207    glEnable (GL_LIGHTING); 
     208    glEnable (GL_LIGHT0); 
     209    glEnable (GL_BLEND); 
     210    glEnable (GL_CULL_FACE); 
     211    glEnable (GL_POLYGON_SMOOTH); 
     212    glPolygonMode (GL_FRONT,GL_FILL); 
     213    glEdgeFlag(GL_FALSE); 
     214 
     215    glClearColor (0.0, 0.0, 0.0, 0.5); 
    165216    glCullFace(GL_FRONT); 
     217    glDisable(GL_DEPTH_TEST); 
     218 
     219    glEnable(GL_DEPTH_TEST); 
     220    glDepthFunc(GL_LEQUAL); 
     221    glLightfv(GL_LIGHT0, GL_POSITION, position); 
     222    glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view); 
     223 
     224    glFrontFace (GL_CCW); 
     225    glEnable(GL_LIGHTING); 
     226    glEnable(GL_LIGHT0); 
     227    glEnable(GL_AUTO_NORMAL); 
     228    glEnable(GL_NORMALIZE); 
     229    glEnable(GL_FOG); 
     230    { 
     231        GLfloat fogColor[4] = {0.5, 0.5, 0.5, 0.5}; 
     232 
     233        glFogi (GL_FOG_MODE, GL_EXP); 
     234        glFogi (GL_FOG_START, 0.0); 
     235        glFogi (GL_FOG_END, 5.0); 
     236        glFogfv (GL_FOG_COLOR, fogColor); 
     237        glFogf (GL_FOG_DENSITY, 0.35); 
     238        glHint (GL_FOG_HINT, GL_DONT_CARE); 
     239        glClearColor(fogColor[0],fogColor[1],fogColor[2],fogColor[3]); 
     240    } 
    166241 
    167242    glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 
     
    208283              atx, aty, atz, 
    209284              0.0, 1.0, 0.0);      // up is in positive Y direction  
    210      
    211   } 
    212  
    213    
     285 
     286    matrix_setup();     
     287  } 
     288 
    214289   
    215290  void  
    216291  redraw(GtkWidget *widget) 
    217292  { 
    218     int frames = 17; 
     293 
    219294    double yoffset = 0.1; 
    220295    if(animating) 
     
    227302            stop_animation(widget); 
    228303            break; 
    229           case CUBE: 
     304          case CUBE_NEXT: 
    230305            cerr << "cube " << frame << endl; 
    231             if(frame == 17) 
     306            if(frame == N_FRAMES) 
    232307              { 
    233308                frame = 0; 
    234309                stop_animation(widget); 
     310                quick_reset(widget); 
    235311              }  
    236312            else  
     
    248324              } 
    249325            break; 
    250           case ZOOM0: 
    251             cerr << "zoom0 " << frame << endl; 
    252             if(frame == 17) 
     326          case CUBE_PREV: 
     327            cerr << "cube " << frame << endl; 
     328            if(frame == N_FRAMES) 
    253329              { 
    254330                frame = 0; 
    255331                stop_animation(widget); 
     332                quick_reset(widget); 
     333              }  
     334            else  
     335              { 
     336                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     337                glMatrixMode(GL_MODELVIEW); 
     338                glLoadIdentity(); 
     339                lookposz -= zsteps[frame]*4; 
     340                lookposy = 6*xsteps[frame]; 
     341                gluLookAt(lookposx, lookposy, lookposz, atx,aty,atz, 0,1,0); 
     342                angle -= steps[frame]; 
     343                glRotatef(angle, 0.0, -1.0, 0.0); 
     344                drawCube(); 
     345                frame++; 
     346              } 
     347            break; 
     348          case ZOOM0: 
     349            cerr << "zoom0 " << frame << endl; 
     350            if(frame == N_FRAMES) 
     351              { 
     352                frame = 0; 
     353                stop_animation(widget); 
     354                quick_reset(widget); 
    256355              }  
    257356            else  
     
    261360                { 
    262361                case ZOOM1: 
    263                   persp = perspsteps[16-frame]; 
    264                   atx = lookposx = -(1.3*zoomsteps[16-frame]); 
    265                   aty = lookposy = zoomsteps[16-frame] -  
    266                     yoffset/frames * (16-frame); 
     362                  persp = perspsteps[(N_FRAMES-1)-frame]; 
     363                  atx = lookposx = -(1.3*zoomsteps[(N_FRAMES-1)-frame]); 
     364                  aty = lookposy = zoomsteps[(N_FRAMES-1)-frame] -  
     365                    yoffset/N_FRAMES * ((N_FRAMES-1)-frame); 
    267366                  break; 
    268367                case ZOOM2: 
    269                   persp = perspsteps[16-frame]; 
    270                   atx = lookposx = 1.3*zoomsteps[16-frame]; 
    271                   aty = lookposy = zoomsteps[16-frame] -  
    272                     yoffset/frames * (16-frame); 
     368                  persp = perspsteps[(N_FRAMES-1)-frame]; 
     369                  atx = lookposx = 1.3*zoomsteps[(N_FRAMES-1)-frame]; 
     370                  aty = lookposy = zoomsteps[(N_FRAMES-1)-frame] -  
     371                    yoffset/N_FRAMES * ((N_FRAMES-1)-frame); 
    273372                  break; 
    274373                case ZOOM3: 
    275                   persp = perspsteps[16-frame]; 
    276                   atx = lookposx = -1.3*zoomsteps[16-frame]; 
    277                   aty = lookposy = -zoomsteps[16-frame] -  
    278                     yoffset/frames * (16-frame); 
     374                  persp = perspsteps[(N_FRAMES-1)-frame]; 
     375                  atx = lookposx = -1.3*zoomsteps[(N_FRAMES-1)-frame]; 
     376                  aty = lookposy = -zoomsteps[(N_FRAMES-1)-frame] -  
     377                    yoffset/N_FRAMES * ((N_FRAMES-1)-frame); 
    279378                  break; 
    280379                case ZOOM4: 
    281                   persp = perspsteps[16-frame]; 
    282                   atx = lookposx = 1.3*zoomsteps[16-frame]; 
    283                   aty = lookposy = -zoomsteps[16-frame] -  
    284                     yoffset/frames * (16-frame); 
     380                  persp = perspsteps[(N_FRAMES-1)-frame]; 
     381                  atx = lookposx = 1.3*zoomsteps[(N_FRAMES-1)-frame]; 
     382                  aty = lookposy = -zoomsteps[(N_FRAMES-1)-frame] -  
     383                    yoffset/N_FRAMES * ((N_FRAMES-1)-frame); 
    285384                  break; 
    286385                case ZOOMC: 
    287                   persp = perspstepsc[16-frame]; 
    288                   aty = lookposy = - zoomsteps[16-frame]*0.38; 
     386                  persp = perspstepsc[(N_FRAMES-1)-frame]; 
     387                  aty = lookposy = - zoomsteps[(N_FRAMES-1)-frame]*0.38; 
    289388                  break; 
    290389                default: 
     
    308407          case ZOOM1: 
    309408            cerr << "zoom1 " << frame << endl; 
    310             if(frame == 17) 
     409            if(frame == N_FRAMES) 
    311410              { 
    312411                frame = 0; 
     
    326425                glLoadIdentity(); 
    327426                atx = lookposx = -1.3*zoomsteps[frame]; 
    328                 aty = lookposy = zoomsteps[frame] - yoffset/frames * (frame); 
     427                aty = lookposy = zoomsteps[frame] - yoffset/N_FRAMES * (frame); 
    329428                gluLookAt(lookposx, lookposy, lookposz, atx, aty, atz, 0,1,0); 
    330429                glRotatef(angle, 0.0, 1.0, 0.0); 
     
    335434          case ZOOM2: 
    336435            cerr << "zoom1 " << frame << endl; 
    337             if(frame == 17) 
     436            if(frame == N_FRAMES) 
    338437              { 
    339438                frame = 0; 
     
    353452                glLoadIdentity(); 
    354453                atx = lookposx = 1.3*zoomsteps[frame]; 
    355                 aty = lookposy = zoomsteps[frame] - yoffset/frames * (frame); 
     454                aty = lookposy = zoomsteps[frame] - yoffset/N_FRAMES * (frame); 
    356455                gluLookAt(lookposx, lookposy, lookposz, atx, aty, atz, 0,1,0); 
    357456                glRotatef(angle, 0.0, 1.0, 0.0); 
     
    362461          case ZOOM3: 
    363462            cerr << "zoom1 " << frame << endl; 
    364             if(frame == 17) 
     463            if(frame == N_FRAMES) 
    365464              { 
    366465                frame = 0; 
     
    380479                glLoadIdentity(); 
    381480                atx = lookposx = -1.3*zoomsteps[frame]; 
    382                 aty = lookposy = -zoomsteps[frame] - yoffset/frames * (frame); 
     481                aty = lookposy = -zoomsteps[frame] - yoffset/N_FRAMES * (frame); 
    383482                gluLookAt(lookposx, lookposy, lookposz, atx, aty, atz, 0,1,0); 
    384483                glRotatef(angle, 0.0, 1.0, 0.0); 
     
    389488          case ZOOM4: 
    390489            cerr << "zoom1 " << frame << endl; 
    391             if(frame == 17) 
     490            if(frame == N_FRAMES) 
    392491              { 
    393492                frame = 0; 
     
    407506                glLoadIdentity(); 
    408507                atx = lookposx = 1.3*zoomsteps[frame]; 
    409                 aty = lookposy = -zoomsteps[frame] -yoffset/frames * (frame); 
     508                aty = lookposy = -zoomsteps[frame] -yoffset/N_FRAMES * (frame); 
    410509                gluLookAt(lookposx, lookposy, lookposz, atx, aty, atz, 0,1,0); 
    411510                glRotatef(angle, 0.0, 1.0, 0.0); 
     
    416515          case ZOOMC: 
    417516            cerr << "zoomc " << frame << endl; 
    418             if(frame == 17) 
     517            if(frame == N_FRAMES) 
    419518              { 
    420519                frame = 0; 
     
    487586            cerr << "Redrawing" << endl; 
    488587            break; 
    489           case CUBE: 
     588          case CUBE_NEXT: 
    490589            cerr << "cube stop" << endl; 
    491590            forward(widget); 
    492591            current_face = next_face(); 
     592//          quick_reset(widget); 
     593            break; 
     594          case CUBE_PREV: 
     595            cerr << "cube stop" << endl; 
     596            backward(widget); 
     597            current_face = prev_face(); 
     598//          quick_reset(widget); 
    493599            break; 
    494600          case SWITCH_FW: 
     
    515621 
    516622        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     623//      glClear(GL_COLOR_BUFFER_BIT); 
    517624        glMatrixMode(GL_PROJECTION); 
    518625        glLoadIdentity(); 
     
    536643         
    537644        cerr << "Ok!" << endl; 
    538       }     
     645        glFlush(); 
     646      } 
    539647  } 
    540648 
     
    571679    cerr << "Current page: " << current_page << endl; 
    572680  } 
     681   
     682  void matrix_setup() 
     683  { 
     684/*GLfloat pdfcube::steps[N_FRAMES] =  
     685  {  2.0,   2.5,   3,     4,     5,     6,     8,     10,    
     686     14,   10,   8,    6,    4,    3,    2.5,   2.0, 0.0  };*/ 
     687 
     688    float step_factor = 0.2*N_FRAMES; //this is little buggy 
     689    float step = (step_factor)/double(N_FRAMES/2); 
     690    int i=0; 
     691    for (i=0;i<N_FRAMES/2;i++) 
     692    { 
     693    steps[i]=i*step; 
     694    if(steps[i]>step_factor) steps[i]=step_factor; 
     695    } 
     696    for (i=N_FRAMES/2;i<N_FRAMES;i++) 
     697    { 
     698    steps[i]=step_factor-(i-N_FRAMES/2)*step; 
     699    if(steps[i]<0) steps[i]=0; 
     700    }     
     701    steps[N_FRAMES-1]=0; 
     702        cout << "Step " << step << endl; 
     703        cout << "Matrix "; 
     704        for (i=0;i<N_FRAMES;i++) cout << steps[i] << " "; 
     705        cout << endl; 
     706         
     707/*double pdfcube::xsteps[N_FRAMES] =  
     708  {  0.01,  0.03,  0.07,  0.12,  0.16,  0.18,  0.20,  0.21,  
     709     0.21, 0.20, 0.18, 0.16, 0.12, 0.07, 0.03, 0.01, 0.00 };*/ 
     710         
     711    float xstep_ratio = 0.4; 
     712    float xstep = double(xstep_ratio-0.01)/double(N_FRAMES/2); 
     713    for (i=0;i<N_FRAMES/2;i++) 
     714    { 
     715    xsteps[i]=i*xstep; 
     716    if(xsteps[i]>xstep_ratio) xsteps[i]=xstep_ratio; 
     717    } 
     718    for (i=N_FRAMES/2;i<N_FRAMES;i++) 
     719    { 
     720    xsteps[i]=xstep_ratio-(i-N_FRAMES/2)*xstep; 
     721    if(xsteps[i]<0.01) xsteps[i]=0; 
     722    } 
     723    xsteps[N_FRAMES-1]=0; 
     724 
     725        cout << "Step x " << xstep << endl; 
     726        cout << "Matrix2 "; 
     727        for (i=0;i<N_FRAMES;i++) cout << xsteps[i] << " "; 
     728        cout << endl; 
     729 
     730/*double pdfcube::zsteps[N_FRAMES] =  
     731  { -0.01, -0.02, -0.04, -0.05, -0.04, -0.02, -0.02, -0.01,  
     732    0.01, 0.02, 0.02, 0.04, 0.05, 0.04, 0.02, 0.01, 0.00 };*/ 
     733 
     734    float granular = 0.07; 
     735    float zstep = granular/double(N_FRAMES/4); 
     736    for (i=0;i<N_FRAMES/4;i++) 
     737    { 
     738    zsteps[i]=-i*zstep; 
     739    } 
     740    for (i=N_FRAMES/4;i<N_FRAMES/2;i++) 
     741    { 
     742    zsteps[i]=-granular+(i-N_FRAMES/4)*zstep; 
     743    }     
     744    for (i=N_FRAMES/2;i<N_FRAMES;i++) 
     745    { 
     746    zsteps[i]=-zsteps[i-N_FRAMES/2]; 
     747    } 
     748    zsteps[N_FRAMES-1]=0; 
     749        cout << "Step z " << zstep << endl; 
     750        cout << "Matrix3 "; 
     751        for (i=0;i<N_FRAMES;i++) cout << zsteps[i] << " "; 
     752        cout << endl; 
     753 
     754/*double pdfcube::zoomsteps[N_FRAMES] = 
     755  { 0.00, 0.01, 0.02, 0.03, 0.05, 0.07, 0.10, 0.13, 0.17,  
     756    0.21, 0.25, 0.29, 0.32, 0.35, 0.37, 0.38, 0.38 };*/ 
     757 
     758    float zoomstop = 0.38; 
     759    float zoomstep = (zoomstop/double(N_FRAMES)); 
     760    for (i=0;i<N_FRAMES;i++) 
     761    { 
     762    zoomsteps[i]=i*zoomstep; 
     763    } 
     764    zoomsteps[N_FRAMES-1]= zoomstop; 
     765        cout << "Step zoom " << zoomstep << endl; 
     766        cout << "Matrix4 "; 
     767        for (i=0;i<N_FRAMES;i++) cout << zoomsteps[i] << " "; 
     768        cout << endl; 
     769 
     770/*double pdfcube::perspsteps[N_FRAMES] = 
     771  { 44.0, 44.0, 44.0, 44.00, 44.00, 43.00, 42.00, 40.00,  
     772    38.00, 36.00, 33.00, 30.00, 27.00, 24.00, 22.00, 21.00, 21.00 };*/ 
     773 
     774    float perspstart = 44.00; 
     775    float perspstop = 21.00; 
     776    float perspstep = (perspstart-perspstop)/double(N_FRAMES); 
     777    for (i=0;i<N_FRAMES;i++) 
     778    { 
     779    perspsteps[i]=perspstart-i*perspstep; 
     780    } 
     781    perspsteps[0]=perspstart; 
     782    perspsteps[N_FRAMES-1]=perspstop; 
     783        cout << "Step persp " << perspstep << endl; 
     784        cout << "Matrix5 "; 
     785        for (i=0;i<N_FRAMES;i++) cout << perspsteps[i] << " "; 
     786        cout << endl; 
     787 
     788 
     789/*double pdfcube::perspstepsc[N_FRAMES] = 
     790    { 44.0, 44.0, 44.0, 44.00, 44.00, 43.00, 42.00, 40.00,  
     791    38.00, 36.00, 34.00, 32.00, 31.00, 30.00, 30.00, 30.00, 30.00 };*/ 
     792    float perspcstart = 44.00; 
     793    float perspcstop = 30.00; 
     794    float perspcstep = (perspcstart-perspcstop)/double(N_FRAMES/2); 
     795    for (i=0;i<N_FRAMES/4;i++) perspstepsc[i]=perspcstart; 
     796 
     797    for (i=N_FRAMES/4;i<3*(N_FRAMES/4);i++) 
     798    { 
     799    perspstepsc[i]=perspcstart-i*perspcstep; 
     800    } 
     801    for (i=3*(N_FRAMES/4);i<N_FRAMES;i++) perspstepsc[i]=perspcstop; 
     802        cout << "Step perspc " << perspcstep << endl; 
     803        cout << "Matrix6 "; 
     804        for (i=0;i<N_FRAMES;i++) cout << perspstepsc[i] << " "; 
     805        cout << endl; 
     806 
     807   } 
    573808   
    574809  void 
     
    597832    last_animation = ANIM_NONE; 
    598833    update_textures(widget); 
     834  } 
     835 
     836  void 
     837  quick_reset(GtkWidget *widget) 
     838  { 
     839    animating = FALSE; 
     840    frame = 0;  
     841    lookposx = 0.0; 
     842    lookposy = 0.0; 
     843    lookposz = 3.48;  
     844    atx = 0.0; 
     845    aty = 0.0; 
     846    atz = 0.0; 
     847    persp = 44.0;  
     848    angle = 0.0; 
     849    current_face = 0; 
     850    active_animation = ANIM_NONE; 
     851    previous_animation = ANIM_NONE; 
     852    last_animation = ANIM_NONE; 
     853//    update_textures(widget); 
    599854  } 
    600855 
     
    711966  static const gint tex_height = (gint)(3*768/2); 
    712967 
    713   // Cube Normals 
    714   static const GLfloat n[6][3]; 
    715   // Cube Faces 
    716   static const GLint faces[6][4]; 
    717   // Cube vertex (filled in pdfcube->initialize()) 
    718   GLfloat v[8][3];   
    719   // Cube texture mapping 
    720   static const GLfloat mapping[6][8]; 
    721   // Cube Rotation Animation steps (17 frames) 
    722   // Cube rotation at each frame 
    723   static const GLfloat steps[17]; 
    724   // x camera movement  
    725   static const double xsteps[17]; 
    726   // z camera movement 
    727   static const double zsteps[17]; 
    728   static const double zoomsteps[17]; 
    729   static const double perspsteps[17]; 
    730   static const double perspstepsc[17]; 
    731968 
    732969  void  
    733970  render_page(GdkPixbuf* pm, int i, gint iWidth, gint iHeight) 
    734971  { 
    735     PopplerPage *page = NULL; 
     972    PopplerPage *page; 
    736973    page = poppler_document_get_page(doc, i); 
    737     assert(page); 
    738974    double w, h; 
    739975    poppler_page_get_size(page, &w, &h); 
     
    7731009            glColor4f(1.0, 1.0, 1.0, 1.0); 
    7741010          } 
     1011       glPolygonMode (GL_FRONT,GL_FILL); 
    7751012        glBegin(GL_QUADS); 
    776         glNormal3fv(&n[i][0]); 
     1013//      glNormal3fv(&n[i][0]); 
    7771014        glTexCoord2f((1.0-mapping[i][4]) * tex_width,  
    7781015                     mapping[i][5] * tex_height);  
     
    7961033}; 
    7971034 
    798 const GLfloat pdfcube::n[6][3] = {  
     1035GLfloat pdfcube::n[6][3] = {  
    7991036  {0.0, 0.0, -1.0}, {1.0, 0.0, 0.0}, {0.0, 0.0, 1.0},  {-1.0, 0.0, 0.0},   
    8001037  {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0} 
    8011038}; 
    802 const GLint pdfcube::faces[6][4] = { 
     1039GLint pdfcube::faces[6][4] = { 
    8031040  {7, 4, 0, 3}, {7, 6, 5, 4}, {5, 6, 2, 1}, {0, 1, 2, 3},  
    8041041  {3, 2, 6, 7}, {4, 5, 1, 0} 
    8051042}; 
    806 const GLfloat pdfcube::mapping[6][8] = { 
     1043GLfloat pdfcube::mapping[6][8] = { 
    8071044    {1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0},  
    8081045    {0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0},  
     
    8121049    {1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0}, // bottom 
    8131050}; 
    814 const GLfloat pdfcube::steps[17] =  
    815   {  2.0,   2.5,   3,     4,     5,     6,     8,     10,    
    816      14,   10,   8,    6,    4,    3,    2.5,   2.0, 0.0  }; 
    817 const double pdfcube::xsteps[17] =  
    818   {  0.01,  0.03,  0.07,  0.12,  0.16,  0.18,  0.20,  0.21,  
    819      0.21, 0.20, 0.18, 0.16, 0.12, 0.07, 0.03, 0.01, 0.00 }; 
    820 const double pdfcube::zsteps[17] =  
    821   { -0.01, -0.02, -0.04, -0.05, -0.04, -0.02, -0.02, -0.01,  
    822     0.01, 0.02, 0.02, 0.04, 0.05, 0.04, 0.02, 0.01, 0.00 }; 
    823 const double pdfcube::zoomsteps[17] = 
    824   { 0.00, 0.01, 0.02, 0.03, 0.05, 0.07, 0.10, 0.13, 0.17,  
    825     0.21, 0.25, 0.29, 0.32, 0.35, 0.37, 0.38, 0.38 }; 
    826 const double pdfcube::perspsteps[17] = 
    827   { 44.0, 44.0, 44.0, 44.00, 44.00, 43.00, 42.00, 40.00,  
    828     38.00, 36.00, 33.00, 30.00, 27.00, 24.00, 22.00, 21.00, 21.00 }; 
    829 const double pdfcube::perspstepsc[17] = 
    830   { 44.0, 44.0, 44.0, 44.00, 44.00, 43.00, 42.00, 40.00,  
    831     38.00, 36.00, 34.00, 32.00, 31.00, 30.00, 30.00, 30.00, 30.00 }; 
    8321051 
    8331052pdfcube* pc; 
     1053 
     1054 
    8341055 
    8351056////////////////////////////////////////////////////////////////////////// 
     
    11001321        // Animated Cube Advancement 
    11011322      case GDK_a: 
     1323        g_print ("a key\n"); 
     1324        if(sleeping()) 
     1325          start_animation(widget, CUBE_PREV); 
     1326 
     1327        break; 
    11021328      case GDK_c: 
    11031329        g_print ("c key\n"); 
    11041330        if(sleeping()) 
    1105           start_animation(widget, CUBE); 
     1331          start_animation(widget, CUBE_NEXT); 
    11061332        break; 
    11071333         
     
    11741400      case GDK_space: 
    11751401        if(page_transition[pc->page()] and sleeping()) 
    1176           start_animation(widget, CUBE); 
     1402          start_animation(widget, CUBE_NEXT); 
    11771403        else if(sleeping()) 
    11781404          start_animation(widget, SWITCH_FW); 
     
    14151641  glconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode) 
    14161642                                        ( 
    1417                                          GDK_GL_MODE_RGB   | 
     1643                                         GDK_GL_MODE_RGBA    | 
     1644                                         GDK_GL_MODE_ALPHA  | 
     1645                                         GDK_GL_MODE_RGB  | 
    14181646                                         GDK_GL_MODE_DEPTH  | 
    14191647                                         GDK_GL_MODE_DOUBLE)); 
     
    15001728      cerr << "Errore nel nome del file" << endl; 
    15011729    } 
    1502  
    1503   GError* g = NULL; 
    15041730  PopplerDocument* document =  
    1505     poppler_document_new_from_file(filename_uri, NULL, &g); 
    1506    
    1507   if(g && g->code) 
    1508     { 
    1509       perror(g->message); 
    1510       exit(2); 
    1511     } 
     1731    poppler_document_new_from_file(filename_uri, NULL, NULL); 
    15121732 
    15131733  if(document == NULL)