Mercurial > sdl-ios-xcode
comparison test/testgl.c @ 1654:0a53c90a37f9 SDL-1.3
Updated to 1.3.0, SDL_OPENGLBLIT is no longer supported
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 27 Apr 2006 05:30:05 +0000 |
parents | 4d3bb026cd16 |
children | 96c2f89cc7e1 |
comparison
equal
deleted
inserted
replaced
1653:939d938d62df | 1654:0a53c90a37f9 |
---|---|
12 /* Undefine this if you want a flat cube instead of a rainbow cube */ | 12 /* Undefine this if you want a flat cube instead of a rainbow cube */ |
13 #define SHADED_CUBE | 13 #define SHADED_CUBE |
14 | 14 |
15 /* Define this to be the name of the logo image to use with -logo */ | 15 /* Define this to be the name of the logo image to use with -logo */ |
16 #define LOGO_FILE "icon.bmp" | 16 #define LOGO_FILE "icon.bmp" |
17 | |
18 /* The SDL_OPENGLBLIT interface is deprecated. | |
19 The code is still available for benchmark purposes though. | |
20 */ | |
21 | |
22 static SDL_bool USE_DEPRECATED_OPENGLBLIT = SDL_FALSE; | |
23 | 17 |
24 static SDL_Surface *global_image = NULL; | 18 static SDL_Surface *global_image = NULL; |
25 static GLuint global_texture = 0; | 19 static GLuint global_texture = 0; |
26 static GLuint cursor_texture = 0; | 20 static GLuint cursor_texture = 0; |
27 | 21 |
362 glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y ); | 356 glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y ); |
363 glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h); | 357 glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h); |
364 glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h); | 358 glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h); |
365 glEnd(); | 359 glEnd(); |
366 SDL_GL_Leave2DMode(); | 360 SDL_GL_Leave2DMode(); |
367 } | |
368 | |
369 /* This code is deprecated, but available for speed comparisons */ | |
370 void DrawLogoBlit(void) | |
371 { | |
372 static int x = 0; | |
373 static int y = 0; | |
374 static int w, h; | |
375 static int delta_x = 1; | |
376 static int delta_y = 1; | |
377 | |
378 SDL_Rect dst; | |
379 SDL_Surface *screen = SDL_GetVideoSurface(); | |
380 | |
381 if ( global_image == NULL ) { | |
382 SDL_Surface *temp; | |
383 | |
384 /* Load the image (could use SDL_image library here) */ | |
385 temp = SDL_LoadBMP(LOGO_FILE); | |
386 if ( temp == NULL ) { | |
387 return; | |
388 } | |
389 w = temp->w; | |
390 h = temp->h; | |
391 | |
392 /* Convert the image into the screen format */ | |
393 global_image = SDL_CreateRGBSurface( | |
394 SDL_SWSURFACE, | |
395 w, h, | |
396 screen->format->BitsPerPixel, | |
397 screen->format->Rmask, | |
398 screen->format->Gmask, | |
399 screen->format->Bmask, | |
400 screen->format->Amask); | |
401 if ( global_image ) { | |
402 SDL_BlitSurface(temp, NULL, global_image, NULL); | |
403 } | |
404 SDL_FreeSurface(temp); | |
405 | |
406 /* Make sure that the texture conversion is okay */ | |
407 if ( ! global_image ) { | |
408 return; | |
409 } | |
410 } | |
411 | |
412 /* Move the image around | |
413 Note that we do not clear the old position. This is because we | |
414 perform a glClear() which clears the framebuffer and then only | |
415 update the new area. | |
416 Note that you can also achieve interesting effects by modifying | |
417 the screen surface alpha channel. It's set to 255 by default.. | |
418 */ | |
419 x += delta_x; | |
420 if ( x < 0 ) { | |
421 x = 0; | |
422 delta_x = -delta_x; | |
423 } else | |
424 if ( (x+w) > screen->w ) { | |
425 x = screen->w-w; | |
426 delta_x = -delta_x; | |
427 } | |
428 y += delta_y; | |
429 if ( y < 0 ) { | |
430 y = 0; | |
431 delta_y = -delta_y; | |
432 } else | |
433 if ( (y+h) > screen->h ) { | |
434 y = screen->h-h; | |
435 delta_y = -delta_y; | |
436 } | |
437 dst.x = x; | |
438 dst.y = y; | |
439 dst.w = w; | |
440 dst.h = h; | |
441 SDL_BlitSurface(global_image, NULL, screen, &dst); | |
442 | |
443 /* Show the image on the screen */ | |
444 SDL_UpdateRects(screen, 1, &dst); | |
445 } | 361 } |
446 | 362 |
447 int RunGLTest( int argc, char* argv[], | 363 int RunGLTest( int argc, char* argv[], |
448 int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa ) | 364 int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa ) |
449 { | 365 { |
486 bpp = 16; /* More doesn't seem to work */ | 402 bpp = 16; /* More doesn't seem to work */ |
487 } | 403 } |
488 } | 404 } |
489 | 405 |
490 /* Set the flags we want to use for setting the video mode */ | 406 /* Set the flags we want to use for setting the video mode */ |
491 if ( logo && USE_DEPRECATED_OPENGLBLIT ) { | 407 video_flags = SDL_OPENGL; |
492 video_flags = SDL_OPENGLBLIT; | |
493 } else { | |
494 video_flags = SDL_OPENGL; | |
495 } | |
496 for ( i=1; argv[i]; ++i ) { | 408 for ( i=1; argv[i]; ++i ) { |
497 if ( strcmp(argv[i], "-fullscreen") == 0 ) { | 409 if ( strcmp(argv[i], "-fullscreen") == 0 ) { |
498 video_flags |= SDL_FULLSCREEN; | 410 video_flags |= SDL_FULLSCREEN; |
499 } | 411 } |
500 } | 412 } |
696 glMatrixMode(GL_MODELVIEW); | 608 glMatrixMode(GL_MODELVIEW); |
697 glRotatef(5.0, 1.0, 1.0, 1.0); | 609 glRotatef(5.0, 1.0, 1.0, 1.0); |
698 | 610 |
699 /* Draw 2D logo onto the 3D display */ | 611 /* Draw 2D logo onto the 3D display */ |
700 if ( logo ) { | 612 if ( logo ) { |
701 if ( USE_DEPRECATED_OPENGLBLIT ) { | 613 DrawLogoTexture(); |
702 DrawLogoBlit(); | |
703 } else { | |
704 DrawLogoTexture(); | |
705 } | |
706 } | 614 } |
707 if ( logocursor ) { | 615 if ( logocursor ) { |
708 DrawLogoCursor(); | 616 DrawLogoCursor(); |
709 } | 617 } |
710 | 618 |
778 if ( strcmp(argv[i], "-twice") == 0 ) { | 686 if ( strcmp(argv[i], "-twice") == 0 ) { |
779 ++numtests; | 687 ++numtests; |
780 } | 688 } |
781 if ( strcmp(argv[i], "-logo") == 0 ) { | 689 if ( strcmp(argv[i], "-logo") == 0 ) { |
782 logo = 1; | 690 logo = 1; |
783 USE_DEPRECATED_OPENGLBLIT = SDL_FALSE; | |
784 } | |
785 if ( strcmp(argv[i], "-logoblit") == 0 ) { | |
786 logo = 1; | |
787 USE_DEPRECATED_OPENGLBLIT = SDL_TRUE; | |
788 } | 691 } |
789 if ( strcmp(argv[i], "-logocursor") == 0 ) { | 692 if ( strcmp(argv[i], "-logocursor") == 0 ) { |
790 logocursor = 1; | 693 logocursor = 1; |
791 } | 694 } |
792 if ( strcmp(argv[i], "-slow") == 0 ) { | 695 if ( strcmp(argv[i], "-slow") == 0 ) { |