Changeset 3611 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Mar 21, 2005, 11:44:37 AM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/graphics_engine.cc
r3610 r3611 18 18 #include "graphics_engine.h" 19 19 20 #include "debug.h" 21 20 22 using namespace std; 21 23 … … 27 29 GraphicsEngine::GraphicsEngine () 28 30 { 29 this->setClassName ("GraphicsEngine"); 31 this->setClassName ("GraphicsEngine"); 32 33 this->initVideo(); 34 35 } 36 37 GraphicsEngine* GraphicsEngine::singletonRef = NULL; 38 39 GraphicsEngine* GraphicsEngine::getInstance() 40 { 41 if (!GraphicsEngine::singletonRef) 42 GraphicsEngine::singletonRef = new GraphicsEngine(); 43 return GraphicsEngine::singletonRef; 44 } 30 45 31 46 47 /** 48 \brief destructs the graphicsEngine. 49 */ 50 GraphicsEngine::~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 */ 60 int GraphicsEngine::initVideo() 61 { 32 62 33 63 if (SDL_Init(SDL_INIT_VIDEO) == -1) … … 53 83 54 84 55 56 int bpp = 16;57 int width = 640;58 int height = 480;59 85 //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/ 60 86 //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER; 61 87 62 Uint32videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE;88 this->videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE; 63 89 64 90 /* query SDL for information about our video hardware */ … … 67 93 if( videoInfo == NULL) 68 94 { 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()); 70 96 SDL_Quit (); 71 97 } 72 98 if( videoInfo->hw_available) 73 videoFlags |= SDL_HWSURFACE;99 this->videoFlags |= SDL_HWSURFACE; 74 100 else 75 videoFlags |= SDL_SWSURFACE;101 this->videoFlags |= SDL_SWSURFACE; 76 102 /* 77 103 if(VideoInfo -> blit_hw) 78 104 VideoFlags |= SDL_HWACCEL; 79 105 */ 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); 87 108 88 109 // Set window labeling … … 92 113 // SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); 93 114 115 } 94 116 117 int 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 } 95 129 96 130 } 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 deconstructor110 111 */112 GraphicsEngine::~GraphicsEngine ()113 {114 // delete what has to be deleted here115 }116 -
orxonox/trunk/src/lib/graphics/graphics_engine.h
r3610 r3611 10 10 #define _GRAPHICS_ENGINE_H 11 11 12 #include <SDL/SDL.h>12 #include "glincl.h" 13 13 14 14 #include "base_object.h" … … 23 23 virtual ~GraphicsEngine(); 24 24 25 int initVideo(); 26 int setResoulution(int width, int height, int bpp); 27 28 static bool texturesEnabled; 29 25 30 private: 26 31 GraphicsEngine(); … … 29 34 30 35 SDL_Surface* screen; 36 int resolutionX; 37 int resolutionY; 38 int bitsPerPixel; 39 bool fullscreen; 40 Uint32 videoFlags; 31 41 }; 32 42 -
orxonox/trunk/src/orxonox.cc
r3610 r3611 56 56 if( localcamera != NULL) delete localcamera; 57 57 if( resources != NULL) delete resources; 58 delete GraphicsEngine::getInstance(); // deleting the Graphics 58 59 } 59 60 … … 113 114 int Orxonox::initVideo() 114 115 { 115 printf("> Initializing video\n");116 PRINTF(3)("> Initializing video\n"); 116 117 117 118 GraphicsEngine::getInstance();
Note: See TracChangeset
for help on using the changeset viewer.