Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3610 in orxonox.OLD for orxonox/trunk/src/lib


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

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

Location:
orxonox/trunk/src/lib/graphics
Files:
2 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) {}
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r3609 r3610  
    11/*!
    2     \file proto_class.h
    3     \brief Definition of the proto class template, used quickly start work
    4     \todo Example: this shows how to use simply add a Marker that here has to be done something.
     2    \file graphics_engine.h
     3   
     4    \brief defines a Interface between orxonox and graphical input
    55
    6     The Protoclass exists, to help you quikly getting the run for how to develop in orxonox.
    7     It is an example for the CODING-CONVENTION, and a starting-point for every class.
     6    handles graphical SDL-initialisation, textures, resolutions, and so on
    87*/
    98
    10 #ifndef _PROTO_CLASS_H
    11 #define _PROTO_CLASS_H
     9#ifndef _GRAPHICS_ENGINE_H
     10#define _GRAPHICS_ENGINE_H
    1211
    13 #include "what realy has to be included"
     12#include <SDL/SDL.h>
     13
    1414#include "base_object.h"
    1515
    1616// FORWARD DEFINITION \\
    17 class someClassWeNeed;
    1817
    1918
    20 /*class Test;*/ /* forward definition of class Test (without including it here!)*/
    21 
    22 //! A default class that aids you to start creating a new class
    23 /**
    24    here can be some longer description of this class
    25 */
    26 class ProtoClass : public BaseObject {
    27 
     19class GraphicsEngine : public BaseObject
     20{
    2821 public:
    29   ProtoClass();
    30   virtual ~ProtoClass();
    31 
    32   bool doNonSense (int nothing);
     22  static GraphicsEngine* getInstance();
     23  virtual ~GraphicsEngine();
    3324
    3425 private:
    35   int nonSense;  //!< doxygen tag here like this for all the variables - delete this variable if you use this
     26  GraphicsEngine();
     27  static GraphicsEngine* singletonRef;
    3628
     29
     30  SDL_Surface* screen;
    3731};
    3832
    39 #endif /* _PROTO_CLASS_H */
     33#endif /* _GRAPHICS_ENGINE_H */
Note: See TracChangeset for help on using the changeset viewer.