Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: structure of the Shader-lib

File size: 3.9 KB
Line 
1/*!
2 * @file graphics_engine.h
3
4  *  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 "event_listener.h"
13
14#include "sdlincl.h"
15#include "glincl.h"
16
17// Forward Declaration
18class Text;
19class IniParser;
20class SubString;
21
22//! class to handle graphics
23/**
24   handles graphical SDL-initialisation, textures, resolutions, and so on
25 */
26class GraphicsEngine : public EventListener
27{
28  public:
29    virtual ~GraphicsEngine();
30    /** @returns a Pointer to the only object of this Class */
31    inline static GraphicsEngine* getInstance() { if (!GraphicsEngine::singletonRef) GraphicsEngine::singletonRef = new GraphicsEngine();  return GraphicsEngine::singletonRef; };
32
33    int init();
34    int initFromIniFile(IniParser* iniParser);
35
36    void setWindowName(const char* windowName, const char* icon);
37
38    int setResolution(int width, int height, int bpp);
39    void setFullscreen(bool fullscreen = false);
40    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
41
42
43    /** @returns the x resolution */
44    inline int getResolutionX() const { return this->resolutionX; };
45    /** @returns the y resolution */
46    inline int getResolutionY() const { return this->resolutionY; };
47    /** @returns the Bits Per Pixel */
48    inline int getbbp() const { return this->bitsPerPixel; };
49
50    int resolutionChanged(const SDL_ResizeEvent& resizeInfo);
51
52    static void showMouse(bool show);
53    static bool isMouseVisible();
54    static void stealWMEvents(bool steal);
55    static bool isStealingEvents();
56
57    static void enter2DMode();
58    static void leave2DMode();
59
60    static void storeMatrices();
61    static GLdouble modMat[16];
62    static GLdouble projMat[16];
63    static GLint viewPort[4];
64
65    void update(float dt);
66    void tick(float dt);
67    void draw() const;
68    void displayFPS(bool display);
69
70    void listModes();
71    bool hwSupportsEXT(const char* extension);
72
73    /** \brief swaps the GL_BUFFERS */
74    inline static void swapBuffers() { SDL_GL_SwapBuffers(); };
75
76    void process(const Event  &event);
77
78  private:
79    GraphicsEngine();
80    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
81    int setGLattribs();
82    void grabHardwareSettings();
83
84  public:
85    static bool             texturesEnabled; //!< if textures should be enabled (globally)
86
87
88  private:
89    static GraphicsEngine*  singletonRef;    //!< Pointer to the only instance of this Class
90    bool                    isInit;          //!< if the GraphicsEngine is initialized.
91
92    SDL_Surface*            screen;          //!< the screen we draw to
93    int                     resolutionX;     //!< the X-resoultion of the screen
94    int                     resolutionY;     //!< the Y-resolution of the screen
95    int                     bitsPerPixel;    //!< the bits per pixels of the screen
96    Uint32                  fullscreenFlag;  //!< if we are in fullscreen mode
97    Uint32                  videoFlags;      //!< flags for video
98    SDL_Rect**              videoModes;      //!< list of resolutions
99
100    bool                    bDisplayFPS;     //!< is true if the fps should be displayed
101    float                   currentFPS;      //!< the current frame rate: frames per seconds
102    float                   maxFPS;          //!< maximal frame rate we ever got since start of the game
103    float                   minFPS;          //!< minimal frame rate we ever got since start
104
105    // HARDWARE-Settings:
106    char*                   hwRenderer;
107    char*                   hwVendor;
108    char*                   hwVersion;
109    SubString*              hwExtensions;
110
111#ifndef NO_TEXT
112  Text*          geTextCFPS;      //!< Text for the current FPS
113  Text*          geTextMaxFPS;    //!< Text for the max FPS
114  Text*          geTextMinFPS;    //!< Text for the min FPS
115#endif /* NO_TEXT */
116};
117
118#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.