src/render/rScreen.cpp File Reference

#include "rFont.h"
#include "defs.h"
#include <string>
#include "rTexture.h"
#include "rScreen.h"
#include "rSysdep.h"
#include "rConsole.h"
#include "rViewport.h"
#include "tConfiguration.h"
#include "tRecorder.h"
#include "tSysTime.h"
#include "rGL.h"
#include "rSDL.h"

Include dependency graph for rScreen.cpp:

Go to the source code of this file.

Defines

#define MAXEMERGENCY   6

Functions

 tCONFIG_ENUM (rResolution)
 tCONFIG_ENUM (rColorDepth)
 tCONFIG_ENUM (rVSync)
bool sr_DesktopScreensizeSupported ()
bool sr_True ()
void sr_ReinitDisplay ()
static int countBits (unsigned int count)
static bool lowlevel_sr_InitDisplay ()
bool sr_InitDisplay ()
void sr_ExitDisplay ()
void sr_LoadDefaultConfig ()
void sr_ResetRenderState (bool menu)
void sr_DepthOffset (bool offset)
void sr_Activate (bool active)

Variables

SDL_Surface * sr_screen = NULL
static int default_texturemode = GL_LINEAR_MIPMAP_LINEAR
rDisplayListUsage sr_useDisplayLists = rDisplayList_Off
static int width [ArmageTron_Custom+2] = {0, 320, 320, 400, 512, 640, 800, 1024 , 1280, 1280, 1280, 1600, 1680, 2048,800,320}
static int height [ArmageTron_Custom+2] = {0, 200, 240, 300, 384, 480, 600, 768 , 800, 854, 1024, 1200, 1050, 1572,600,200}
static REAL aspect [ArmageTron_Custom+2] = {1, 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1, 1, 1 , 1, 1, 1,1, 1}
int sr_screenWidth
int sr_screenHeight
static tSettingItem< int > at_ch ("CUSTOM_SCREEN_HEIGHT", height[ArmageTron_Custom])
static tSettingItem< int > at_cw ("CUSTOM_SCREEN_WIDTH", width[ArmageTron_Custom])
static tSettingItem< REALat_ca ("CUSTOM_SCREEN_ASPECT", aspect[ArmageTron_Custom])
rScreenSettings lastSuccess (ArmageTron_640_480, false)
static rScreenSettings em6 (ArmageTron_320_240, false, ArmageTron_ColorDepth_16, true, false)
static rScreenSettings em5 (ArmageTron_320_240, false, ArmageTron_ColorDepth_Desktop, true, false)
static rScreenSettings em4 (ArmageTron_640_480, false, ArmageTron_ColorDepth_16)
static rScreenSettings em3 (ArmageTron_640_480, true, ArmageTron_ColorDepth_16)
static rScreenSettings em2 (ArmageTron_640_480, true, ArmageTron_ColorDepth_16, false)
static rScreenSettings em1 (ArmageTron_640_480)
static rScreenSettingsemergency [MAXEMERGENCY+2] = { &lastSuccess, &lastSuccess, &em1, &em2, &em3 , &em4, &em5, &em6}
rScreenSettings currentScreensetting (sr_DesktopScreensizeSupported()?ArmageTron_Desktop:ArmageTron_800_600, true)
static int failed_attempts = 0
static tConfItem< rResolutionscreenres ("ARMAGETRON_SCREENMODE", currentScreensetting.res.res)
static tConfItem< rResolutionscreenresLast ("ARMAGETRON_LAST_SCREENMODE", lastSuccess.res.res)
static tConfItem< rResolutionwinsize ("ARMAGETRON_WINDOWSIZE", currentScreensetting.windowSize.res)
static tConfItem< rResolutionwinsizeLast ("ARMAGETRON_LAST_WINDOWSIZE", lastSuccess.windowSize.res)
static tConfItem< rVSyncvSync ("ARMAGETRON_VSYNC", currentScreensetting.vSync)
static tConfItem< rVSyncvSyncLast ("ARMAGETRON_VSYNC_LAST", lastSuccess.vSync)
static tConfItem< int > screenres_w ("ARMAGETRON_SCREENMODE_W", currentScreensetting.res.width)
static tConfItem< int > screenresLast_w ("ARMAGETRON_LAST_SCREENMODE_W", lastSuccess.res.width)
static tConfItem< int > winsize_w ("ARMAGETRON_WINDOWSIZE_W", currentScreensetting.windowSize.width)
static tConfItem< int > winsizeLast_w ("ARMAGETRON_LAST_WINDOWSIZE_W", lastSuccess.windowSize.width)
static tConfItem< int > screenres_h ("ARMAGETRON_SCREENMODE_H", currentScreensetting.res.height)
static tConfItem< int > screenresLast_h ("ARMAGETRON_LAST_SCREENMODE_H", lastSuccess.res.height)
static tConfItem< int > winsize_h ("ARMAGETRON_WINDOWSIZE_H", currentScreensetting.windowSize.height)
static tConfItem< int > winsizeLast_h ("ARMAGETRON_LAST_WINDOWSIZE_H", lastSuccess.windowSize.height)
static tConfItem< bool > fs_ci ("FULLSCREEN", currentScreensetting.fullscreen)
static tConfItem< bool > fs_lci ("LAST_FULLSCREEN", currentScreensetting.fullscreen)
static tConfItem< rColorDepthtc ("COLORDEPTH", currentScreensetting.colorDepth)
static tConfItem< rColorDepthltc ("LAST_COLORDEPTH", lastSuccess.colorDepth)
static tConfItem< rColorDepthtzd ("ZDEPTH", currentScreensetting.zDepth)
static tConfItem< rColorDepthltzd ("LAST_ZDEPTH", lastSuccess.zDepth)
static tConfItem< bool > check_errors ("CHECK_ERRORS", currentScreensetting.checkErrors)
static tConfItem< bool > check_errorsl ("LAST_CHECK_ERRORS", lastSuccess.checkErrors)
static tConfItem< int > fa ("FAILED_ATTEMPTS", failed_attempts)
static tCallbackrPerFrameTask_anchor
static tCallbackStringRenderId_anchor
tString gl_vendor
tString gl_renderer
tString gl_version
tString gl_extensions
bool software_renderer = false
bool last_software_renderer = false
static tConfItem< bool > lsr ("SOFTWARE_RENDERER", last_software_renderer)
tString lastError ("Unknown")
bool cycleprograminited
bool sr_alphaBlend = true
bool sr_glOut = true
bool sr_smoothShading = true
int sr_floorMirror = 0
int sr_floorDetail = rFLOOR_TEXTURE
bool sr_highRim = true
bool sr_upperSky = false
bool sr_lowerSky = false
bool sr_skyWobble = true
bool sr_dither = true
bool sr_infinityPlane = false
bool sr_laggometer = true
bool sr_predictObjects = false
bool sr_texturesTruecolor = false
bool sr_textOut = false
bool sr_FPSOut = true
bool sr_keepWindowActive = false
tString renderer_identification
static tCallbacksr_BeforeAnchor
static tCallbacksr_AfterAnchor


Define Documentation

#define MAXEMERGENCY   6

Definition at line 86 of file rScreen.cpp.

Referenced by sr_InitDisplay().


Function Documentation

static int countBits ( unsigned int  count  )  [static]

Definition at line 395 of file rScreen.cpp.

Referenced by lowlevel_sr_InitDisplay().

00397 {
00398     int ret = 0;
00399     while (count)
00400     {
00401         ret    += count & 1;
00402         count >>= 1;
00403     }
00404 
00405     return ret;

Here is the caller graph for this function:

static bool lowlevel_sr_InitDisplay (  )  [static]

Definition at line 499 of file rScreen.cpp.

References ArmageTron_ColorDepth_16, ArmageTron_ColorDepth_32, ArmageTron_ColorDepth_Desktop, ArmageTron_Invalid, rScreenSettings::aspect, rScreenSettings::checkErrors, tString::Clear(), rScreenSettings::colorDepth, countBits(), currentScreensetting, default_texturemode, rCallbackAfterScreenModeChange::Exec(), rScreenSettings::fullscreen, rScreenSize::height, rSysDep::InitGL(), tRecorderBase::IsPlayingBack(), lastError, NULL, renderer_identification, rRenderIdCallback::RenderId(), rScreenSize::res, rScreenSettings::res, sr_DesktopScreensizeSupported(), sr_LoadDefaultConfig(), sr_ResetRenderState(), sr_screen, sr_screenHeight, sr_screenWidth, rISurfaceTexture::storageHack_, rTextureGroups::TEX_FONT, rTextureGroups::TextureMode, rScreenSize::UpdateSize(), rScreenSettings::useSDL, rScreenSize::width, rScreenSettings::windowSize, and rScreenSettings::zDepth.

Referenced by sr_InitDisplay().

00500                                      {
00501     #ifndef DEDICATED
00502     rScreenSize & res = currentScreensetting.fullscreen ? currentScreensetting.res : currentScreensetting.windowSize;
00503 
00504     // update pixel aspect ratio
00505     if ( res.res != ArmageTron_Invalid )
00506         currentScreensetting.aspect = aspect[res.res];
00507 
00508     #ifndef DIRTY
00509     currentScreensetting.useSDL = true;
00510     #endif
00511     res.UpdateSize();
00512     sr_screenWidth = res.width;
00513     sr_screenHeight= res.height;
00514 
00515     if (!sr_screen)
00516     {
00517         int singleCD_R  = 5;
00518         int singleCD_G  = 5;
00519         int singleCD_B  = 5;
00520         int fullCD              = 16;
00521         int zDepth              = 16;
00522 
00523         switch (currentScreensetting.colorDepth)
00524         {
00525         case ArmageTron_ColorDepth_16:
00526             // parameters already set for this depth
00527             break;
00528         case ArmageTron_ColorDepth_Desktop:
00529             {
00530                 const SDL_VideoInfo* videoInfo     = SDL_GetVideoInfo( );
00531                 const SDL_PixelFormat* pixelFormat = videoInfo->vfmt;
00532                 fullCD                                 = pixelFormat->BitsPerPixel;
00533                 singleCD_R                         = countBits(pixelFormat->Rmask);
00534                 singleCD_G                         = countBits(pixelFormat->Gmask);
00535                 singleCD_B                         = countBits(pixelFormat->Bmask);
00536             }
00537             break;
00538         case ArmageTron_ColorDepth_32:
00539             singleCD_R  = 8;
00540             singleCD_G  = 8;
00541             singleCD_B  = 8;
00542             fullCD              = 24;
00543             zDepth              = 32;
00544             break;
00545         }
00546 
00547         switch ( currentScreensetting.zDepth )
00548         {
00549         case ArmageTron_ColorDepth_16: zDepth = 16; break;
00550         case ArmageTron_ColorDepth_32: zDepth = 32; break;
00551         default: break;
00552         }
00553 
00554     #ifdef SDL_OPENGL
00555         if (currentScreensetting.useSDL)
00556         {
00557             sr_SetGLAttributes( singleCD_R, singleCD_G, singleCD_B, zDepth );
00558         }
00559     #else
00560         currentScreensetting.useSDL = false;
00561     #endif
00562 
00563 
00564 
00565         /*
00566           #ifdef POWERPAK_DEB
00567           PD_SetGFXMode(sr_screenWidth, sr_screenHeight, 32, PD_DEFAULT);
00568           sr_screen=DoubleBuffer;
00569           #else
00570         */
00571 
00572         int attrib;
00573 
00574     #ifdef SDL_OPENGL
00575         if (currentScreensetting.useSDL)
00576         {
00577             // SDL 1.1
00578     #ifndef FORCE_WINDOW
00579             if (currentScreensetting.fullscreen)
00580                 attrib=SDL_OPENGL | SDL_FULLSCREEN;
00581             else
00582     #endif
00583                 attrib=SDL_OPENGL;
00584         }
00585         else
00586     #endif
00587         {
00588     #ifndef FORCE_WINDOW
00589             if (currentScreensetting.fullscreen)
00590                 attrib=SDL_DOUBLEBUF | SDL_SWSURFACE | SDL_FULLSCREEN;
00591             else
00592     #endif
00593                 attrib=SDL_DOUBLEBUF | SDL_SWSURFACE;
00594         }
00595 
00596     #ifdef FORCE_WINDOW
00597     #ifdef WIN32
00598         //              sr_screenWidth  = 400;
00599         //              sr_screenHeight = 300;
00600     #else
00601         //              sr_screenWidth  = 640;
00602         //              sr_screenHeight = 480;
00603     #endif
00604     #endif
00605         int CD = fullCD;
00606 
00607         if (currentScreensetting.checkErrors)
00608         {
00609             // check if the video mode should be OK:
00610             CD = SDL_VideoModeOK
00611                  (sr_screenWidth, sr_screenHeight,   fullCD,
00612                   attrib);
00613 
00614             // if not quite right
00615             if (CD < fullCD){
00616                 // check if the other fs/windowed mode is better
00617                 int CD_fsinv = SDL_VideoModeOK
00618                                (sr_screenWidth, sr_screenHeight,   fullCD,
00619                                 attrib^SDL_FULLSCREEN);
00620 
00621                 if (CD_fsinv > fullCD){
00622                     // yes! change the mode
00623                     currentScreensetting.fullscreen=!currentScreensetting.fullscreen;
00624                     attrib ^= SDL_FULLSCREEN;
00625                     CD = CD_fsinv;
00626                 }
00627             }
00628 
00629             if (CD < fullCD && currentScreensetting.colorDepth != ArmageTron_ColorDepth_16)
00630             {
00631                 currentScreensetting.colorDepth = ArmageTron_ColorDepth_16;
00632 
00633     #ifdef SDL_OPENGL
00634                 if (currentScreensetting.useSDL)
00635                 {
00636                     sr_SetGLAttributes( 5, 5, 5, 16 );
00637                 }
00638     #endif
00639             }
00640         }
00641 
00642         // determine desktop resolution
00643         static int sr_desktopWidth = 0, sr_desktopHeight = 0;
00644         if ( sr_desktopWidth == 0 && !sr_screen )
00645         {
00646             // select sane defaults in case the following operation fails
00647             sr_desktopWidth = 640;
00648             sr_desktopHeight = 480;
00649 
00650             if ( sr_DesktopScreensizeSupported() )
00651             {
00652                 sr_screen=SDL_SetVideoMode( 0, 0, CD, attrib );
00653                 if ( sr_screen )
00654                 {
00655                     sr_desktopWidth = sr_screen->w;
00656                     sr_desktopHeight = sr_screen->h;
00657                 }
00658             }
00659         }
00660 
00661         // if desktop resolution was selected, pick it
00662         if ( sr_screenWidth + sr_screenHeight == 0 )
00663         {
00664             sr_screenWidth = sr_desktopWidth;
00665             sr_screenHeight = sr_desktopHeight;
00666         }
00667 
00668         if ( (sr_screen=SDL_SetVideoMode
00669                         (sr_screenWidth, sr_screenHeight,   CD,
00670                          attrib))
00671                 == NULL)
00672         {
00673             if((sr_screen=SDL_SetVideoMode
00674                           (sr_screenWidth, sr_screenHeight,    CD,
00675                            attrib^SDL_FULLSCREEN))==NULL )
00676             {
00677                 lastError.Clear();
00678                 lastError << "Couldn't set video mode: ";
00679                 lastError << SDL_GetError();
00680                 std::cerr << lastError << '\n';
00681                 return false;
00682             }
00683             else
00684             {
00685                 currentScreensetting.fullscreen=!currentScreensetting.fullscreen;
00686             }
00687         }
00688 
00689         // MacOSX SDL 1.2.4 crashes if we SetCaption after switch to fullscreen. (fixed in 1.2.5)
00690     #ifdef MACOSX
00691         if(!currentScreensetting.fullscreen)
00692     #endif
00693         {
00694             tOutput o("Armagetron Advanced");
00695             tString s;
00696             s << o;
00697             SDL_WM_SetCaption(s, s);
00698         }
00699 
00700         sr_CompleteGLAttributes();
00701 
00702         SDL_EnableUNICODE(1);
00703     }
00704 
00705     #ifdef DIRTY
00706     if (!currentScreensetting.useSDL)
00707         if(!rSysDep::InitGL()) return false;
00708     #endif
00709 
00710     #ifndef DEDICATED
00711     gl_vendor.Clear();
00712     gl_renderer.Clear();
00713     gl_version.Clear();
00714     gl_extensions.Clear();
00715     renderer_identification.Clear();
00716 
00717     gl_vendor     << reinterpret_cast<const char *>(glGetString(GL_VENDOR));
00718     gl_renderer   << reinterpret_cast<const char *>(glGetString(GL_RENDERER));
00719     gl_version    << reinterpret_cast<const char *>(glGetString(GL_VERSION));
00720     gl_extensions << reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
00721 
00722     #ifndef WIN32
00723     if(!strstr(gl_renderer,"Voodoo3"))
00724     #endif
00725         if(currentScreensetting.fullscreen)
00726             SDL_ShowCursor(0);
00727         else
00728             SDL_ShowCursor(1);
00729 
00730     #ifdef WIN32
00731     renderer_identification << "WIN32 ";
00732     #else
00733     #ifdef MACOSX
00734     renderer_identification << "MACOSX ";
00735     #else
00736     renderer_identification << "LINUX ";
00737     #endif
00738     #endif
00739     renderer_identification << rRenderIdCallback::RenderId() << ' ';
00740     #ifdef SDL_OPENGL
00741     renderer_identification << "SDL 1.2\n";
00742     renderer_identification << "USE_SDL=" << currentScreensetting.useSDL
00743     << '\n';
00744     #else
00745     renderer_identification << "SDL 1.0\n";
00746     #endif
00747     renderer_identification << "CD=" << currentScreensetting.colorDepth  << '\n';
00748     renderer_identification << "FS=" << currentScreensetting.fullscreen  << '\n';
00749     renderer_identification << "GL_VENDOR=" << gl_vendor   << '\n';
00750     renderer_identification << "GL_RENDERER=" << gl_renderer << '\n';
00751     renderer_identification << "GL_VERSION=" << gl_version  << '\n';
00752     #endif
00753 
00754     if (// test for Windows software GL (be a little flexible...)
00755         (
00756             strstr(gl_vendor,"icrosoft") || strstr(gl_vendor,"SGI")
00757         )
00758         && strstr(gl_renderer,"eneric")
00759     )
00760         software_renderer=true;
00761 
00762     if ( // test for Mesa software GL
00763         strstr(gl_vendor,"rian") && strstr(gl_renderer,"X11") &&
00764         strstr(gl_renderer,"esa")
00765     )
00766         software_renderer=true;
00767 
00768     if ( // test for GLX software GL
00769         strstr(gl_renderer,"GLX") &&
00770         strstr(gl_renderer,"ndirect") &&
00771         strstr(gl_renderer,"esa")
00772     )
00773         software_renderer=true;
00774 
00775     // disable storage of non-alpha textures on Savage MX
00776     if ( strstr( gl_renderer, "SavageMX" ) )
00777     {
00778         rISurfaceTexture::storageHack_ = true;
00779     }
00780 
00781     // fonts look best in bilinear filtering, no mipmaps
00782     if ( rTextureGroups::TextureMode[rTextureGroups::TEX_FONT] > GL_LINEAR )
00783         rTextureGroups::TextureMode[rTextureGroups::TEX_FONT] = GL_LINEAR;
00784 
00785     // disable trilinear filtering for ATI cards
00786     if ( strstr( gl_vendor, "ATI" ) )
00787     {
00788         default_texturemode = GL_LINEAR_MIPMAP_NEAREST;
00789     }
00790 
00791     // wait for activation if we were ALT-Tabbed away:
00792     while ( (SDL_GetAppState() & SDL_APPACTIVE) == 0)
00793     {
00794         SDL_Delay(100);
00795         SDL_PumpEvents();
00796     }
00797 
00798     if (software_renderer && !last_software_renderer && !tRecorder::IsPlayingBack())
00799         sr_LoadDefaultConfig();
00800 
00801     last_software_renderer=software_renderer;
00802 
00803 
00804     // wait for activation if we were ALT-Tabbed away:
00805     while ( (SDL_GetAppState() & SDL_APPACTIVE) == 0)
00806     {
00807         SDL_Delay(100);
00808         SDL_PumpEvents();
00809     }
00810 
00811     sr_ResetRenderState(true);
00812 
00813     rCallbackAfterScreenModeChange::Exec();
00814     #endif
00815     return true;

Here is the call graph for this function:

Here is the caller graph for this function:

void sr_Activate ( bool  active  ) 

Definition at line 1100 of file rScreen.cpp.

References currentScreensetting, rCallbackBeforeScreenModeChange::Exec(), and rScreenSettings::fullscreen.

Referenced by Activate().

01102 {
01103     #ifndef DEDICATED
01104     if ( !currentScreensetting.fullscreen && !active && sr_keepWindowActive )
01105     {
01106         sr_glOut=!active;
01107     }
01108     else
01109     {
01110         sr_glOut=active;
01111     }
01112 
01113     // unload textures and stuff if rendering gets disabled
01114     if (!sr_glOut)
01115         rCallbackBeforeScreenModeChange::Exec();
01116 
01117     // Jonathans fullscreen bugfix.
01118     // z-man's ammendmend: apparently, doing this in Linux is painful as well.
01119     // Only on Windows, you get a deactivation event when you ALT-TAB away
01120     // from th application, then iconification is the right thing to do.
01121     // On Linux at least, there is no standard alt-tab for fullscreen applications.
01122 #ifdef WIN32
01123     if ( currentScreensetting.fullscreen && !active )
01124     {
01125         SDL_WM_IconifyWindow();
01126     }
01127     #endif
01128     #endif

Here is the call graph for this function:

Here is the caller graph for this function:

void sr_DepthOffset ( bool  offset  ) 

Definition at line 1074 of file rScreen.cpp.

Referenced by eGrid::display_simple(), gCycle::Render(), gCycleWallsDisplayListManager::RenderAll(), gNetPlayerWall::RenderBegin(), and gNetPlayerWall::RenderNormal().

01075                                 {
01076     // return;
01077     //  if(offset!=offs){
01078     //offs=offset;
01079     #ifndef DEDICATED
01080     if (offset){
01081         //glMatrixMode(GL_PROJECTION);
01082         //glScalef(.9,.9,.9);
01083         glPolygonOffset(-2,-5);
01084         glEnable(GL_POLYGON_OFFSET_LINE);
01085         glEnable(GL_POLYGON_OFFSET_POINT);
01086         glEnable(GL_POLYGON_OFFSET_FILL);
01087     }
01088     else{
01089         glPolygonOffset(0,0);
01090         glDisable(GL_POLYGON_OFFSET_POINT);
01091         glDisable(GL_POLYGON_OFFSET_LINE);
01092         glDisable(GL_POLYGON_OFFSET_FILL);
01093         //glMatrixMode(GL_PROJECTION);
01094         //glScalef(1/.9,1/.9,1/.9);
01095     }
01096     //  }
01097     #endif

Here is the caller graph for this function:

bool sr_DesktopScreensizeSupported (  ) 

Definition at line 119 of file rScreen.cpp.

Referenced by gResMenEntry::gResMenEntry(), and lowlevel_sr_InitDisplay().

00120 {
00121 #ifndef DEDICATED
00122     SDL_version const & sdlVersion = *SDL_Linked_Version();
00123 
00124     return
00125         sdlVersion.major > 1 || sdlVersion.major == 1 &&
00126         ( sdlVersion.minor > 2 || sdlVersion.minor == 2 &&
00127           ( sdlVersion.patch >= 10 ) );
00128 #else
00129     return false;
00130 #endif

Here is the caller graph for this function:

void sr_ExitDisplay (  ) 

Definition at line 889 of file rScreen.cpp.

References rCallbackBeforeScreenModeChange::Exec(), rSysDep::ExitGL(), NULL, sr_LockSDL(), sr_screen, sr_UnlockSDL(), and st_SaveConfig().

Referenced by cleanup(), main(), sr_InitDisplay(), and sr_ReinitDisplay().

00890                      {
00891     #ifndef DEDICATED
00892     rCallbackBeforeScreenModeChange::Exec();
00893 
00894     #ifdef DIRTY
00895     rSysDep::ExitGL();
00896     #endif
00897 
00898     if (sr_screen){
00899         failed_attempts = 0;
00900         st_SaveConfig();
00901 
00902         sr_LockSDL();
00903         // z-man: according to man SDL_SetVideoSurface, screen should not bee freed.
00904         // SDL_FreeSurface(sr_screen);
00905         sr_screen=NULL;
00906         sr_UnlockSDL();
00907         //SDL_Quit();
00908     }
00909     #endif

Here is the call graph for this function:

Here is the caller graph for this function:

bool sr_InitDisplay (  ) 

Definition at line 819 of file rScreen.cpp.

References currentScreensetting, rScreenSettings::fullscreen, lastError, lastSuccess, lowlevel_sr_InitDisplay(), MAXEMERGENCY, sr_ExitDisplay(), sr_LockSDL(), sr_UnlockSDL(), st_SaveConfig(), and tERR_ERROR.

Referenced by main(), and sr_ReinitDisplay().

00820                      {
00821     cycleprograminited = false;
00822     while (failed_attempts <= MAXEMERGENCY+1)
00823     {
00824     #ifndef DEBUG
00825         if (failed_attempts)
00826             currentScreensetting = *emergency[failed_attempts];
00827 
00828         failed_attempts++;
00829         st_SaveConfig();
00830 
00831         //      std::cout << failed_attempts << "\n";
00832         //      std::cout.flush();
00833     #endif
00834 
00835     #ifdef MACOSX
00836         // init the screen once in windowed mode
00837         static bool first = true;
00838         if ( first && currentScreensetting.fullscreen )
00839         {
00840             first = false;
00841             currentScreensetting.fullscreen = false;
00842 
00843             sr_LockSDL();
00844             if (lowlevel_sr_InitDisplay())
00845             {
00846                 sr_ExitDisplay();
00847             }
00848             sr_UnlockSDL();
00849 
00850             currentScreensetting.fullscreen = true;
00851         }
00852     #endif
00853 
00854         sr_LockSDL();
00855         if (lowlevel_sr_InitDisplay())
00856         {
00857             lastSuccess=currentScreensetting;
00858             sr_UnlockSDL();
00859             return true;
00860         }
00861 
00862         st_SaveConfig();
00863 
00864         if (lowlevel_sr_InitDisplay())
00865         {
00866             lastSuccess=currentScreensetting;
00867             sr_UnlockSDL();
00868             return true;
00869         }
00870         sr_UnlockSDL();
00871 
00872 
00873     }
00874 
00875     failed_attempts = 1;
00876     st_SaveConfig();
00877 
00878     tERR_ERROR("\nSorry, played all my cards trying to "
00879                "initialize your video system.\n"
00880                << tOutput("$program_name") << " won't run on your computer. Reason:\n\n"
00881                << lastError
00882                << "\n\nI'll try again from the beginning, but the "
00883                << "chances of success are minimal.\n"
00884               );
00885 
00886     return false;

Here is the call graph for this function:

Here is the caller graph for this function:

void sr_LoadDefaultConfig (  ) 

Definition at line 935 of file rScreen.cpp.

References default_texturemode, rDisplayList_CAC, rDisplayList_Off, rFLOOR_GRID, rFLOOR_TEXTURE, rFLOOR_TWOTEXTURE, rMIRROR_OFF, rSysDep::rSwap_glFinish, rSysDep::rSwap_glFlush, sr_useDisplayLists, rSysDep::swapMode_, rTextureGroups::TEX_FONT, rTextureGroups::TEX_GROUPS, rTextureGroups::TEX_OBJ, and rTextureGroups::TextureMode.

Referenced by lowlevel_sr_InitDisplay(), and welcome().

00936                            {
00937 
00938     // High detail defaults; no problem for your ordinary 3d-card.
00939     sr_alphaBlend=true;
00940     sr_useDisplayLists=rDisplayList_Off;
00941     sr_textOut=true;
00942     sr_dither=true;
00943     sr_smoothShading=true;
00944     int i;
00945     #ifndef DEDICATED
00946     for (i=rTextureGroups::TEX_GROUPS-1;i>=0;i--)
00947         rTextureGroups::TextureMode[i]=default_texturemode;
00948 
00949     // fonts look best in bilinear filtering, no mipmaps
00950     rTextureGroups::TextureMode[rTextureGroups::TEX_FONT]=GL_LINEAR;
00951     #endif
00952     sr_floorDetail=rFLOOR_TWOTEXTURE;
00953     sr_floorMirror=rMIRROR_OFF;
00954     sr_infinityPlane=false;
00955     sr_lowerSky=false;
00956     sr_upperSky=false;
00957     sr_keepWindowActive=false;
00958     rSysDep::swapMode_=rSysDep::rSwap_glFinish;
00959 
00960     if (software_renderer){
00961         // A software renderer! Poor soul. Set low details:
00962         for (i=rTextureGroups::TEX_GROUPS-1;i>=0;i--)
00963             rTextureGroups::TextureMode[i]=-1;
00964 
00965     #ifndef DEDICATED
00966         rTextureGroups::TextureMode[rTextureGroups::TEX_OBJ]=GL_NEAREST_MIPMAP_NEAREST;
00967         rTextureGroups::TextureMode[rTextureGroups::TEX_FONT]=GL_NEAREST_MIPMAP_NEAREST;
00968     #endif
00969 
00970         sr_highRim=false;
00971         sr_dither=false;
00972         sr_alphaBlend=false;
00973         sr_smoothShading=true; // smooth shading does not slow down the
00974         // two tested renderers; leave it it.
00975         sr_floorDetail=rFLOOR_GRID;
00976         sr_floorMirror=rMIRROR_OFF;
00977     }
00978     else if(strstr(gl_vendor,"3Dfx")){
00979         //workaround for 3dfx renderer: aliasing must be turned on
00980         //sr_lineAntialias=rFEAT_OFF;
00981     }
00982     else if(strstr(gl_vendor,"NVIDIA")){
00983         // infinity , display lists and glFlush swapping work for NVIDIA
00984         sr_infinityPlane=true;
00985         sr_useDisplayLists=rDisplayList_CAC;
00986         rSysDep::swapMode_=rSysDep::rSwap_glFlush;
00987     }
00988     #ifdef MACOSX
00989     else if(strstr(gl_vendor,"ATI")){
00990         // glFlush swapping work for ATI on the mac
00991         rSysDep::swapMode_=rSysDep::rSwap_glFlush;
00992     }
00993     #endif
00994     else if(strstr(gl_vendor,"Matrox")){
00995         sr_floorDetail = rFLOOR_TEXTURE;  // double textured floor does not work
00996     }

Here is the caller graph for this function:

void sr_ReinitDisplay (  ) 

Definition at line 365 of file rScreen.cpp.

References sr_ExitDisplay(), sr_InitDisplay(), and tERR_ERROR.

Referenced by sg_ScreenModeMenu(), and toggle_fullscreen_func().

00366                        {
00367     sr_ExitDisplay();
00368     if (!sr_InitDisplay()){
00369         tERR_ERROR("Oops. Failed to reinit video hardware. "
00370                    "Resetting to defaults..\n");
00371         exit(-1);
00372     }
00373 

Here is the call graph for this function:

Here is the caller graph for this function:

void sr_ResetRenderState ( bool  menu  ) 

Definition at line 998 of file rScreen.cpp.

References glMatrixMode, sr_screenHeight, and sr_screenWidth.

Referenced by display_cockpit_lucifer(), uMenu::GenericBackground(), init_game_grid(), lowlevel_sr_InitDisplay(), uMenu::Message(), uMenu::OnEnter(), Render(), cCockpit::Render(), rConsole::Render(), RenderAllViewports(), and welcome().

00999                                    {
01000     if(!sr_glOut)
01001         return;
01002     #ifndef DEDICATED
01003 
01004     // Z-Buffering and perspective correction
01005 
01006     if (menu){
01007         glDisable(GL_DEPTH_TEST);
01008         glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
01009         glViewport (0, 0, GLsizei(sr_screenWidth), GLsizei(sr_screenHeight));
01010     }
01011     else{
01012         glEnable(GL_DEPTH_TEST);
01013         glDepthFunc(GL_LEQUAL);
01014     }
01015 
01016     if (sr_dither)
01017         glEnable(GL_DITHER);
01018     else
01019         glDisable(GL_DITHER);
01020 
01021     glDisable(GL_LIGHTING);
01022 
01023     // disable texture mapping (selecting textures will reactivate it)
01024 
01025     //  glDisable(GL_TEXTURE);
01026     glDisable(GL_TEXTURE_2D);
01027 
01028 
01029     // flat or smooth shading
01030     if (sr_smoothShading)
01031         glShadeModel(GL_SMOOTH);
01032     else
01033         glShadeModel(GL_FLAT);
01034 
01035     // alpha blending
01036     if (sr_alphaBlend){
01037         glEnable(GL_ALPHA_TEST);
01038         glAlphaFunc(GL_GREATER,0);
01039         glEnable(GL_BLEND);
01040         glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
01041     }
01042     else{
01043         glDisable(GL_ALPHA_TEST);
01044         glDisable(GL_BLEND);
01045     }
01046 
01047     // reset matrices
01048     glMatrixMode(GL_TEXTURE);
01049     glLoadIdentity();
01050 
01051     glMatrixMode(GL_PROJECTION);
01052     glLoadIdentity();
01053 
01054     glMatrixMode(GL_MODELVIEW);
01055     glLoadIdentity();
01056     #endif

Here is the caller graph for this function:

bool sr_True (  ) 

Definition at line 185 of file rScreen.cpp.

00186 {return true;}

tCONFIG_ENUM ( rVSync   ) 

tCONFIG_ENUM ( rColorDepth   ) 

tCONFIG_ENUM ( rResolution   ) 


Variable Documentation

REAL aspect[ArmageTron_Custom+2] = {1, 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1, 1, 1 , 1, 1, 1,1, 1} [static]

Definition at line 78 of file rScreen.cpp.

tSettingItem<REAL> at_ca("CUSTOM_SCREEN_ASPECT", aspect[ArmageTron_Custom]) [static]

tSettingItem<int> at_ch("CUSTOM_SCREEN_HEIGHT", height[ArmageTron_Custom]) [static]

tSettingItem<int> at_cw("CUSTOM_SCREEN_WIDTH", width[ArmageTron_Custom]) [static]

tConfItem<bool> check_errors("CHECK_ERRORS", currentScreensetting.checkErrors) [static]

tConfItem<bool> check_errorsl("LAST_CHECK_ERRORS", lastSuccess.checkErrors) [static]

rScreenSettings currentScreensetting(sr_DesktopScreensizeSupported()?ArmageTron_Desktop:ArmageTron_800_600, true)

Referenced by Activate(), filter(), rSysDep::InitGL(), lowlevel_sr_InitDisplay(), main(), rViewport::Perspective(), sg_ScreenModeMenu(), sr_Activate(), sr_InitDisplay(), sr_MotionBlur(), toggle_fullscreen_func(), and rViewport::UpDownFOV().

bool cycleprograminited

Definition at line 100 of file gCycle.cpp.

Referenced by gCycle::Render().

int default_texturemode = GL_LINEAR_MIPMAP_LINEAR [static]

Definition at line 71 of file rScreen.cpp.

Referenced by lowlevel_sr_InitDisplay(), and sr_LoadDefaultConfig().

rScreenSettings em1(ArmageTron_640_480) [static]

rScreenSettings em2(ArmageTron_640_480, true, ArmageTron_ColorDepth_16, false) [static]

rScreenSettings em3(ArmageTron_640_480, true, ArmageTron_ColorDepth_16) [static]

rScreenSettings em4(ArmageTron_640_480, false, ArmageTron_ColorDepth_16) [static]

rScreenSettings em5(ArmageTron_320_240, false, ArmageTron_ColorDepth_Desktop, true, false) [static]

rScreenSettings em6(ArmageTron_320_240, false, ArmageTron_ColorDepth_16, true, false) [static]

rScreenSettings* emergency[MAXEMERGENCY+2] = { &lastSuccess, &lastSuccess, &em1, &em2, &em3 , &em4, &em5, &em6} [static]

Definition at line 110 of file rScreen.cpp.

Referenced by gCycleMovement::TimestepCore().

tConfItem<int> fa("FAILED_ATTEMPTS", failed_attempts) [static]

int failed_attempts = 0 [static]

Definition at line 132 of file rScreen.cpp.

tConfItem<bool> fs_ci("FULLSCREEN", currentScreensetting.fullscreen) [static]

tConfItem<bool> fs_lci("LAST_FULLSCREEN", currentScreensetting.fullscreen) [static]

tString gl_extensions

Definition at line 385 of file rScreen.cpp.

tString gl_renderer

Definition at line 383 of file rScreen.cpp.

Referenced by welcome().

tString gl_vendor

Definition at line 382 of file rScreen.cpp.

Referenced by welcome().

tString gl_version

Definition at line 384 of file rScreen.cpp.

Referenced by welcome().

int height[ArmageTron_Custom+2] = {0, 200, 240, 300, 384, 480, 600, 768 , 800, 854, 1024, 1200, 1050, 1572,600,200} [static]

Definition at line 77 of file rScreen.cpp.

Referenced by DisplayText(), rTextField::GetTextLength(), MenuBackground(), gParser::parseObstacleWall(), gParser::parseWall(), and cWidget::Label::Render().

bool last_software_renderer = false

Definition at line 388 of file rScreen.cpp.

tString lastError("Unknown")

Referenced by lowlevel_sr_InitDisplay(), and sr_InitDisplay().

rScreenSettings lastSuccess(ArmageTron_640_480, false)

Referenced by filter(), sr_InitDisplay(), and rSysDep::SwapGL().

tConfItem<bool> lsr("SOFTWARE_RENDERER", last_software_renderer) [static]

tConfItem<rColorDepth> ltc("LAST_COLORDEPTH", lastSuccess.colorDepth) [static]

tConfItem<rColorDepth> ltzd("LAST_ZDEPTH", lastSuccess.zDepth) [static]

tString renderer_identification

Definition at line 933 of file rScreen.cpp.

Referenced by ConnectToServerCore(), lowlevel_sr_InitDisplay(), and main().

tCallbackString* RenderId_anchor [static]

Definition at line 210 of file rScreen.cpp.

tCallback* rPerFrameTask_anchor [static]

Definition at line 179 of file rScreen.cpp.

tConfItem<rResolution> screenres("ARMAGETRON_SCREENMODE", currentScreensetting.res.res) [static]

tConfItem<int> screenres_h("ARMAGETRON_SCREENMODE_H", currentScreensetting.res.height) [static]

tConfItem<int> screenres_w("ARMAGETRON_SCREENMODE_W", currentScreensetting.res.width) [static]

tConfItem<rResolution> screenresLast("ARMAGETRON_LAST_SCREENMODE", lastSuccess.res.res) [static]

tConfItem<int> screenresLast_h("ARMAGETRON_LAST_SCREENMODE_H", lastSuccess.res.height) [static]

tConfItem<int> screenresLast_w("ARMAGETRON_LAST_SCREENMODE_W", lastSuccess.res.width) [static]

bool software_renderer = false

Definition at line 387 of file rScreen.cpp.

tCallback* sr_AfterAnchor [static]

Definition at line 1145 of file rScreen.cpp.

bool sr_alphaBlend = true

Definition at line 911 of file rScreen.cpp.

Referenced by eGrid::display_simple(), cWidget::Map::DrawRimWalls(), rTextField::FlushLine(), rDisplayListAlphaSensitive::OnCall(), uMenu::OnEnter(), paint_sr_lowerSky(), rFont::ProcessImage(), zShapePolygon::render(), zShapeCircle::render(), gZone::Render(), gCycle::Render(), and gZone::RendersAlpha().

tCallback* sr_BeforeAnchor [static]

Definition at line 1135 of file rScreen.cpp.

bool sr_dither = true

Definition at line 922 of file rScreen.cpp.

int sr_floorDetail = rFLOOR_TEXTURE

Definition at line 917 of file rScreen.cpp.

Referenced by eGrid::display_simple(), gCycle::Render(), and se_FloorColor().

int sr_floorMirror = 0

Definition at line 916 of file rScreen.cpp.

Referenced by finite_xy_plane(), and eGrid::Render().

bool sr_FPSOut = true

Definition at line 929 of file rScreen.cpp.

bool sr_glOut = true

Definition at line 912 of file rScreen.cpp.

Referenced by arrow(), cleanup(), rSysDep::ClearGL(), rViewportConfiguration::DemonstrateViewport(), gLogo::Display(), uMenuItem::DisplayText(), rTextField::FlushLine(), gGame::GameLoop(), uMenu::GenericBackground(), gFloor::glFloorColor(), init_game_grid(), main(), uMenu::Message(), gGame::NetSync(), uMenu::OnEnter(), rISurfaceTexture::OnSelect(), rFont::OnSelect(), rViewport::Perspective(), gServerMenu::Render(), Render(), rModel::Render(), rConsole::Render(), eGrid::Render(), eCamera::Render(), eGameObject::RenderAll(), RenderAllViewports(), ArmageTron_color_menuitem::RenderBackground(), cWidget::NeedleGauge::RenderGraph(), rViewport::Select(), sr_NetSyncThread(), rSysDep::SwapGL(), ePlayerNetID::Update(), welcome(), and rTextField::~rTextField().

bool sr_highRim = true

Definition at line 918 of file rScreen.cpp.

Referenced by eGrid::display_simple(), eWallRim::eWallRim(), and infinity_xy_plane().

bool sr_infinityPlane = false

Definition at line 923 of file rScreen.cpp.

Referenced by gWallRim_helper(), and infinity_xy_plane().

bool sr_keepWindowActive = false

Definition at line 931 of file rScreen.cpp.

Referenced by sg_ScreenModeMenu().

bool sr_laggometer = true

Definition at line 924 of file rScreen.cpp.

Referenced by net_options(), and gCycle::Render().

bool sr_lowerSky = false

Definition at line 920 of file rScreen.cpp.

Referenced by gWallRim_helper(), and eGrid::Render().

bool sr_predictObjects = false

Definition at line 925 of file rScreen.cpp.

Referenced by net_options(), gNetPlayerWall::RealWallReceived(), gCycle::Render(), gAIPlayer::ThinkCloseCombat(), and eGameObject::TimestepThisWrapper().

SDL_Surface* sr_screen = NULL

Definition at line 68 of file rScreen.cpp.

Referenced by rConsole::DoPrint(), lowlevel_sr_InitDisplay(), rConsole::Render(), and sr_ExitDisplay().

int sr_screenHeight

Definition at line 80 of file rScreen.cpp.

Referenced by rFontContainer::BBox(), display_cockpit_lucifer(), rViewport::EqualAspectBottom(), filter(), rFontContainer::GetFont(), rFontContainer::GetWidth(), lowlevel_sr_InitDisplay(), make_screenshot(), MenuBackground(), rViewport::Perspective(), cCockpit::Readjust(), rFontContainer::Render(), rConsole::Render(), rTextField::rTextField(), SDL_SavePNG(), rViewport::Select(), sr_MotionBlur(), sr_MotionBlurCore(), sr_ResetRenderState(), su_TransformEvent(), and rViewport::UpDownFOV().

int sr_screenWidth

Definition at line 80 of file rScreen.cpp.

Referenced by rFontContainer::BBox(), display_cockpit_lucifer(), rViewport::EqualAspectBottom(), filter(), rFontContainer::GetWidth(), lowlevel_sr_InitDisplay(), make_screenshot(), MenuBackground(), rViewport::Perspective(), cCockpit::ProcessCockpit(), cCockpit::Readjust(), cWidget::Map::Render(), cCockpit::Render(), rFontContainer::Render(), rConsole::Render(), SDL_SavePNG(), rViewport::Select(), sr_MotionBlur(), sr_MotionBlurCore(), sr_ResetRenderState(), su_TransformEvent(), and rViewport::UpDownFOV().

bool sr_skyWobble = true

Definition at line 921 of file rScreen.cpp.

Referenced by paint_sr_lowerSky().

bool sr_smoothShading = true

Definition at line 913 of file rScreen.cpp.

bool sr_textOut = false

Definition at line 928 of file rScreen.cpp.

Referenced by gServerBrowser::BrowseLAN(), gServerBrowser::BrowseSpecialMaster(), ConnectToServerCore(), rConsole::DoPrint(), MainMenu(), uMenu::Message(), rConsole::Render(), and welcome().

bool sr_texturesTruecolor = false

Definition at line 926 of file rScreen.cpp.

Referenced by rISurfaceTexture::Upload().

bool sr_upperSky = false

Definition at line 919 of file rScreen.cpp.

Referenced by gWallRim_helper(), and eGrid::Render().

rDisplayListUsage sr_useDisplayLists = rDisplayList_Off

Definition at line 74 of file rScreen.cpp.

Referenced by sr_LoadDefaultConfig(), rDisplayListFiller::Start(), and rDisplayListFiller::Stop().

tConfItem<rColorDepth> tc("COLORDEPTH", currentScreensetting.colorDepth) [static]

Referenced by main(), SWIG_Ruby_ConvertPacked(), SWIG_Ruby_ConvertPtrAndOwn(), and SWIG_TypeClientData().

tConfItem<rColorDepth> tzd("ZDEPTH", currentScreensetting.zDepth) [static]

tConfItem<rVSync> vSync("ARMAGETRON_VSYNC", currentScreensetting.vSync) [static]

tConfItem<rVSync> vSyncLast("ARMAGETRON_VSYNC_LAST", lastSuccess.vSync) [static]

int width[ArmageTron_Custom+2] = {0, 320, 320, 400, 512, 640, 800, 1024 , 1280, 1280, 1280, 1600, 1680, 2048,800,320} [static]

Definition at line 76 of file rScreen.cpp.

Referenced by MenuBackground(), cWidget::Label::Render(), and rConsole::Render().

tConfItem<rResolution> winsize("ARMAGETRON_WINDOWSIZE", currentScreensetting.windowSize.res) [static]

Referenced by sg_ScreenModeMenu().

tConfItem<int> winsize_h("ARMAGETRON_WINDOWSIZE_H", currentScreensetting.windowSize.height) [static]

tConfItem<int> winsize_w("ARMAGETRON_WINDOWSIZE_W", currentScreensetting.windowSize.width) [static]

tConfItem<rResolution> winsizeLast("ARMAGETRON_LAST_WINDOWSIZE", lastSuccess.windowSize.res) [static]

tConfItem<int> winsizeLast_h("ARMAGETRON_LAST_WINDOWSIZE_H", lastSuccess.windowSize.height) [static]

tConfItem<int> winsizeLast_w("ARMAGETRON_LAST_WINDOWSIZE_W", lastSuccess.windowSize.width) [static]


Generated on Sat Mar 15 23:03:33 2008 for Armagetron Advanced by  doxygen 1.5.4