[4619] | 1 | /*! |
---|
[3610] | 2 | \file graphics_engine.h |
---|
[4619] | 3 | |
---|
[3610] | 4 | \brief defines a Interface between orxonox and graphical input |
---|
[3329] | 5 | |
---|
[3610] | 6 | handles graphical SDL-initialisation, textures, resolutions, and so on |
---|
[3245] | 7 | */ |
---|
[1853] | 8 | |
---|
[3610] | 9 | #ifndef _GRAPHICS_ENGINE_H |
---|
| 10 | #define _GRAPHICS_ENGINE_H |
---|
[1853] | 11 | |
---|
[3543] | 12 | #include "base_object.h" |
---|
[1853] | 13 | |
---|
[4381] | 14 | #include "sdlincl.h" |
---|
| 15 | #include "glincl.h" |
---|
[3543] | 16 | |
---|
[4381] | 17 | // Forward Declaration |
---|
[4245] | 18 | class Text; |
---|
[3543] | 19 | |
---|
[4458] | 20 | //! class to handle graphics |
---|
| 21 | /** |
---|
| 22 | handles graphical SDL-initialisation, textures, resolutions, and so on |
---|
[4619] | 23 | */ |
---|
| 24 | class GraphicsEngine : public BaseObject |
---|
[3610] | 25 | { |
---|
[4619] | 26 | public: |
---|
| 27 | virtual ~GraphicsEngine(); |
---|
| 28 | /** \returns a Pointer to the only object of this Class */ |
---|
[4746] | 29 | inline static GraphicsEngine* getInstance() { if (!singletonRef) singletonRef = new GraphicsEngine(); return singletonRef; }; |
---|
[1853] | 30 | |
---|
[4619] | 31 | int initVideo(); |
---|
[4374] | 32 | |
---|
[4619] | 33 | void setWindowName(const char* windowName, const char* icon); |
---|
[4746] | 34 | int setGLattribs(); |
---|
[4619] | 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); |
---|
[3611] | 38 | |
---|
[4619] | 39 | /** \returns the x resolution */ |
---|
[4746] | 40 | inline int getResolutionX() const { return this->resolutionX; }; |
---|
[4619] | 41 | /** \returns the y resolution */ |
---|
[4746] | 42 | inline int getResolutionY() const { return this->resolutionY; }; |
---|
[4619] | 43 | /** \returns the Bits Per Pixel */ |
---|
[4746] | 44 | inline int getbbp() const { return this->bitsPerPixel; }; |
---|
[3611] | 45 | |
---|
[4619] | 46 | int resolutionChanged(SDL_ResizeEvent* resizeInfo); |
---|
[3790] | 47 | |
---|
[4746] | 48 | static void enter2DMode(); |
---|
| 49 | static void leave2DMode(); |
---|
[3844] | 50 | |
---|
[4746] | 51 | static void storeMatrices(); |
---|
[4619] | 52 | static GLdouble modMat[16]; |
---|
| 53 | static GLdouble projMat[16]; |
---|
| 54 | static GLint viewPort[4]; |
---|
[3844] | 55 | |
---|
[4619] | 56 | void tick(float dt); |
---|
| 57 | void displayFPS(bool display); |
---|
[3245] | 58 | |
---|
[4746] | 59 | void listModes(); |
---|
[3617] | 60 | |
---|
[4681] | 61 | /** \brief swaps the GL_BUFFERS */ |
---|
[4746] | 62 | static void swapBuffers() { SDL_GL_SwapBuffers(); }; |
---|
[4681] | 63 | |
---|
[4619] | 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 |
---|
[4768] | 77 | Uint32 fullscreenFlag; //!< if we are in fullscreen mode |
---|
[4619] | 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 | |
---|
[4536] | 87 | #ifndef NO_TEXT |
---|
[4458] | 88 | Text* geTextCFPS; //!< Text for the current FPS |
---|
| 89 | Text* geTextMaxFPS; //!< Text for the max FPS |
---|
| 90 | Text* geTextMinFPS; //!< Text for the min FPS |
---|
[4536] | 91 | #endif /* NO_TEXT */ |
---|
[1853] | 92 | }; |
---|
| 93 | |
---|
[3610] | 94 | #endif /* _GRAPHICS_ENGINE_H */ |
---|