Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Mar 21, 2005, 11:44:37 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: one step further with the gragpicsEngine

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

Legend:

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

    r3610 r3611  
    1818#include "graphics_engine.h"
    1919
     20#include "debug.h"
     21
    2022using namespace std;
    2123
     
    2729GraphicsEngine::GraphicsEngine ()
    2830{
    29    this->setClassName ("GraphicsEngine");
     31  this->setClassName ("GraphicsEngine");
     32 
     33  this->initVideo();
     34
     35}
     36
     37GraphicsEngine* GraphicsEngine::singletonRef = NULL;
     38
     39GraphicsEngine* GraphicsEngine::getInstance()
     40{
     41  if (!GraphicsEngine::singletonRef)
     42    GraphicsEngine::singletonRef = new GraphicsEngine();
     43  return GraphicsEngine::singletonRef;
     44}
    3045
    3146
     47/**
     48   \brief destructs the graphicsEngine.
     49*/
     50GraphicsEngine::~GraphicsEngine ()
     51{
     52  // delete what has to be deleted here
     53}
     54
     55/**
     56   \brief initializes the Video for openGL.
     57
     58   This has to be done only once when starting orxonox.
     59*/
     60int GraphicsEngine::initVideo()
     61{
    3262
    3363  if (SDL_Init(SDL_INIT_VIDEO) == -1)
     
    5383
    5484
    55 
    56   int bpp = 16;
    57   int width = 640;
    58   int height = 480;
    5985  //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/
    6086  //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER;
    6187
    62   Uint32 videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE;
     88  this->videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE;
    6389
    6490  /* query SDL for information about our video hardware */
     
    6793  if( videoInfo == NULL)
    6894    {
    69       printf ("Orxonox::initVideo() - Failed getting Video Info :%s\n", SDL_GetError());
     95      PRINTF(1)("Orxonox::initVideo() - Failed getting Video Info :%s\n", SDL_GetError());
    7096      SDL_Quit ();
    7197    }
    7298  if( videoInfo->hw_available)
    73     videoFlags |= SDL_HWSURFACE;
     99    this->videoFlags |= SDL_HWSURFACE;
    74100  else
    75     videoFlags |= SDL_SWSURFACE;
     101    this->videoFlags |= SDL_SWSURFACE;
    76102  /*
    77103  if(VideoInfo -> blit_hw)                           
    78104    VideoFlags |= SDL_HWACCEL;
    79105  */
    80  
    81   if((this->screen = SDL_SetVideoMode (width, height, bpp, videoFlags)) == NULL)
    82   {
    83     printf("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", width, height, bpp, videoFlags, SDL_GetError());
    84     SDL_Quit();
    85     //    return -1;
    86   }
     106
     107  this->setResoulution(800, 600, 16);
    87108 
    88109  // Set window labeling
     
    92113  // SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); 
    93114
     115}
    94116
     117int GraphicsEngine::setResoulution(int width, int height, int bpp)
     118{
     119  this->resolutionX = width;
     120  this->resolutionY = height;
     121  this->bitsPerPixel = bpp;
     122 
     123  if((this->screen = SDL_SetVideoMode (this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags)) == NULL)
     124    {
     125      PRINTF(1)("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", this->resolutionX, this->resolutionY, this->bitsPerPixel, this->videoFlags, SDL_GetError());
     126      SDL_Quit();
     127      //    return -1;
     128    }
    95129
    96130}
    97 
    98 GraphicsEngine* GraphicsEngine::singletonRef = NULL;
    99 
    100 GraphicsEngine* GraphicsEngine::getInstance()
    101 {
    102   if (!GraphicsEngine::singletonRef)
    103     GraphicsEngine::singletonRef = new GraphicsEngine();
    104   return GraphicsEngine::singletonRef;
    105 }
    106 
    107 
    108 /**
    109    \brief standard deconstructor
    110 
    111 */
    112 GraphicsEngine::~GraphicsEngine ()
    113 {
    114   // delete what has to be deleted here
    115 }
    116 
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r3610 r3611  
    1010#define _GRAPHICS_ENGINE_H
    1111
    12 #include <SDL/SDL.h>
     12#include "glincl.h"
    1313
    1414#include "base_object.h"
     
    2323  virtual ~GraphicsEngine();
    2424
     25  int initVideo();
     26  int setResoulution(int width, int height, int bpp);
     27
     28  static bool texturesEnabled;
     29
    2530 private:
    2631  GraphicsEngine();
     
    2934
    3035  SDL_Surface* screen;
     36  int resolutionX;
     37  int resolutionY;
     38  int bitsPerPixel;
     39  bool fullscreen;
     40  Uint32 videoFlags;
    3141};
    3242
Note: See TracChangeset for help on using the changeset viewer.