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