Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10519 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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