- Timestamp:
- 02/29/08 13:48:56 (4 years ago)
- Files:
-
- 1 modified
-
branches/pdfcube-0.0.3/src/pdfcube.cc (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pdfcube-0.0.3/src/pdfcube.cc
r17 r18 1 // -*- mode: C++ -*-1 // ex: set ts=2: -*- mode: C++; mode: flyspell-prog; mode: flymake; c-basic-offset: 2; indent-tabs-mode: nil -*- 2 2 // 3 3 // PDF-Cube source file - pdfcube.cc … … 18 18 // along with this program; if not, write to the Free Software 19 19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 // 21 // Notes: please indent using 2 spaces. 20 22 21 23 #include <iostream> … … 57 59 58 60 enum animation { ANIM_NONE, 59 CUBE_NEXT, CUBE_PREV,60 ZOOM0, ZOOM1, ZOOM2, ZOOM3, ZOOM4, ZOOMC,61 SWITCH_FW, SWITCH_BW61 CUBE_NEXT, CUBE_PREV, 62 ZOOM0, ZOOM1, ZOOM2, ZOOM3, ZOOM4, ZOOMC, 63 SWITCH_FW, SWITCH_BW 62 64 }; 63 65 … … 114 116 pixmap = 115 117 gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, tex_width, 116 tex_height);118 tex_height); 117 119 steps = new GLfloat[N_FRAMES]; 118 120 xsteps = new double[N_FRAMES]; … … 177 179 for (ii = 0; ii < total_pages; ++ii) { 178 180 if (page_transition[ii]) 179 section--;181 ection--; 180 182 if (section == 0) 181 break;183 break; 182 184 } 183 185 #ifndef NDEBUG … … 239 241 glHint(GL_FOG_HINT, GL_DONT_CARE); 240 242 glClearColor(fogColor[0], fogColor[1], 241 fogColor[2], fogColor[3]);243 fogColor[2], fogColor[3]); 242 244 } 243 245 … … 248 250 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); 249 251 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, 250 GL_CLAMP_TO_EDGE);252 GL_CLAMP_TO_EDGE); 251 253 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, 252 GL_CLAMP_TO_EDGE);254 GL_CLAMP_TO_EDGE); 253 255 254 256 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, 255 GL_LINEAR_MIPMAP_LINEAR);257 GL_LINEAR_MIPMAP_LINEAR); 256 258 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, 257 GL_LINEAR);259 GL_LINEAR); 258 260 259 261 update_textures(widget); … … 280 282 281 283 // up is in positive Y direction 282 gluLookAt(lookposx, lookposy, lookposz, atx, aty, atz, 0.0, 1.0, 0.0); 284 gluLookAt(lookposx, lookposy, lookposz, atx, aty, atz, 0.0, 1.0, 0.0); 283 285 284 286 matrix_setup(); … … 294 296 295 297 #ifndef NDEBUG 296 cerr << "No animation... stopping right now." <<297 endl;298 #endif 299 frame = 0;300 stop_animation(widget);301 break;298 cerr << "No animation... stopping right now." << 299 endl; 300 #endif 301 frame = 0; 302 stop_animation(widget); 303 break; 302 304 case CUBE_NEXT: 303 305 #ifndef NDEBUG 304 cerr << "cube " << frame << endl;305 #endif 306 if (frame == N_FRAMES) {307 frame = 0;308 stop_animation(widget);309 quick_reset(widget);310 } else {311 glClear(GL_COLOR_BUFFER_BIT |312 GL_DEPTH_BUFFER_BIT);313 glMatrixMode(GL_MODELVIEW);314 glLoadIdentity();315 lookposz -= zsteps[frame] * 4;316 lookposy = 6 * xsteps[frame];317 gluLookAt(lookposx, lookposy, lookposz,318 atx, aty, atz, 0, 1, 0);319 angle -= steps[frame];320 glRotatef(angle, 0.0, 1.0, 0.0);321 drawCube();322 frame++;323 }324 break;306 cerr << "cube " << frame << endl; 307 #endif 308 if (frame == N_FRAMES) { 309 frame = 0; 310 stop_animation(widget); 311 quick_reset(widget); 312 } else { 313 glClear(GL_COLOR_BUFFER_BIT | 314 GL_DEPTH_BUFFER_BIT); 315 glMatrixMode(GL_MODELVIEW); 316 glLoadIdentity(); 317 lookposz -= zsteps[frame] * 4; 318 lookposy = 6 * xsteps[frame]; 319 gluLookAt(lookposx, lookposy, lookposz, 320 atx, aty, atz, 0, 1, 0); 321 angle -= steps[frame]; 322 glRotatef(angle, 0.0, 1.0, 0.0); 323 drawCube(); 324 frame++; 325 } 326 break; 325 327 case CUBE_PREV: 326 328 #ifndef NDEBUG 327 cerr << "cube " << frame << endl;328 #endif 329 if (frame == N_FRAMES) {330 frame = 0;331 stop_animation(widget);332 quick_reset(widget);333 } else {334 glClear(GL_COLOR_BUFFER_BIT |335 GL_DEPTH_BUFFER_BIT);336 glMatrixMode(GL_MODELVIEW);337 glLoadIdentity();338 lookposz -= zsteps[frame] * 4;339 lookposy = 6 * xsteps[frame];340 gluLookAt(lookposx, lookposy, lookposz,341 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;329 cerr << "cube " << frame << endl; 330 #endif 331 if (frame == N_FRAMES) { 332 frame = 0; 333 stop_animation(widget); 334 quick_reset(widget); 335 } else { 336 glClear(GL_COLOR_BUFFER_BIT | 337 GL_DEPTH_BUFFER_BIT); 338 glMatrixMode(GL_MODELVIEW); 339 glLoadIdentity(); 340 lookposz -= zsteps[frame] * 4; 341 lookposy = 6 * xsteps[frame]; 342 gluLookAt(lookposx, lookposy, lookposz, 343 atx, aty, atz, 0, 1, 0); 344 angle -= steps[frame]; 345 glRotatef(angle, 0.0, -1.0, 0.0); 346 drawCube(); 347 frame++; 348 } 349 break; 348 350 case ZOOM0: 349 351 350 352 #ifndef NDEBUG 351 cerr << "zoom0 " << frame << endl;352 #endif 353 if (frame == N_FRAMES) {354 frame = 0;355 stop_animation(widget);356 quick_reset(widget);357 } else {358 glClear(GL_COLOR_BUFFER_BIT |359 GL_DEPTH_BUFFER_BIT);360 switch (previous_animation) {361 case ZOOM1:362 persp =363 perspsteps[(N_FRAMES - 1) -364 frame];365 atx = lookposx =366 -(1.3 *367 zoomsteps[(N_FRAMES - 1) -368 frame]);369 aty = lookposy =370 zoomsteps[(N_FRAMES - 1) -371 frame] -372 yoffset / N_FRAMES *373 ((N_FRAMES - 1) - frame);374 break;375 case ZOOM2:376 persp =377 perspsteps[(N_FRAMES - 1) -378 frame];379 atx = lookposx =380 1.3 *381 zoomsteps[(N_FRAMES - 1) -382 frame];383 aty = lookposy =384 zoomsteps[(N_FRAMES - 1) -385 frame] -386 yoffset / N_FRAMES *387 ((N_FRAMES - 1) - frame);388 break;389 case ZOOM3:390 persp =391 perspsteps[(N_FRAMES - 1) -392 frame];393 atx = lookposx =394 -1.3 *395 zoomsteps[(N_FRAMES - 1) -396 frame];397 aty = lookposy =398 -zoomsteps[(N_FRAMES - 1) -399 frame] -400 yoffset / N_FRAMES *401 ((N_FRAMES - 1) - frame);402 break;403 case ZOOM4:404 persp =405 perspsteps[(N_FRAMES - 1) -406 frame];407 atx = lookposx =408 1.3 *409 zoomsteps[(N_FRAMES - 1) -410 frame];411 aty = lookposy =412 -zoomsteps[(N_FRAMES - 1) -413 frame] -414 yoffset / N_FRAMES *415 ((N_FRAMES - 1) - frame);416 break;417 case ZOOMC:418 persp =419 perspstepsc[(N_FRAMES - 1) -420 frame];421 aty = lookposy =422 -zoomsteps[(N_FRAMES - 1) -423 frame] * 0.38;424 break;425 default:426 427 #ifndef NDEBUG 428 cerr << "Should not reach" <<429 endl;430 #endif 431 break;432 }433 glMatrixMode(GL_PROJECTION);434 glLoadIdentity();435 gluPerspective(persp, 1.0, 0.5, 10.0);436 glMatrixMode(GL_MODELVIEW);437 glLoadIdentity();438 gluLookAt(lookposx, lookposy, lookposz,439 atx, aty, atz, 0, 1, 0);440 glRotatef(angle, 0.0, 1.0, 0.0);441 drawCube();442 frame++;443 }444 break;353 cerr << "zoom0 " << frame << endl; 354 #endif 355 if (frame == N_FRAMES) { 356 frame = 0; 357 stop_animation(widget); 358 quick_reset(widget); 359 } else { 360 glClear(GL_COLOR_BUFFER_BIT | 361 GL_DEPTH_BUFFER_BIT); 362 switch (previous_animation) { 363 case ZOOM1: 364 persp = 365 perspsteps[(N_FRAMES - 1) - 366 frame]; 367 atx = lookposx = 368 -(1.3 * 369 zoomsteps[(N_FRAMES - 1) - 370 frame]); 371 aty = lookposy = 372 zoomsteps[(N_FRAMES - 1) - 373 frame] - 374 yoffset / N_FRAMES * 375 ((N_FRAMES - 1) - frame); 376 break; 377 case ZOOM2: 378 persp = 379 perspsteps[(N_FRAMES - 1) - 380 frame]; 381 atx = lookposx = 382 1.3 * 383 zoomsteps[(N_FRAMES - 1) - 384 frame]; 385 aty = lookposy = 386 zoomsteps[(N_FRAMES - 1) - 387 frame] - 388 yoffset / N_FRAMES * 389 ((N_FRAMES - 1) - frame); 390 break; 391 case ZOOM3: 392 persp = 393 perspsteps[(N_FRAMES - 1) - 394 frame]; 395 atx = lookposx = 396 -1.3 * 397 zoomsteps[(N_FRAMES - 1) - 398 frame]; 399 aty = lookposy = 400 -zoomsteps[(N_FRAMES - 1) - 401 frame] - 402 yoffset / N_FRAMES * 403 ((N_FRAMES - 1) - frame); 404 break; 405 case ZOOM4: 406 persp = 407 perspsteps[(N_FRAMES - 1) - 408 frame]; 409 atx = lookposx = 410 1.3 * 411 zoomsteps[(N_FRAMES - 1) - 412 frame]; 413 aty = lookposy = 414 -zoomsteps[(N_FRAMES - 1) - 415 frame] - 416 yoffset / N_FRAMES * 417 ((N_FRAMES - 1) - frame); 418 break; 419 case ZOOMC: 420 persp = 421 perspstepsc[(N_FRAMES - 1) - 422 frame]; 423 aty = lookposy = 424 -zoomsteps[(N_FRAMES - 1) - 425 frame] * 0.38; 426 break; 427 default: 428 429 #ifndef NDEBUG 430 cerr << "Should not reach" << 431 endl; 432 #endif 433 break; 434 } 435 glMatrixMode(GL_PROJECTION); 436 glLoadIdentity(); 437 gluPerspective(persp, 1.0, 0.5, 10.0); 438 glMatrixMode(GL_MODELVIEW); 439 glLoadIdentity(); 440 gluLookAt(lookposx, lookposy, lookposz, 441 atx, aty, atz, 0, 1, 0); 442 glRotatef(angle, 0.0, 1.0, 0.0); 443 drawCube(); 444 frame++; 445 } 446 break; 445 447 case ZOOM1: 446 448 #ifndef NDEBUG 447 cerr << "zoom1 " << frame << endl;448 #endif 449 if (frame == N_FRAMES) {450 frame = 0;451 stop_animation(widget);452 } else {453 glClear(GL_COLOR_BUFFER_BIT |454 GL_DEPTH_BUFFER_BIT);455 glMatrixMode(GL_PROJECTION);456 glLoadIdentity();457 persp = perspsteps[frame];458 gluPerspective(persp, 1.0, 0.5, 10.0);459 glMatrixMode(GL_MODELVIEW);460 glLoadIdentity();461 atx = lookposx =462 -1.3 * zoomsteps[frame];463 aty = lookposy =464 zoomsteps[frame] -465 yoffset / N_FRAMES * (frame);466 gluLookAt(lookposx, lookposy, lookposz,467 atx, aty, atz, 0, 1, 0);468 glRotatef(angle, 0.0, 1.0, 0.0);469 drawCube();470 frame++;471 }472 break;449 cerr << "zoom1 " << frame << endl; 450 #endif 451 if (frame == N_FRAMES) { 452 frame = 0; 453 stop_animation(widget); 454 } else { 455 glClear(GL_COLOR_BUFFER_BIT | 456 GL_DEPTH_BUFFER_BIT); 457 glMatrixMode(GL_PROJECTION); 458 glLoadIdentity(); 459 persp = perspsteps[frame]; 460 gluPerspective(persp, 1.0, 0.5, 10.0); 461 glMatrixMode(GL_MODELVIEW); 462 glLoadIdentity(); 463 atx = lookposx = 464 -1.3 * zoomsteps[frame]; 465 aty = lookposy = 466 zoomsteps[frame] - 467 yoffset / N_FRAMES * (frame); 468 gluLookAt(lookposx, lookposy, lookposz, 469 atx, aty, atz, 0, 1, 0); 470 glRotatef(angle, 0.0, 1.0, 0.0); 471 drawCube(); 472 frame++; 473 } 474 break; 473 475 case ZOOM2: 474 476 #ifndef NDEBUG 475 cerr << "zoom1 " << frame << endl;476 #endif 477 if (frame == N_FRAMES) {478 frame = 0;479 stop_animation(widget);480 } else {481 glClear(GL_COLOR_BUFFER_BIT |482 GL_DEPTH_BUFFER_BIT);483 glMatrixMode(GL_PROJECTION);484 glLoadIdentity();485 persp = perspsteps[frame];486 gluPerspective(persp, 1.0, 0.5, 10.0);487 glMatrixMode(GL_MODELVIEW);488 glLoadIdentity();489 atx = lookposx = 1.3 * zoomsteps[frame];490 aty = lookposy =491 zoomsteps[frame] -492 yoffset / N_FRAMES * (frame);493 gluLookAt(lookposx, lookposy, lookposz,494 atx, aty, atz, 0, 1, 0);495 glRotatef(angle, 0.0, 1.0, 0.0);496 drawCube();497 frame++;498 }499 break;477 cerr << "zoom1 " << frame << endl; 478 #endif 479 if (frame == N_FRAMES) { 480 frame = 0; 481 stop_animation(widget); 482 } else { 483 glClear(GL_COLOR_BUFFER_BIT | 484 GL_DEPTH_BUFFER_BIT); 485 glMatrixMode(GL_PROJECTION); 486 glLoadIdentity(); 487 persp = perspsteps[frame]; 488 gluPerspective(persp, 1.0, 0.5, 10.0); 489 glMatrixMode(GL_MODELVIEW); 490 glLoadIdentity(); 491 atx = lookposx = 1.3 * zoomsteps[frame]; 492 aty = lookposy = 493 zoomsteps[frame] - 494 yoffset / N_FRAMES * (frame); 495 gluLookAt(lookposx, lookposy, lookposz, 496 atx, aty, atz, 0, 1, 0); 497 glRotatef(angle, 0.0, 1.0, 0.0); 498 drawCube(); 499 frame++; 500 } 501 break; 500 502 case ZOOM3: 501 503 #ifndef NDEBUG 502 cerr << "zoom1 " << frame << endl;503 #endif 504 if (frame == N_FRAMES) {505 frame = 0;506 stop_animation(widget);507 } else {508 glClear(GL_COLOR_BUFFER_BIT |509 GL_DEPTH_BUFFER_BIT);510 glMatrixMode(GL_PROJECTION);511 glLoadIdentity();512 persp = perspsteps[frame];513 gluPerspective(persp, 1.0, 0.5, 10.0);514 glMatrixMode(GL_MODELVIEW);515 glLoadIdentity();516 atx = lookposx =517 -1.3 * zoomsteps[frame];518 aty = lookposy =519 -zoomsteps[frame] -520 yoffset / N_FRAMES * (frame);521 gluLookAt(lookposx, lookposy, lookposz,522 atx, aty, atz, 0, 1, 0);523 glRotatef(angle, 0.0, 1.0, 0.0);524 drawCube();525 frame++;526 }527 break;504 cerr << "zoom1 " << frame << endl; 505 #endif 506 if (frame == N_FRAMES) { 507 frame = 0; 508 stop_animation(widget); 509 } else { 510 glClear(GL_COLOR_BUFFER_BIT | 511 GL_DEPTH_BUFFER_BIT); 512 glMatrixMode(GL_PROJECTION); 513 glLoadIdentity(); 514 persp = perspsteps[frame]; 515 gluPerspective(persp, 1.0, 0.5, 10.0); 516 glMatrixMode(GL_MODELVIEW); 517 glLoadIdentity(); 518 atx = lookposx = 519 -1.3 * zoomsteps[frame]; 520 aty = lookposy = 521 -zoomsteps[frame] - 522 yoffset / N_FRAMES * (frame); 523 gluLookAt(lookposx, lookposy, lookposz, 524 atx, aty, atz, 0, 1, 0); 525 glRotatef(angle, 0.0, 1.0, 0.0); 526 drawCube(); 527 frame++; 528 } 529 break; 528 530 case ZOOM4: 529 531 #ifndef NDEBUG 530 cerr << "zoom1 " << frame << endl;531 #endif 532 if (frame == N_FRAMES) {533 frame = 0;534 stop_animation(widget);535 } else {536 glClear(GL_COLOR_BUFFER_BIT |537 GL_DEPTH_BUFFER_BIT);538 glMatrixMode(GL_PROJECTION);539 glLoadIdentity();540 persp = perspsteps[frame];541 gluPerspective(persp, 1.0, 0.5, 10.0);542 glMatrixMode(GL_MODELVIEW);543 glLoadIdentity();544 atx = lookposx = 1.3 * zoomsteps[frame];545 aty = lookposy =546 -zoomsteps[frame] -547 yoffset / N_FRAMES * (frame);548 gluLookAt(lookposx, lookposy, lookposz,549 atx, aty, atz, 0, 1, 0);550 glRotatef(angle, 0.0, 1.0, 0.0);551 drawCube();552 frame++;553 }554 break;532 cerr << "zoom1 " << frame << endl; 533 #endif 534 if (frame == N_FRAMES) { 535 frame = 0; 536 stop_animation(widget); 537 } else { 538 glClear(GL_COLOR_BUFFER_BIT | 539 GL_DEPTH_BUFFER_BIT); 540 glMatrixMode(GL_PROJECTION); 541 glLoadIdentity(); 542 persp = perspsteps[frame]; 543 gluPerspective(persp, 1.0, 0.5, 10.0); 544 glMatrixMode(GL_MODELVIEW); 545 glLoadIdentity(); 546 atx = lookposx = 1.3 * zoomsteps[frame]; 547 aty = lookposy = 548 -zoomsteps[frame] - 549 yoffset / N_FRAMES * (frame); 550 gluLookAt(lookposx, lookposy, lookposz, 551 atx, aty, atz, 0, 1, 0); 552 glRotatef(angle, 0.0, 1.0, 0.0); 553 drawCube(); 554 frame++; 555 } 556 break; 555 557 case ZOOMC: 556 558 #ifndef NDEBUG 557 cerr << "zoomc " << frame << endl;558 #endif 559 if (frame == N_FRAMES) {560 frame = 0;561 stop_animation(widget);562 } else {563 glClear(GL_COLOR_BUFFER_BIT |564 GL_DEPTH_BUFFER_BIT);565 persp = perspstepsc[frame];566 aty = lookposy =567 -zoomsteps[frame] * 0.38;568 glMatrixMode(GL_PROJECTION);569 glLoadIdentity();570 gluPerspective(persp, 1.0, 0.5, 10.0);571 glMatrixMode(GL_MODELVIEW);572 glLoadIdentity();573 gluLookAt(lookposx, lookposy, lookposz,574 atx, aty, atz, 0, 1, 0);575 glRotatef(angle, 0.0, 1.0, 0.0);576 drawCube();577 frame++;578 }579 break;559 cerr << "zoomc " << frame << endl; 560 #endif 561 if (frame == N_FRAMES) { 562 frame = 0; 563 stop_animation(widget); 564 } else { 565 glClear(GL_COLOR_BUFFER_BIT | 566 GL_DEPTH_BUFFER_BIT); 567 persp = perspstepsc[frame]; 568 aty = lookposy = 569 -zoomsteps[frame] * 0.38; 570 glMatrixMode(GL_PROJECTION); 571 glLoadIdentity(); 572 gluPerspective(persp, 1.0, 0.5, 10.0); 573 glMatrixMode(GL_MODELVIEW); 574 glLoadIdentity(); 575 gluLookAt(lookposx, lookposy, lookposz, 576 atx, aty, atz, 0, 1, 0); 577 glRotatef(angle, 0.0, 1.0, 0.0); 578 drawCube(); 579 frame++; 580 } 581 break; 580 582 case SWITCH_FW: 581 583 #ifndef NDEBUG 582 cerr << "fw " << frame << endl;583 #endif 584 if (frame == 1) {585 frame = 0;586 stop_animation(widget);587 } else {588 glClear(GL_COLOR_BUFFER_BIT |589 GL_DEPTH_BUFFER_BIT);590 glMatrixMode(GL_MODELVIEW);591 glLoadIdentity();592 gluLookAt(lookposx, lookposy, lookposz,593 atx, aty, atz, 0, 1, 0);594 angle -= 90;595 glRotatef(angle, 0.0, 1.0, 0.0);596 drawCube();597 frame++;598 }599 break;584 cerr << "fw " << frame << endl; 585 #endif 586 if (frame == 1) { 587 frame = 0; 588 stop_animation(widget); 589 } else { 590 glClear(GL_COLOR_BUFFER_BIT | 591 GL_DEPTH_BUFFER_BIT); 592 glMatrixMode(GL_MODELVIEW); 593 glLoadIdentity(); 594 gluLookAt(lookposx, lookposy, lookposz, 595 atx, aty, atz, 0, 1, 0); 596 angle -= 90; 597 glRotatef(angle, 0.0, 1.0, 0.0); 598 drawCube(); 599 frame++; 600 } 601 break; 600 602 case SWITCH_BW: 601 603 #ifndef NDEBUG 602 cerr << "bw " << frame << endl;603 #endif 604 if (frame == 1) {605 frame = 0;606 stop_animation(widget);607 } else {608 glClear(GL_COLOR_BUFFER_BIT |609 GL_DEPTH_BUFFER_BIT);610 glMatrixMode(GL_MODELVIEW);611 glLoadIdentity();612 gluLookAt(lookposx, lookposy, lookposz,613 atx, aty, atz, 0, 1, 0);614 angle += 90;615 glRotatef(angle, 0.0, 1.0, 0.0);616 drawCube();617 frame++;618 }619 break;604 cerr << "bw " << frame << endl; 605 #endif 606 if (frame == 1) { 607 frame = 0; 608 stop_animation(widget); 609 } else { 610 glClear(GL_COLOR_BUFFER_BIT | 611 GL_DEPTH_BUFFER_BIT); 612 glMatrixMode(GL_MODELVIEW); 613 glLoadIdentity(); 614 gluLookAt(lookposx, lookposy, lookposz, 615 atx, aty, atz, 0, 1, 0); 616 angle += 90; 617 glRotatef(angle, 0.0, 1.0, 0.0); 618 drawCube(); 619 frame++; 620 } 621 break; 620 622 } 621 623 } else { … … 623 625 case ANIM_NONE: 624 626 #ifndef NDEBUG 625 cerr << "Redrawing" << endl;626 #endif 627 break;627 cerr << "Redrawing" << endl; 628 #endif 629 break; 628 630 case CUBE_NEXT: 629 631 #ifndef NDEBUG 630 cerr << "cube stop" << endl;631 #endif 632 forward(widget);633 current_face = next_face();634 // quick_reset(widget);635 break;632 cerr << "cube stop" << endl; 633 #endif 634 forward(widget); 635 current_face = next_face(); 636 // quick_reset(widget); 637 break; 636 638 case CUBE_PREV: 637 639 #ifndef NDEBUG 638 cerr << "cube stop" << endl;639 #endif 640 backward(widget);641 current_face = prev_face();642 // quick_reset(widget);643 break;640 cerr << "cube stop" << endl; 641 #endif 642 backward(widget); 643 current_face = prev_face(); 644 // quick_reset(widget); 645 break; 644 646 case SWITCH_FW: 645 647 #ifndef NDEBUG 646 cerr << "fw stop" << endl;647 #endif 648 forward(widget);649 current_face = next_face();650 break;648 cerr << "fw stop" << endl; 649 #endif 650 forward(widget); 651 current_face = next_face(); 652 break; 651 653 case SWITCH_BW: 652 654 #ifndef NDEBUG 653 cerr << "bw stop" << endl;654 #endif 655 backward(widget);656 current_face = prev_face();657 break;655 cerr << "bw stop" << endl; 656 #endif 657 backward(widget); 658 current_face = prev_face(); 659 break; 658 660 case ZOOM0: 659 661 case ZOOM1: … … 664 666 default: 665 667 #ifndef NDEBUG 666 cerr << "default stop" << endl;667 #endif 668 break;668 cerr << "default stop" << endl; 669 #endif 670 break; 669 671 670 672 } … … 678 680 glLoadIdentity(); 679 681 gluLookAt(lookposx, lookposy, lookposz, atx, aty, atz, 680 0, 1, 0);682 0, 1, 0); 681 683 glRotatef(angle, 0.0, 1.0, 0.0); 682 684 drawCube(); … … 684 686 glRasterPos3f(0, -1.4, 0); 685 687 GLuint rcube[] = { 686 0, 0, 0, 127688 0, 0, 0, 127 687 689 }; 688 690 glDrawPixels(1, 1, GL_RGBA, GL_UNSIGNED_BYTE, rcube); … … 740 742 14, 10, 8, 6, 4, 3, 2.5, 2.0, 0.0 };*/ 741 743 742 float step_factor = 0.2 * N_FRAMES; //this is little buggy744 float step_factor = 0.2 * N_FRAMES; //this is little buggy 743 745 float step = (step_factor) / double (N_FRAMES / 2); 744 746 int i = 0; … … 746 748 steps[i] = i * step; 747 749 if (steps[i] > step_factor) 748 steps[i] = step_factor;750 steps[i] = step_factor; 749 751 } 750 752 for (i = N_FRAMES / 2; i < N_FRAMES; i++) { 751 753 steps[i] = step_factor - (i - N_FRAMES / 2) * step; 752 754 if (steps[i] < 0) 753 steps[i] = 0;755 steps[i] = 0; 754 756 } 755 757 steps[N_FRAMES - 1] = 0; … … 771 773 xsteps[i] = i * xstep; 772 774 if (xsteps[i] > xstep_ratio) 773 xsteps[i] = xstep_ratio;775 xsteps[i] = xstep_ratio; 774 776 } 775 777 for (i = N_FRAMES / 2; i < N_FRAMES; i++) { 776 778 xsteps[i] = xstep_ratio - (i - N_FRAMES / 2) * xstep; 777 779 if (xsteps[i] < 0.01) 778 xsteps[i] = 0;780 xsteps[i] = 0; 779 781 } 780 782 xsteps[N_FRAMES - 1] = 0; … … 932 934 933 935 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 934 textures[texmap[forward ? 2 : 1]]);936 textures[texmap[forward ? 2 : 1]]); 935 937 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 936 0,937 GL_RGBA,938 tex_width,939 tex_height,940 0,941 GL_RGBA,942 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap));938 0, 939 GL_RGBA, 940 tex_width, 941 tex_height, 942 0, 943 GL_RGBA, 944 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap)); 943 945 944 946 gdk_window_invalidate_rect(widget->window, &widget->allocation, 945 FALSE);947 FALSE); 946 948 947 949 } … … 955 957 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures[texmap[0]]); 956 958 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 957 0,958 GL_RGBA,959 tex_width,960 tex_height,961 0,962 GL_RGBA,963 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap));959 0, 960 GL_RGBA, 961 tex_width, 962 tex_height, 963 0, 964 GL_RGBA, 965 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap)); 964 966 965 967 render_page(pixmap, prev_page(), tex_width, tex_height); 966 968 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures[texmap[1]]); 967 969 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 968 0,969 GL_RGBA,970 tex_width,971 tex_height,972 0,973 GL_RGBA,974 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap));970 0, 971 GL_RGBA, 972 tex_width, 973 tex_height, 974 0, 975 GL_RGBA, 976 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap)); 975 977 976 978 render_page(pixmap, next_page(), tex_width, tex_height); 977 979 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textures[texmap[2]]); 978 980 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 979 0,980 GL_RGBA,981 tex_width,982 tex_height,983 0,984 GL_RGBA,985 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap));981 0, 982 GL_RGBA, 983 tex_width, 984 tex_height, 985 0, 986 GL_RGBA, 987 GL_UNSIGNED_BYTE, gdk_pixbuf_get_pixels(pixmap)); 986 988 987 989 gdk_window_invalidate_rect(widget->window, &widget->allocation, 988 FALSE);990 FALSE); 989 991 990 992 } … … 1018 1020 poppler_page_get_size(page, &w, &h); 1019 1021 poppler_page_render_to_pixbuf(page, 0, 0, iWidth, iHeight, 1020 1.0 * iWidth / w, 0, pm);1022 1.0 * iWidth / w, 0, pm); 1021 1023 } 1022 1024 … … 1027 1029 for (i = 0; i < 6; i++) { 1028 1030 if (i == current_face) { 1029 glEnable(GL_TEXTURE_RECTANGLE_ARB);1030 glBindTexture(GL_TEXTURE_RECTANGLE_ARB,1031 textures[texmap[0]]);1031 glEnable(GL_TEXTURE_RECTANGLE_ARB); 1032 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 1033 textures[texmap[0]]); 1032 1034 } else if (i == prev_face()) { 1033 glEnable(GL_TEXTURE_RECTANGLE_ARB);1034 glBindTexture(GL_TEXTURE_RECTANGLE_ARB,1035 textures[texmap[1]]);1035 glEnable(GL_TEXTURE_RECTANGLE_ARB); 1036 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 1037 textures[texmap[1]]); 1036 1038 } else if (i == next_face()) { 1037 glEnable(GL_TEXTURE_RECTANGLE_ARB);1038 glBindTexture(GL_TEXTURE_RECTANGLE_ARB,1039 textures[texmap[2]]);1039 glEnable(GL_TEXTURE_RECTANGLE_ARB); 1040 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 1041 textures[texmap[2]]); 1040 1042 } else if (i <= 3) { 1041 glDisable(GL_TEXTURE_RECTANGLE_ARB);1042 glColor4f(0.4, 0.0, 0.0, 1.0);1043 glDisable(GL_TEXTURE_RECTANGLE_ARB); 1044 glColor4f(0.4, 0.0, 0.0, 1.0); 1043 1045 } else { 1044 glDisable(GL_TEXTURE_RECTANGLE_ARB);1045 glColor4f(1.0, 1.0, 1.0, 1.0);1046 glDisable(GL_TEXTURE_RECTANGLE_ARB); 1047 glColor4f(1.0, 1.0, 1.0, 1.0); 1046 1048 } 1047 1049 glPolygonMode(GL_FRONT, GL_FILL); … … 1049 1051 // glNormal3fv(&n[i][0]); 1050 1052 glTexCoord2f((1.0 - mapping[i][4]) * tex_width, 1051 mapping[i][5] * tex_height);1053 mapping[i][5] * tex_height); 1052 1054 glVertex3fv(&v[faces[i][0]][0]); 1053 1055 1054 1056 glTexCoord2f((1.0 - mapping[i][6]) * tex_width, 1055 mapping[i][7] * tex_height);1057 mapping[i][7] * tex_height); 1056 1058 glVertex3fv(&v[faces[i][1]][0]); 1057 1059 1058 1060 glTexCoord2f((1.0 - mapping[i][0]) * tex_width, 1059 mapping[i][1] * tex_height);1061 mapping[i][1] * tex_height); 1060 1062 glVertex3fv(&v[faces[i][2]][0]); 1061 1063 1062 1064 glTexCoord2f((1.0 - mapping[i][2]) * tex_width, 1063 mapping[i][3] * tex_height);1065 mapping[i][3] * tex_height); 1064 1066 glVertex3fv(&v[faces[i][3]][0]); 1065 1067 … … 1100 1102 , 1101 1103 {1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0} 1102 , // top1104 , // top 1103 1105 {1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0} 1104 , // bottom1106 , // bottom 1105 1107 }; 1106 1108 … … 1269 1271 #ifndef NDEBUG 1270 1272 g_print("%s: \"motion_notify_event\": button", 1271 gtk_widget_get_name(widget));1273 gtk_widget_get_name(widget)); 1272 1274 if (event->state & GDK_BUTTON1_MASK) { 1273 1275 g_print(" 1"); … … 1345 1347 #endif 1346 1348 if (sleeping()) 1347 pc->section(widget, event->keyval - GDK_1 + 1);1349 pc->section(widget, event->keyval - GDK_1 + 1); 1348 1350 break; 1349 1351 … … 1381 1383 #endif 1382 1384 if (sleeping()) 1383 pc->go_to(widget, (event->keyval - GDK_1) * 5);1385 pc->go_to(widget, (event->keyval - GDK_1) * 5); 1384 1386 break; 1385 1387 … … 1390 1392 #endif 1391 1393 if (sleeping()) 1392 start_animation(widget, CUBE_PREV);1394 start_animation(widget, CUBE_PREV); 1393 1395 1394 1396 break; … … 1398 1400 #endif 1399 1401 if (sleeping()) 1400 start_animation(widget, CUBE_NEXT);1402 start_animation(widget, CUBE_NEXT); 1401 1403 break; 1402 1404 … … 1408 1410 #endif 1409 1411 if (sleeping()) 1410 start_animation(widget, SWITCH_FW);1412 start_animation(widget, SWITCH_FW); 1411 1413 break; 1412 1414 … … 1418 1420 #endif 1419 1421 if (sleeping()) 1420 start_animation(widget, SWITCH_BW);1422 start_animation(widget, SWITCH_BW); 1421 1423 break; 1422 1424 1423 1425 case GDK_g: 1424 1426 if (sleeping()) 1425 if (last_animation >=1426 ZOOM1 and last_animation <= ZOOMC)1427 start_animation(widget, ZOOM0);1427 if (last_animation >= 1428 ZOOM1 and last_animation <= ZOOMC) 1429 start_animation(widget, ZOOM0); 1428 1430 break; 1429 1431 1430 1432 case GDK_h: 1431 1433 if (sleeping()) 1432 if (last_animation >=1433 ZOOM1 and last_animation <= ZOOMC)1434 start_animation(widget, ZOOM0);1435 else1436 start_animation(widget, ZOOM1);1434 if (last_animation >= 1435 ZOOM1 and last_animation <= ZOOMC) 1436 start_animation(widget, ZOOM0); 1437 else 1438 start_animation(widget, ZOOM1); 1437 1439 break; 1438 1440 1439 1441 case GDK_j: 1440 1442 if (sleeping()) 1441 if (last_animation >=1442 ZOOM1 and last_animation <= ZOOMC)1443 start_animation(widget, ZOOM0);1444 else1445 start_animation(widget, ZOOM2);1443 if (last_animation >= 1444 ZOOM1 and last_animation <= ZOOMC) 1445 start_animation(widget, ZOOM0); 1446 else 1447 start_animation(widget, ZOOM2); 1446 1448 break; 1447 1449 1448 1450 case GDK_k: 1449 1451 if (sleeping()) 1450 if (last_animation >=1451 ZOOM1 and last_animation <= ZOOMC)1452 start_animation(widget, ZOOM0);1453 else1454 start_animation(widget, ZOOM3);1452 if (last_animation >= 1453 ZOOM1 and last_animation <= ZOOMC) 1454 start_animation(widget, ZOOM0); 1455 else 1456 start_animation(widget, ZOOM3); 1455 1457 break; 1456 1458 1457 1459 case GDK_l: 1458 1460 if (sleeping()) 1459 if (last_animation >=1460 ZOOM1 and last_animation <= ZOOMC)1461 start_animation(widget, ZOOM0);1462 else1463 start_animation(widget, ZOOM4);1461 if (last_animation >= 1462 ZOOM1 and last_animation <= ZOOMC) 1463 start_animation(widget, ZOOM0); 1464 else 1465 start_animation(widget, ZOOM4); 1464 1466 break; 1465 1467 1466 1468 case GDK_z: 1467 1469 if (sleeping()) 1468 if (last_animation >=1469 ZOOM1 and last_animation <= ZOOMC)1470 start_animation(widget, ZOOM0);1471 else1472 start_animation(widget, ZOOMC);1470 if (last_animation >= 1471 ZOOM1 and last_animation <= ZOOMC) 1472 start_animation(widget, ZOOM0); 1473 else 1474 start_animation(widget, ZOOMC); 1473 1475 break; 1474 1476 … … 1476 1478 case GDK_space: 1477 1479 if (page_transition[pc->page()]and sleeping()) 1478 start_animation(widget, CUBE_NEXT);1480 start_animation(widget, CUBE_NEXT); 1479 1481 else if (sleeping()) 1480 start_animation(widget, SWITCH_FW);1482 start_animation(widget, SWITCH_FW); 1481 1483 1482 1484 break; … … 1485 1487 case GDK_f: 1486 1488 if ((fullscreen = !fullscreen) == true) 1487 gtk_window_fullscreen((GtkWindow *) (data));1489 gtk_window_fullscreen((GtkWindow *) (data)); 1488 1490 else 1489 gtk_window_unfullscreen((GtkWindow *) (data));1491 gtk_window_unfullscreen((GtkWindow *) (data)); 1490 1492 break; 1491 1493 … … 1523 1525 if (timeout_id == 0) { 1524 1526 timeout_id = g_timeout_add(TIMEOUT_INTERVAL, 1525 (GSourceFunc) timeout, widget);1527 (GSourceFunc) timeout, widget); 1526 1528 } 1527 1529 } … … 1577 1579 gboolean 1578 1580 visibility_notify_event(GtkWidget * widget, 1579 GdkEventVisibility * event, gpointer data)1581 GdkEventVisibility * event, gpointer data) 1580 1582 { 1581 1583 if (animating) { … … 1645 1647 /* Connect signal handlers to the window */ 1646 1648 g_signal_connect(G_OBJECT(window), "delete_event", 1647 G_CALLBACK(gtk_main_quit), NULL);1649 G_CALLBACK(gtk_main_quit), NULL); 1648 1650 1649 1651 /* … … 1661 1663 drawing_area = gtk_drawing_area_new(); 1662 1664 gtk_widget_set_size_request(drawing_area, DEFAULT_WIDTH, 1663 DEFAULT_HEIGHT);1665 DEFAULT_HEIGHT); 1664 1666 1665 1667 /* Set OpenGL-capability to the widget */ 1666 1668 gtk_widget_set_gl_capability(drawing_area, 1667 glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE);1669 glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); 1668 1670 1669 1671 gtk_widget_add_events(drawing_area, 1670 GDK_BUTTON1_MOTION_MASK |1671 GDK_BUTTON2_MOTION_MASK |1672 GDK_BUTTON_PRESS_MASK |1673 GDK_VISIBILITY_NOTIFY_MASK);1672 GDK_BUTTON1_MOTION_MASK | 1673 GDK_BUTTON2_MOTION_MASK | 1674 GDK_BUTTON_PRESS_MASK | 1675 GDK_VISIBILITY_NOTIFY_MASK); 1674 1676 1675 1677 /* Connect signal handlers to the drawing area */ 1676 1678 g_signal_connect_after(G_OBJECT(drawing_area), "realize", 1677 G_CALLBACK(realize), NULL);1679 G_CALLBACK(realize), NULL); 1678 1680 g_signal_connect(G_OBJECT(drawing_area), "configure_event", 1679 G_CALLBACK(configure_event), NULL);1681 G_CALLBACK(configure_event), NULL); 1680 1682 g_signal_connect(G_OBJECT(drawing_area), "expose_event", 1681 G_CALLBACK(expose_event), NULL);1683 G_CALLBACK(expose_event), NULL); 1682 1684 g_signal_connect(G_OBJECT(drawing_area), "unrealize", 1683 G_CALLBACK(unrealize), NULL);1685 G_CALLBACK(unrealize), NULL); 1684 1686 1685 1687 g_signal_connect(G_OBJECT(drawing_area), "motion_notify_event", 1686 G_CALLBACK(motion_notify_event), NULL);1688 G_CALLBACK(motion_notify_event), NULL); 1687 1689 g_signal_connect(G_OBJECT(drawing_area), "button_press_event", 1688 G_CALLBACK(button_press_event), NULL);1690 G_CALLBACK(button_press_event), NULL); 1689 1691 1690 1692 /* key_press_event handler for top-level window */ 1691 1693 g_signal_connect_swapped(G_OBJECT(window), "key_press_event", 1692 G_CALLBACK(key_press_event), drawing_area);1694 G_CALLBACK(key_press_event), drawing_area); 1693 1695 1694 1696 /* For timeout function. */ 1695 1697 g_signal_connect(G_OBJECT(drawing_area), "map_event", 1696 G_CALLBACK(map_event), NULL);1698 G_CALLBACK(map_event), NULL); 1697 1699 g_signal_connect(G_OBJECT(drawing_area), "unmap_event", 1698 G_CALLBACK(unmap_event), NULL);1700 G_CALLBACK(unmap_event), NULL); 1699 1701 g_signal_connect(G_OBJECT(drawing_area), "visibility_notify_event", 1700 G_CALLBACK(visibility_notify_event), NULL);1702 G_CALLBACK(visibility_notify_event), NULL); 1701 1703 1702 1704 gtk_box_pack_start(GTK_BOX(vbox), drawing_area, TRUE, TRUE, 0); … … 1718 1720 /* Try double-buffered visual */ 1719 1721 glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode) 1720 (GDK_GL_MODE_RGBA |1721 GDK_GL_MODE_ALPHA |1722 GDK_GL_MODE_RGB |1723 GDK_GL_MODE_DEPTH |1724 GDK_GL_MODE_DOUBLE));1722 (GDK_GL_MODE_RGBA | 1723 GDK_GL_MODE_ALPHA | 1724 GDK_GL_MODE_RGB | 1725 GDK_GL_MODE_DEPTH | 1726 GDK_GL_MODE_DOUBLE)); 1725 1727 if (glconfig == NULL) { 1726 1728 g_print("\n*** Cannot find the double-buffered visual.\n"); … … 1729 1731 /* Try single-buffered visual */ 1730 1732 glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode) 1731 (GDK_GL_MODE_RGB |1732 GDK_GL_MODE_DEPTH));1733 (GDK_GL_MODE_RGB | 1734 GDK_GL_MODE_DEPTH)); 1733 1735 if (glconfig == NULL) { 1734 1736 g_print 1735 ("*** No appropriate OpenGL-capable visual found.\n");1737 ("*** No appropriate OpenGL-capable visual found.\n"); 1736 1738 exit(1); 1737 1739 }

