19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h> 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdio.h> 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <string.h> 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <math.h> 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL.h" 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef __MACOS__ 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define HAVE_OPENGL 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef HAVE_OPENGL 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_opengl.h" 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Undefine this if you want a flat cube instead of a rainbow cube */ 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define SHADED_CUBE 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Define this to be the name of the logo image to use with -logo */ 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define LOGO_FILE "icon.bmp" 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* The SDL_OPENGLBLIT interface is deprecated. 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall The code is still available for benchmark purposes though. 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_bool USE_DEPRECATED_OPENGLBLIT = SDL_FALSE; 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_Surface *global_image = NULL; 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic GLuint global_texture = 0; 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic GLuint cursor_texture = 0; 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/**********************************************************************/ 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid HotKey_ToggleFullScreen(void) 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *screen; 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen = SDL_GetVideoSurface(); 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_WM_ToggleFullScreen(screen) ) { 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Toggled fullscreen mode - now %s\n", 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (screen->flags&SDL_FULLSCREEN) ? "fullscreen" : "windowed"); 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Unable to toggle fullscreen mode\n"); 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid HotKey_ToggleGrab(void) 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GrabMode mode; 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Ctrl-G: toggling input grab!\n"); 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode = SDL_WM_GrabInput(SDL_GRAB_QUERY); 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( mode == SDL_GRAB_ON ) { 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Grab was on\n"); 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Grab was off\n"); 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall mode = SDL_WM_GrabInput(!mode); 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( mode == SDL_GRAB_ON ) { 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Grab is now on\n"); 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Grab is now off\n"); 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid HotKey_Iconify(void) 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Ctrl-Z: iconifying window!\n"); 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_WM_IconifyWindow(); 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint HandleEvent(SDL_Event *event) 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int done; 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall done = 0; 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch( event->type ) { 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case SDL_ACTIVEEVENT: 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* See what happened */ 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "app %s ", event->active.gain ? "gained" : "lost" ); 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event->active.state & SDL_APPACTIVE ) { 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "active " ); 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else if ( event->active.state & SDL_APPMOUSEFOCUS ) { 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "mouse " ); 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else if ( event->active.state & SDL_APPINPUTFOCUS ) { 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "input " ); 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "focus\n" ); 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case SDL_KEYDOWN: 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( event->key.keysym.sym == SDLK_ESCAPE ) { 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall done = 1; 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (event->key.keysym.sym == SDLK_g) && 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (event->key.keysym.mod & KMOD_CTRL) ) { 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HotKey_ToggleGrab(); 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (event->key.keysym.sym == SDLK_z) && 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (event->key.keysym.mod & KMOD_CTRL) ) { 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HotKey_Iconify(); 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (event->key.keysym.sym == SDLK_RETURN) && 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (event->key.keysym.mod & KMOD_ALT) ) { 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HotKey_ToggleFullScreen(); 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("key '%s' pressed\n", 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GetKeyName(event->key.keysym.sym)); 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case SDL_QUIT: 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall done = 1; 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(done); 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_GL_Enter2DMode() 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *screen = SDL_GetVideoSurface(); 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Note, there may be other things you need to change, 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall depending on how you have your OpenGL state set up. 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushAttrib(GL_ENABLE_BIT); 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glDisable(GL_DEPTH_TEST); 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glDisable(GL_CULL_FACE); 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnable(GL_TEXTURE_2D); 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* This allows alpha blending of 2D textures with the scene */ 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnable(GL_BLEND); 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glViewport(0, 0, screen->w, screen->h); 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode(GL_PROJECTION); 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushMatrix(); 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLoadIdentity(); 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0); 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode(GL_MODELVIEW); 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPushMatrix(); 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLoadIdentity(); 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SDL_GL_Leave2DMode() 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode(GL_MODELVIEW); 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopMatrix(); 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode(GL_PROJECTION); 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopMatrix(); 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glPopAttrib(); 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Quick utility function for texture creation */ 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int power_of_two(int input) 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int value = 1; 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while ( value < input ) { 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall value <<= 1; 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return value; 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallGLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord) 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLuint texture; 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int w, h; 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *image; 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect area; 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint32 saved_flags; 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 saved_alpha; 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Use the surface width and height expanded to powers of 2 */ 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w = power_of_two(surface->w); 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h = power_of_two(surface->h); 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texcoord[0] = 0.0f; /* Min X */ 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texcoord[1] = 0.0f; /* Min Y */ 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texcoord[2] = (GLfloat)surface->w / w; /* Max X */ 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texcoord[3] = (GLfloat)surface->h / h; /* Max Y */ 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall image = SDL_CreateRGBSurface( 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SWSURFACE, 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w, h, 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 32, 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0x000000FF, 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0x0000FF00, 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0x00FF0000, 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0xFF000000 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0xFF000000, 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0x00FF0000, 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0x0000FF00, 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0x000000FF 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ); 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( image == NULL ) { 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Save the alpha blending attributes */ 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK); 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall saved_alpha = surface->format->alpha; 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetAlpha(surface, 0, 0); 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Copy the surface into the GL texture image */ 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall area.x = 0; 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall area.y = 0; 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall area.w = surface->w; 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall area.h = surface->h; 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_BlitSurface(surface, &area, image, &area); 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Restore the alpha blending attributes */ 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetAlpha(surface, saved_flags, saved_alpha); 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Create an OpenGL texture for the image */ 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glGenTextures(1, &texture); 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glBindTexture(GL_TEXTURE_2D, texture); 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexImage2D(GL_TEXTURE_2D, 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0, 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GL_RGBA, 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w, h, 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0, 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GL_RGBA, 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GL_UNSIGNED_BYTE, 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall image->pixels); 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(image); /* No longer needed */ 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return texture; 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DrawLogoCursor(void) 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static GLfloat texMinX, texMinY; 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static GLfloat texMaxX, texMaxY; 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int w, h; 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int x, y; 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! cursor_texture ) { 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *image; 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLfloat texcoord[4]; 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Load the image (could use SDL_image library here) */ 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall image = SDL_LoadBMP(LOGO_FILE); 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( image == NULL ) { 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w = image->w; 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h = image->h; 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Convert the image into an OpenGL texture */ 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cursor_texture = SDL_GL_LoadTexture(image, texcoord); 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Make texture coordinates easy to understand */ 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texMinX = texcoord[0]; 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texMinY = texcoord[1]; 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texMaxX = texcoord[2]; 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texMaxY = texcoord[3]; 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We don't need the original image anymore */ 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(image); 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Make sure that the texture conversion is okay */ 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! cursor_texture ) { 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Move the image around */ 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GetMouseState(&x, &y); 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x -= w/2; 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y -= h/2; 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Show the image on the screen */ 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_Enter2DMode(); 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glBindTexture(GL_TEXTURE_2D, cursor_texture); 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glBegin(GL_TRIANGLE_STRIP); 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexCoord2f(texMinX, texMinY); glVertex2i(x, y ); 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y ); 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h); 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h); 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnd(); 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_Leave2DMode(); 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DrawLogoTexture(void) 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static GLfloat texMinX, texMinY; 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static GLfloat texMaxX, texMaxY; 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int x = 0; 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int y = 0; 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int w, h; 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int delta_x = 1; 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int delta_y = 1; 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *screen = SDL_GetVideoSurface(); 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! global_texture ) { 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *image; 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLfloat texcoord[4]; 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Load the image (could use SDL_image library here) */ 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall image = SDL_LoadBMP(LOGO_FILE); 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( image == NULL ) { 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w = image->w; 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h = image->h; 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Convert the image into an OpenGL texture */ 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall global_texture = SDL_GL_LoadTexture(image, texcoord); 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Make texture coordinates easy to understand */ 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texMinX = texcoord[0]; 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texMinY = texcoord[1]; 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texMaxX = texcoord[2]; 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall texMaxY = texcoord[3]; 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* We don't need the original image anymore */ 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(image); 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Make sure that the texture conversion is okay */ 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! global_texture ) { 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Move the image around */ 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x += delta_x; 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( x < 0 ) { 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x = 0; 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delta_x = -delta_x; 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (x+w) > screen->w ) { 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x = screen->w-w; 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delta_x = -delta_x; 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y += delta_y; 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( y < 0 ) { 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y = 0; 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delta_y = -delta_y; 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (y+h) > screen->h ) { 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y = screen->h-h; 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delta_y = -delta_y; 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Show the image on the screen */ 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_Enter2DMode(); 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glBindTexture(GL_TEXTURE_2D, global_texture); 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glBegin(GL_TRIANGLE_STRIP); 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexCoord2f(texMinX, texMinY); glVertex2i(x, y ); 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y ); 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h); 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h); 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnd(); 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_Leave2DMode(); 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* This code is deprecated, but available for speed comparisons */ 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid DrawLogoBlit(void) 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int x = 0; 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int y = 0; 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int w, h; 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int delta_x = 1; 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall static int delta_y = 1; 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Rect dst; 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *screen = SDL_GetVideoSurface(); 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( global_image == NULL ) { 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Surface *temp; 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Load the image (could use SDL_image library here) */ 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall temp = SDL_LoadBMP(LOGO_FILE); 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( temp == NULL ) { 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w = temp->w; 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall h = temp->h; 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Convert the image into the screen format */ 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall global_image = SDL_CreateRGBSurface( 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SWSURFACE, 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall w, h, 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->format->BitsPerPixel, 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->format->Rmask, 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->format->Gmask, 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->format->Bmask, 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->format->Amask); 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( global_image ) { 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_BlitSurface(temp, NULL, global_image, NULL); 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(temp); 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Make sure that the texture conversion is okay */ 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( ! global_image ) { 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Move the image around 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Note that we do not clear the old position. This is because we 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall perform a glClear() which clears the framebuffer and then only 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall update the new area. 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Note that you can also achieve interesting effects by modifying 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall the screen surface alpha channel. It's set to 255 by default.. 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall */ 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x += delta_x; 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( x < 0 ) { 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x = 0; 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delta_x = -delta_x; 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (x+w) > screen->w ) { 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall x = screen->w-w; 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delta_x = -delta_x; 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y += delta_y; 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( y < 0 ) { 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y = 0; 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delta_y = -delta_y; 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( (y+h) > screen->h ) { 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall y = screen->h-h; 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delta_y = -delta_y; 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.x = x; 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.y = y; 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.w = w; 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dst.h = h; 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_BlitSurface(global_image, NULL, screen, &dst); 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Show the image on the screen */ 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_UpdateRects(screen, 1, &dst); 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint RunGLTest( int argc, char* argv[], 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa, int sync, int accel ) 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int rgb_size[3]; 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int w = 640; 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int h = 480; 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int done = 0; 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int frames; 4609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint32 start_time, this_time; 4619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall float color[8][3]= {{ 1.0, 1.0, 0.0}, 4629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1.0, 0.0, 0.0}, 4639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 0.0, 0.0, 0.0}, 4649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 0.0, 1.0, 0.0}, 4659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 0.0, 1.0, 1.0}, 4669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1.0, 1.0, 1.0}, 4679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1.0, 0.0, 1.0}, 4689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 0.0, 0.0, 1.0}}; 4699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall float cube[8][3]= {{ 0.5, 0.5, -0.5}, 4709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 0.5, -0.5, -0.5}, 4719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall {-0.5, -0.5, -0.5}, 4729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall {-0.5, 0.5, -0.5}, 4739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall {-0.5, 0.5, 0.5}, 4749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 0.5, 0.5, 0.5}, 4759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 0.5, -0.5, 0.5}, 4769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall {-0.5, -0.5, 0.5}}; 4779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint32 video_flags; 4789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int value; 4799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { 4819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError()); 4829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall exit( 1 ); 4839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* See if we should detect the display depth */ 4869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( bpp == 0 ) { 4879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 ) { 4889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bpp = 8; 4899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 4909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bpp = 16; /* More doesn't seem to work */ 4919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the flags we want to use for setting the video mode */ 4959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( logo && USE_DEPRECATED_OPENGLBLIT ) { 4969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall video_flags = SDL_OPENGLBLIT; 4979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 4989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall video_flags = SDL_OPENGL; 4999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=1; argv[i]; ++i ) { 5019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-fullscreen") == 0 ) { 5029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall video_flags |= SDL_FULLSCREEN; 5039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (noframe) { 5079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall video_flags |= SDL_NOFRAME; 5089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Initialize the display */ 5119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (bpp) { 5129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 8: 5139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[0] = 3; 5149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[1] = 3; 5159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[2] = 2; 5169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 5179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 15: 5189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 16: 5199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[0] = 5; 5209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[1] = 5; 5219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[2] = 5; 5229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 5239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 5249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[0] = 8; 5259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[1] = 8; 5269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall rgb_size[2] = 8; 5279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 5289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] ); 5309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] ); 5319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] ); 5329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); 5339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 5349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( fsaa ) { 5359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); 5369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa ); 5379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( accel ) { 5399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 ); 5409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( sync ) { 5429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 ); 5439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 5449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 ); 5459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) { 5479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); 5489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Quit(); 5499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall exit(1); 5509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel); 5539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 5549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "Vendor : %s\n", glGetString( GL_VENDOR ) ); 5559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "Renderer : %s\n", glGetString( GL_RENDERER ) ); 5569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "Version : %s\n", glGetString( GL_VERSION ) ); 5579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "Extensions : %s\n", glGetString( GL_EXTENSIONS ) ); 5589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("\n"); 5599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value ); 5619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value); 5629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value ); 5639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value); 5649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value ); 5659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value); 5669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value ); 5679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value ); 5689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value ); 5699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value ); 5709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( fsaa ) { 5719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value ); 5729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value ); 5739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value ); 5749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value ); 5759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( accel ) { 5779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_ACCELERATED_VISUAL, &value ); 5789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value ); 5799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( sync ) { 5819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_GetAttribute( SDL_GL_SWAP_CONTROL, &value ); 5829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( "SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value ); 5839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the window manager title bar */ 5869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_WM_SetCaption( "SDL GL test", "testgl" ); 5879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set the gamma for the window */ 5899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( gamma != 0.0 ) { 5909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetGamma(gamma, gamma, gamma); 5919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glViewport( 0, 0, w, h ); 5949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode( GL_PROJECTION ); 5959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLoadIdentity( ); 5969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glOrtho( -2.0, 2.0, -2.0, 2.0, -20.0, 20.0 ); 5989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode( GL_MODELVIEW ); 6009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glLoadIdentity( ); 6019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnable(GL_DEPTH_TEST); 6039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glDepthFunc(GL_LESS); 6059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glShadeModel(GL_SMOOTH); 6079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Loop until done. */ 6099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall start_time = SDL_GetTicks(); 6109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frames = 0; 6119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while( !done ) { 6129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLenum gl_error; 6139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall char* sdl_error; 6149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Event event; 6159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Do our drawing, too. */ 6179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glClearColor( 0.0, 0.0, 0.0, 1.0 ); 6189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 6199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glBegin( GL_QUADS ); 6219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef SHADED_CUBE 6239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[0]); 6249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[0]); 6259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[1]); 6269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[1]); 6279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[2]); 6289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[2]); 6299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[3]); 6309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[3]); 6319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[3]); 6339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[3]); 6349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[4]); 6359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[4]); 6369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[7]); 6379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[7]); 6389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[2]); 6399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[2]); 6409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[0]); 6429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[0]); 6439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[5]); 6449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[5]); 6459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[6]); 6469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[6]); 6479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[1]); 6489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[1]); 6499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[5]); 6519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[5]); 6529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[4]); 6539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[4]); 6549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[7]); 6559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[7]); 6569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[6]); 6579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[6]); 6589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[5]); 6609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[5]); 6619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[0]); 6629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[0]); 6639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[3]); 6649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[3]); 6659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[4]); 6669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[4]); 6679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[6]); 6699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[6]); 6709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[1]); 6719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[1]); 6729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[2]); 6739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[2]); 6749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3fv(color[7]); 6759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[7]); 6769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else /* flat cube */ 6779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3f(1.0, 0.0, 0.0); 6789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[0]); 6799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[1]); 6809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[2]); 6819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[3]); 6829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3f(0.0, 1.0, 0.0); 6849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[3]); 6859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[4]); 6869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[7]); 6879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[2]); 6889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3f(0.0, 0.0, 1.0); 6909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[0]); 6919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[5]); 6929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[6]); 6939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[1]); 6949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3f(0.0, 1.0, 1.0); 6969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[5]); 6979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[4]); 6989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[7]); 6999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[6]); 7009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3f(1.0, 1.0, 0.0); 7029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[5]); 7039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[0]); 7049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[3]); 7059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[4]); 7069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glColor3f(1.0, 0.0, 1.0); 7089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[6]); 7099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[1]); 7109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[2]); 7119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glVertex3fv(cube[7]); 7129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SHADED_CUBE */ 7139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glEnd( ); 7159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glMatrixMode(GL_MODELVIEW); 7179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glRotatef(5.0, 1.0, 1.0, 1.0); 7189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Draw 2D logo onto the 3D display */ 7209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( logo ) { 7219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( USE_DEPRECATED_OPENGLBLIT ) { 7229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawLogoBlit(); 7239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 7249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawLogoTexture(); 7259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( logocursor ) { 7289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DrawLogoCursor(); 7299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_GL_SwapBuffers( ); 7329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check for error conditions. */ 7349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall gl_error = glGetError( ); 7359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( gl_error != GL_NO_ERROR ) { 7379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error ); 7389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sdl_error = SDL_GetError( ); 7419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if( sdl_error[0] != '\0' ) { 7439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error); 7449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_ClearError(); 7459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Allow the user to see what's happening */ 7489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( slowly ) { 7499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Delay( 20 ); 7509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Check if there's a pending event. */ 7539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while( SDL_PollEvent( &event ) ) { 7549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall done = HandleEvent(&event); 7559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++frames; 7579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Print out the frames per second */ 7609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this_time = SDL_GetTicks(); 7619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( this_time != start_time ) { 7629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("%2.2f FPS\n", 7639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((float)frames/(this_time-start_time))*1000.0); 7649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( global_image ) { 7679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_FreeSurface(global_image); 7689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall global_image = NULL; 7699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( global_texture ) { 7719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glDeleteTextures( 1, &global_texture ); 7729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall global_texture = 0; 7739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( cursor_texture ) { 7759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall glDeleteTextures( 1, &cursor_texture ); 7769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cursor_texture = 0; 7779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Destroy our GL context, etc. */ 7809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Quit( ); 7819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return(0); 7829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint main(int argc, char *argv[]) 7859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i, logo, logocursor = 0; 7879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int numtests; 7889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int bpp = 0; 7899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int slowly; 7909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall float gamma = 0.0; 7919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int noframe = 0; 7929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int fsaa = 0; 7939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int accel = 0; 7949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int sync = 0; 7959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall logo = 0; 7979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slowly = 0; 7989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall numtests = 1; 7999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=1; argv[i]; ++i ) { 8009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-twice") == 0 ) { 8019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++numtests; 8029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-logo") == 0 ) { 8049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall logo = 1; 8059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall USE_DEPRECATED_OPENGLBLIT = SDL_FALSE; 8069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-logoblit") == 0 ) { 8089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall logo = 1; 8099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall USE_DEPRECATED_OPENGLBLIT = SDL_TRUE; 8109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-logocursor") == 0 ) { 8129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall logocursor = 1; 8139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-slow") == 0 ) { 8159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slowly = 1; 8169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-bpp") == 0 ) { 8189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bpp = atoi(argv[++i]); 8199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-gamma") == 0 ) { 8219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall gamma = (float)atof(argv[++i]); 8229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-noframe") == 0 ) { 8249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall noframe = 1; 8259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-fsaa") == 0 ) { 8279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++fsaa; 8289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-accel") == 0 ) { 8309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++accel; 8319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strcmp(argv[i], "-sync") == 0 ) { 8339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++sync; 8349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ( strncmp(argv[i], "-h", 2) == 0 ) { 8369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf( 8379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall"Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel] [-sync] [-fullscreen]\n", 8389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall argv[0]); 8399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall exit(0); 8409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for ( i=0; i<numtests; ++i ) { 8439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa, sync, accel); 8449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 8469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#else /* HAVE_OPENGL */ 8499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint main(int argc, char *argv[]) 8519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 8529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("No OpenGL support on this system\n"); 8539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 1; 8549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* HAVE_OPENGL */ 857