Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9696 was 9406, checked in by bensch, 18 years ago

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

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