Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/shared_lib/src/lib/graphics/graphics_engine.h @ 7178

Last change on this file since 7178 was 6990, checked in by bensch, 19 years ago

orxonox/trunk: better mouse capture now

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