Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/graphics/graphics_engine.h @ 4770

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

orxonox/trunk: GraphicsEngine now parses the INI-file

File size: 3.0 KB
Line 
1/*!
2    \file graphics_engine.h
3
4    \brief defines a Interface between orxonox and graphical input
5
6    handles graphical SDL-initialisation, textures, resolutions, and so on
7*/
8
9#ifndef _GRAPHICS_ENGINE_H
10#define _GRAPHICS_ENGINE_H
11
12#include "base_object.h"
13
14#include "sdlincl.h"
15#include "glincl.h"
16
17// Forward Declaration
18class Text;
19class IniParser;
20
21//! class to handle graphics
22/**
23   handles graphical SDL-initialisation, textures, resolutions, and so on
24 */
25class GraphicsEngine : public BaseObject
26{
27  public:
28    virtual ~GraphicsEngine();
29    /** \returns a Pointer to the only object of this Class */
30    inline static GraphicsEngine* getInstance() { if (!singletonRef) singletonRef = new GraphicsEngine();  return singletonRef; };
31
32    int initVideo();
33    int loadFromIniFile(IniParser* iniParser, const char* section);
34
35    void setWindowName(const char* windowName, const char* icon);
36    int setGLattribs();
37    int setResolution(int width, int height, int bpp);
38    void setFullscreen(bool fullscreen = false);
39    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
40
41    /** \returns the x resolution */
42    inline int getResolutionX() const { return this->resolutionX; };
43    /** \returns the y resolution */
44    inline int getResolutionY() const { return this->resolutionY; };
45    /** \returns the Bits Per Pixel */
46    inline int getbbp() const { return this->bitsPerPixel; };
47
48    int resolutionChanged(SDL_ResizeEvent* resizeInfo);
49
50    static void enter2DMode();
51    static void leave2DMode();
52
53    static void storeMatrices();
54    static GLdouble modMat[16];
55    static GLdouble projMat[16];
56    static GLint viewPort[4];
57
58    void tick(float dt);
59    void displayFPS(bool display);
60
61    void listModes();
62
63    /** \brief swaps the GL_BUFFERS */
64    static void swapBuffers() { SDL_GL_SwapBuffers(); };
65
66  public:
67    static bool texturesEnabled;
68
69  private:
70    GraphicsEngine();
71
72  private:
73    static GraphicsEngine* singletonRef;
74
75    SDL_Surface*   screen;          //!< the screen we draw to
76    int            resolutionX;     //!< the X-resoultion of the screen
77    int            resolutionY;     //!< the Y-resolution of the screen
78    int            bitsPerPixel;    //!< the bits per pixels of the screen
79    Uint32         fullscreenFlag;  //!< if we are in fullscreen mode
80    Uint32         videoFlags;      //!< flags for video
81    SDL_Rect**     videoModes;      //!< list of resolutions
82
83    bool           bDisplayFPS;     //!< is true if the fps should be displayed
84    float          currentFPS;      //!< the current frame rate: frames per seconds
85    float          maxFPS;          //!< maximal frame rate we ever got since start of the game
86    float          minFPS;          //!< minimal frame rate we ever got since start
87
88
89#ifndef NO_TEXT
90  Text*          geTextCFPS;      //!< Text for the current FPS
91  Text*          geTextMaxFPS;    //!< Text for the max FPS
92  Text*          geTextMinFPS;    //!< Text for the min FPS
93#endif /* NO_TEXT */
94};
95
96#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.