Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/graphics/graphics_engine.cc @ 3610

Last change on this file since 3610 was 3610, checked in by bensch, 19 years ago

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

File size: 2.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
17
18#include "graphics_engine.h"
19
20using namespace std;
21
22
23/**
24   \brief standard constructor
25   \todo this constructor is not jet implemented - do it
26*/
27GraphicsEngine::GraphicsEngine () 
28{
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;
105}
106
107
108/**
109   \brief standard deconstructor
110
111*/
112GraphicsEngine::~GraphicsEngine () 
113{
114  // delete what has to be deleted here
115}
116
Note: See TracBrowser for help on using the repository browser.