Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 21, 2005, 1:36:16 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: first definition of the Grahpics-class. more to follow, (and to read about)

File:
1 copied

Legend:

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

    r3609 r3610  
    1 
    2 
    31/*
    42   orxonox - the future of 3D-vertical-scrollers
     
    1210
    1311   ### File Specific:
    14    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1513   co-programmer: ...
    1614*/
    1715
    18 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
    1917
    20 #include "proto_class.h"
    21 
    22 #include "stdincl.h" // maybe
     18#include "graphics_engine.h"
    2319
    2420using namespace std;
     
    2925   \todo this constructor is not jet implemented - do it
    3026*/
    31 ProtoClass::ProtoClass ()
     27GraphicsEngine::GraphicsEngine ()
    3228{
    33    this->setClassName ("ProtoClass");
     29   this->setClassName ("GraphicsEngine");
     30
     31
     32
     33  if (SDL_Init(SDL_INIT_VIDEO) == -1)
     34    {
     35      printf ("could not initialize SDL Video\n");
     36      //      return -1;
     37    }
     38  // Set video mode
     39  // TO DO: parse arguments for settings
     40  //SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
     41  //SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
     42  //SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
     43  //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
     44 
     45
     46  SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );   
     47  SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);   
     48  SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); 
     49  SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0);
     50  SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0);
     51  SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
     52  SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
     53
     54
     55
     56  int bpp = 16;
     57  int width = 640;
     58  int height = 480;
     59  //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/
     60  //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER;
     61
     62  Uint32 videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE;
     63
     64  /* query SDL for information about our video hardware */
     65  const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
     66 
     67  if( videoInfo == NULL)
     68    {
     69      printf ("Orxonox::initVideo() - Failed getting Video Info :%s\n", SDL_GetError());
     70      SDL_Quit ();
     71    }
     72  if( videoInfo->hw_available)
     73    videoFlags |= SDL_HWSURFACE;
     74  else
     75    videoFlags |= SDL_SWSURFACE;
     76  /*
     77  if(VideoInfo -> blit_hw)                           
     78    VideoFlags |= SDL_HWACCEL;
     79  */
     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  }
     87 
     88  // Set window labeling
     89  SDL_WM_SetCaption ("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION);
     90 
     91  // TO DO: Create a cool icon and use it here
     92  // SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); 
     93
     94
     95
     96}
     97
     98GraphicsEngine* GraphicsEngine::singletonRef = NULL;
     99
     100GraphicsEngine* GraphicsEngine::getInstance()
     101{
     102  if (!GraphicsEngine::singletonRef)
     103    GraphicsEngine::singletonRef = new GraphicsEngine();
     104  return GraphicsEngine::singletonRef;
    34105}
    35106
     
    39110
    40111*/
    41 ProtoClass::~ProtoClass ()
     112GraphicsEngine::~GraphicsEngine ()
    42113{
    43114  // delete what has to be deleted here
    44115}
    45116
    46 /**
    47    \brief nonsense - delete this method
    48    \param realy nothing to give
    49    \returns true or false - probably nothing?
    50 
    51    this is just to show the doxygen abilities (this for example is an extension for a long comment)
    52 */
    53 bool ProtoClass::doNonSense (int nothing) {}
Note: See TracChangeset for help on using the changeset viewer.