Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8490 was 8490, checked in by patrick, 18 years ago

merged the bsp branche back to trunk

File size: 5.2 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#include <list>
17
18#include "substring.h"
19
20// Forward Declaration
21class Text;
22class WorldEntity;
23class GraphicsEffect;
24class TiXmlElement;
25
26//! class to handle graphics
27/**
28   handles graphical SDL-initialisation, textures, resolutions, and so on
29 */
30class GraphicsEngine : public EventListener
31{
32  public:
33    virtual ~GraphicsEngine();
34    /** @returns a Pointer to the only object of this Class */
35    inline static GraphicsEngine* getInstance() { if (!GraphicsEngine::singletonRef) GraphicsEngine::singletonRef = new GraphicsEngine();  return GraphicsEngine::singletonRef; };
36
37    virtual void loadParams(const TiXmlElement* root);
38
39    int init();
40    int initFromPreferences();
41
42    void setWindowName(const std::string& windowName, const std::string& icon);
43
44    int setResolution(int width, int height, int bpp);
45    void setFullscreen(bool fullscreen = false);
46    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
47
48    inline void setAntialiasing(bool flag) { this->bAntialiasing = flag; }
49    inline bool getAntialiasing() { return this->bAntialiasing; }
50
51    /** @returns the x resolution */
52    inline int getResolutionX() const { return this->resolutionX; };
53    /** @returns the y resolution */
54    inline int getResolutionY() const { return this->resolutionY; };
55    /** @returns the Bits Per Pixel */
56    inline int getbbp() const { return this->bitsPerPixel; };
57
58    void resolutionChanged(const SDL_ResizeEvent& resizeInfo);
59
60    static void enter2DMode();
61    static void leave2DMode();
62
63    void wireframe();
64
65    static void storeMatrices();
66    static GLdouble modMat[16];
67    static GLdouble projMat[16];
68    static GLint viewPort[4];
69
70    void update(float dt);
71    void tick(float dt);
72
73    void drawBackgroundElements() const;
74    void draw() const;
75    void displayFPS(bool display);
76
77    void listModes();
78    bool hwSupportsEXT(const std::string& extension);
79
80    /** @brief swaps the GL_BUFFERS */
81    inline static void swapBuffers() { SDL_GL_SwapBuffers(); };
82
83    void process(const Event  &event);
84
85    void loadGraphicsEffects(const TiXmlElement* root);
86
87
88
89  private:
90    GraphicsEngine();
91    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
92    void setGLattribs();
93    void grabHardwareSettings();
94
95  public:
96
97  private:
98    static GraphicsEngine*     singletonRef;       //!< Pointer to the only instance of this Class
99    bool                       isInit;             //!< if the GraphicsEngine is initialized.
100
101    // state.
102    SDL_Surface*               screen;             //!< the screen we draw to
103    int                        resolutionX;        //!< the X-resoultion of the screen
104    int                        resolutionY;        //!< the Y-resolution of the screen
105    int                        bitsPerPixel;       //!< the bits per pixels of the screen
106    Uint32                     fullscreenFlag;     //!< if we are in fullscreen mode
107    Uint32                     videoFlags;         //!< flags for video
108    SDL_Rect**                 videoModes;         //!< list of resolutions
109
110    bool                       fogEnabled;         //!< If Fog should be enabled.
111    bool                       shadowsEnabled;     //!< If Shadows should be enabled.
112    bool                       particlesEnabled;   //!< If particles should be enabled.
113    bool                       bAntialiasing;      //!< true if antialiasing enabled
114
115    int                        particlesValue;     //!< How many particles
116    int                        textureQuality;     //!< the quality of Textures
117    int                        filteringMethod;    //!< The filtering Method of textures.
118    int                        modelQuality;       //!< The quality of the Models loaded.
119    int                        antialiasingDepth;  //!< the Depth of the AntiAlias-Filter.
120
121    // HARDWARE-Settings:
122    std::string                hwRenderer;         //!< HW-renderer-string
123    std::string                hwVendor;           //!< HW-vendor-string
124    std::string                hwVersion;          //!< HW-version-string
125    SubString                  hwExtensions;       //!< All suported Extensions.
126
127    // FPS-related
128    bool                       bDisplayFPS;        //!< is true if the fps should be displayed
129    float                      currentFPS;         //!< the current frame rate: frames per seconds
130    float                      maxFPS;             //!< maximal frame rate we ever got since start of the game
131    float                      minFPS;             //!< minimal frame rate we ever got since start.
132
133    const std::list<BaseObject*>* graphicsEffects; //!< list of graphics effects
134
135
136#ifndef NO_TEXT
137  Text*          geTextCFPS;                    //!< Text for the current FPS
138  Text*          geTextMaxFPS;                  //!< Text for the max FPS
139  Text*          geTextMinFPS;                  //!< Text for the min FPS
140#endif /* NO_TEXT */
141};
142
143#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.