Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: ini-parser small cleanup char* → const char*

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