ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/test.C
(Generate patch)

Comparing libgender/test.C (file contents):
Revision 1.1 by root, Sat Oct 2 12:10:40 2004 UTC vs.
Revision 1.2 by root, Sat Oct 2 15:54:43 2004 UTC

11#define SHADED_CUBE 11#define SHADED_CUBE
12 12
13/* Define this to be the name of the logo image to use with -logo */ 13/* Define this to be the name of the logo image to use with -logo */
14#define LOGO_FILE "icon.bmp" 14#define LOGO_FILE "icon.bmp"
15 15
16/* The SDL_OPENGLBLIT interface is deprecated.
17 The code is still available for benchmark purposes though.
18*/
19
20static SDL_bool USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
21
22static SDL_Surface *global_image = NULL; 16static SDL_Surface *global_image = NULL;
23static GLuint global_texture = 0; 17static GLuint global_texture = 0;
18
19#include "entity.h"
24 20
25/**********************************************************************/ 21/**********************************************************************/
26 22
27void 23void
28HotKey_ToggleFullScreen (void) 24HotKey_ToggleFullScreen (void)
355 int w = 640; 351 int w = 640;
356 int h = 480; 352 int h = 480;
357 int done = 0; 353 int done = 0;
358 int frames; 354 int frames;
359 Uint32 start_time, this_time; 355 Uint32 start_time, this_time;
356 Uint32 video_flags;
360 int value; 357 int value;
361 358
362 if (SDL_Init (SDL_INIT_VIDEO) < 0) 359 if (SDL_Init (SDL_INIT_VIDEO) < 0)
363 { 360 {
364 fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); 361 fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ());
376 { 373 {
377 bpp = 16; /* More doesn't seem to work */ 374 bpp = 16; /* More doesn't seem to work */
378 } 375 }
379 } 376 }
380 377
381 /* Set the flags we want to use for setting the video mode */
382 if (logo && USE_DEPRECATED_OPENGLBLIT)
383 {
384 video_flags = SDL_OPENGLBLIT;
385 }
386 else
387 {
388 video_flags = SDL_OPENGL; 378 video_flags = SDL_OPENGL;
389 } 379
390 for (i = 1; argv[i]; ++i) 380 for (i = 1; argv[i]; ++i)
391 { 381 {
392 if (strcmp (argv[1], "-fullscreen") == 0) 382 if (strcmp (argv[1], "-fullscreen") == 0)
393 { 383 {
394 video_flags |= SDL_FULLSCREEN; 384 video_flags |= SDL_FULLSCREEN;
501 glClearColor (0.0, 0.0, 0.0, 1.0); 491 glClearColor (0.0, 0.0, 0.0, 1.0);
502 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 492 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
503 493
504 glBegin (GL_QUADS); 494 glBegin (GL_QUADS);
505 495
506#ifdef SHADED_CUBE
507 glColor3fv (color[0]);
508 glVertex3fv (cube[0]);
509 glColor3fv (color[1]);
510 glVertex3fv (cube[1]);
511 glColor3fv (color[2]);
512 glVertex3fv (cube[2]);
513 glColor3fv (color[3]);
514 glVertex3fv (cube[3]);
515
516 glColor3fv (color[3]);
517 glVertex3fv (cube[3]);
518 glColor3fv (color[4]);
519 glVertex3fv (cube[4]);
520 glColor3fv (color[7]);
521 glVertex3fv (cube[7]);
522 glColor3fv (color[2]);
523 glVertex3fv (cube[2]);
524
525 glColor3fv (color[0]);
526 glVertex3fv (cube[0]);
527 glColor3fv (color[5]);
528 glVertex3fv (cube[5]);
529 glColor3fv (color[6]);
530 glVertex3fv (cube[6]);
531 glColor3fv (color[1]);
532 glVertex3fv (cube[1]);
533
534 glColor3fv (color[5]);
535 glVertex3fv (cube[5]);
536 glColor3fv (color[4]);
537 glVertex3fv (cube[4]);
538 glColor3fv (color[7]);
539 glVertex3fv (cube[7]);
540 glColor3fv (color[6]);
541 glVertex3fv (cube[6]);
542
543 glColor3fv (color[5]);
544 glVertex3fv (cube[5]);
545 glColor3fv (color[0]);
546 glVertex3fv (cube[0]);
547 glColor3fv (color[3]);
548 glVertex3fv (cube[3]);
549 glColor3fv (color[4]);
550 glVertex3fv (cube[4]);
551
552 glColor3fv (color[6]);
553 glVertex3fv (cube[6]);
554 glColor3fv (color[1]);
555 glVertex3fv (cube[1]);
556 glColor3fv (color[2]);
557 glVertex3fv (cube[2]);
558 glColor3fv (color[7]);
559 glVertex3fv (cube[7]);
560#else // flat cube
561 glColor3f (1.0, 0.0, 0.0);
562 glVertex3fv (cube[0]);
563 glVertex3fv (cube[1]);
564 glVertex3fv (cube[2]);
565 glVertex3fv (cube[3]);
566
567 glColor3f (0.0, 1.0, 0.0);
568 glVertex3fv (cube[3]);
569 glVertex3fv (cube[4]);
570 glVertex3fv (cube[7]);
571 glVertex3fv (cube[2]);
572
573 glColor3f (0.0, 0.0, 1.0);
574 glVertex3fv (cube[0]);
575 glVertex3fv (cube[5]);
576 glVertex3fv (cube[6]);
577 glVertex3fv (cube[1]);
578
579 glColor3f (0.0, 1.0, 1.0);
580 glVertex3fv (cube[5]);
581 glVertex3fv (cube[4]);
582 glVertex3fv (cube[7]);
583 glVertex3fv (cube[6]);
584
585 glColor3f (1.0, 1.0, 0.0);
586 glVertex3fv (cube[5]);
587 glVertex3fv (cube[0]);
588 glVertex3fv (cube[3]);
589 glVertex3fv (cube[4]);
590
591 glColor3f (1.0, 0.0, 1.0);
592 glVertex3fv (cube[6]);
593 glVertex3fv (cube[1]);
594 glVertex3fv (cube[2]);
595 glVertex3fv (cube[7]);
596#endif /* SHADED_CUBE */
597
598 glEnd (); 496 glEnd ();
599
600 glMatrixMode (GL_MODELVIEW);
601 glRotatef (5.0, 1.0, 1.0, 1.0);
602 497
603 SDL_GL_SwapBuffers (); 498 SDL_GL_SwapBuffers ();
604 499
605 /* Check for error conditions. */ 500 /* Check for error conditions. */
606 gl_error = glGetError (); 501 gl_error = glGetError ();
617 fprintf (stderr, "testgl: SDL error '%s'\n", sdl_error); 512 fprintf (stderr, "testgl: SDL error '%s'\n", sdl_error);
618 SDL_ClearError (); 513 SDL_ClearError ();
619 } 514 }
620 515
621 /* Allow the user to see what's happening */ 516 /* Allow the user to see what's happening */
622 if (slowly)
623 {
624 SDL_Delay (20);
625 }
626 SDL_Delay (20); 517 SDL_Delay (20);
627 518
628 /* Check if there's a pending event. */ 519 /* Check if there's a pending event. */
629 while (SDL_PollEvent (&event)) 520 while (SDL_PollEvent (&event))
630 { 521 {
675 { 566 {
676 if (strcmp (argv[i], "-twice") == 0) 567 if (strcmp (argv[i], "-twice") == 0)
677 { 568 {
678 ++numtests; 569 ++numtests;
679 } 570 }
680 if (strcmp (argv[i], "-logo") == 0)
681 {
682 logo = 1;
683 USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
684 }
685 if (strcmp (argv[i], "-logoblit") == 0)
686 {
687 logo = 1;
688 USE_DEPRECATED_OPENGLBLIT = SDL_TRUE;
689 }
690 if (strcmp (argv[i], "-slow") == 0) 571 if (strcmp (argv[i], "-slow") == 0)
691 { 572 {
692 slowly = 1; 573 slowly = 1;
693 } 574 }
694 if (strcmp (argv[i], "-bpp") == 0) 575 if (strcmp (argv[i], "-bpp") == 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines