Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3617 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
Mar 21, 2005, 2:59:30 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: little fix to graphicsEngine, now the different resolution-types are outputted. also there is a fix from debug.h all warnings are shown now

Location:
orxonox/trunk/src/lib/graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r3611 r3617  
    3030{
    3131  this->setClassName ("GraphicsEngine");
    32  
    3332  this->initVideo();
     33
     34  this->listModes();
     35
    3436
    3537}
     
    6062int GraphicsEngine::initVideo()
    6163{
    62 
     64  // initialize SDL_VIDEO
    6365  if (SDL_Init(SDL_INIT_VIDEO) == -1)
    6466    {
    65       printf ("could not initialize SDL Video\n");
     67      PRINTF(1)("could not initialize SDL Video\n");
    6668      //      return -1;
    6769    }
     70  // initialize SDL_GL-settings
     71  this->setGLattribs();
     72
     73  // setting the Video Flags.
     74  this->videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE;
     75
     76  /* query SDL for information about our video hardware */
     77  const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
     78  if( videoInfo == NULL)
     79    {
     80      PRINTF(1)("Failed getting Video Info :%s\n", SDL_GetError());
     81      SDL_Quit ();
     82    }
     83  if( videoInfo->hw_available)
     84    this->videoFlags |= SDL_HWSURFACE;
     85  else
     86    this->videoFlags |= SDL_SWSURFACE;
     87  /*
     88  if(VideoInfo -> blit_hw)                           
     89    VideoFlags |= SDL_HWACCEL;
     90  */
     91
     92  // setting up the Resolution
     93  this->setResoulution(800, 600, 16);
     94 
     95  // Set window labeling
     96  SDL_WM_SetCaption ("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION);
     97 
     98  // TO DO: Create a cool icon and use it here
     99  // SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); 
     100
     101}
     102
     103
     104int GraphicsEngine::setGLattribs(void)
     105{
    68106  // Set video mode
    69107  // TO DO: parse arguments for settings
     
    81119  SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
    82120  SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
    83 
    84 
    85   //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/
    86   //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER;
    87 
    88   this->videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE;
    89 
    90   /* query SDL for information about our video hardware */
    91   const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
    92  
    93   if( videoInfo == NULL)
    94     {
    95       PRINTF(1)("Orxonox::initVideo() - Failed getting Video Info :%s\n", SDL_GetError());
    96       SDL_Quit ();
    97     }
    98   if( videoInfo->hw_available)
    99     this->videoFlags |= SDL_HWSURFACE;
    100   else
    101     this->videoFlags |= SDL_SWSURFACE;
    102   /*
    103   if(VideoInfo -> blit_hw)                           
    104     VideoFlags |= SDL_HWACCEL;
    105   */
    106 
    107   this->setResoulution(800, 600, 16);
    108  
    109   // Set window labeling
    110   SDL_WM_SetCaption ("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION);
    111  
    112   // TO DO: Create a cool icon and use it here
    113   // SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); 
    114 
    115121}
    116122
     
    129135
    130136}
     137
     138
     139
     140
     141
     142
     143
     144/**
     145   \brief outputs all the Fullscreen modes.
     146*/
     147void GraphicsEngine::listModes(void)
     148{
     149  /* Get available fullscreen/hardware modes */
     150  this->videoModes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
     151 
     152  /* Check is there are any modes available */
     153  if(this->videoModes == (SDL_Rect **)0){
     154    PRINTF(1)("No modes available!\n");
     155    exit(-1);
     156  }
     157 
     158  /* Check if our resolution is restricted */
     159  if(this->videoModes == (SDL_Rect **)-1){
     160    PRINTF(1)("All resolutions available.\n");
     161  }
     162  else{
     163    /* Print valid modes */
     164    PRINT(0)("Available Resoulution Modes are\n");
     165    for(int i = 0; this->videoModes[i]; ++i)
     166      PRINT(0)(" |  %d x %d\n", this->videoModes[i]->w, this->videoModes[i]->h);
     167  }
     168 
     169}
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r3611 r3617  
    2424
    2525  int initVideo();
     26  int setGLattribs(void);
    2627  int setResoulution(int width, int height, int bpp);
     28  void listModes(void);
    2729
    2830  static bool texturesEnabled;
     
    3941  bool fullscreen;
    4042  Uint32 videoFlags;
     43
     44  SDL_Rect **videoModes;
    4145};
    4246
Note: See TracChangeset for help on using the changeset viewer.