Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/graphics/graphics_engine.h @ 8479

Last change on this file since 8479 was 8475, checked in by bensch, 18 years ago

yeah a fullscreen button :)

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#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
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    void 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
72    void drawBackgroundElements() const;
73    void draw() const;
74    void displayFPS(bool display);
75
76    void listModes();
77    bool hwSupportsEXT(const std::string& extension);
78
79    /** @brief swaps the GL_BUFFERS */
80    inline static void swapBuffers() { SDL_GL_SwapBuffers(); };
81
82    void process(const Event  &event);
83
84    void loadGraphicsEffects(const TiXmlElement* root);
85
86
87
88  private:
89    GraphicsEngine();
90    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
91    void setGLattribs();
92    void grabHardwareSettings();
93
94  public:
95
96  private:
97    static GraphicsEngine*     singletonRef;       //!< Pointer to the only instance of this Class
98    bool                       isInit;             //!< if the GraphicsEngine is initialized.
99
100    // state.
101    SDL_Surface*               screen;             //!< the screen we draw to
102    int                        resolutionX;        //!< the X-resoultion of the screen
103    int                        resolutionY;        //!< the Y-resolution of the screen
104    int                        bitsPerPixel;       //!< the bits per pixels of the screen
105    Uint32                     fullscreenFlag;     //!< if we are in fullscreen mode
106    Uint32                     videoFlags;         //!< flags for video
107    SDL_Rect**                 videoModes;         //!< list of resolutions
108
109    bool                       fogEnabled;         //!< If Fog should be enabled.
110    bool                       shadowsEnabled;     //!< If Shadows should be enabled.
111    bool                       particlesEnabled;   //!< If particles should be enabled.
112    int                        particlesValue;     //!< How many particles
113    int                        textureQuality;     //!< the quality of Textures
114    int                        filteringMethod;    //!< The filtering Method of textures.
115    int                        modelQuality;       //!< The quality of the Models loaded.
116    int                        antialiasingDepth;  //!< the Depth of the AntiAlias-Filter.
117
118    // HARDWARE-Settings:
119    std::string                hwRenderer;         //!< HW-renderer-string
120    std::string                hwVendor;           //!< HW-vendor-string
121    std::string                hwVersion;          //!< HW-version-string
122    SubString                  hwExtensions;       //!< All suported Extensions.
123
124    // FPS-related
125    bool                       bDisplayFPS;        //!< is true if the fps should be displayed
126    float                      currentFPS;         //!< the current frame rate: frames per seconds
127    float                      maxFPS;             //!< maximal frame rate we ever got since start of the game
128    float                      minFPS;             //!< minimal frame rate we ever got since start.
129
130    const std::list<BaseObject*>* graphicsEffects; //!< list of graphics effects
131
132
133#ifndef NO_TEXT
134  Text*          geTextCFPS;                    //!< Text for the current FPS
135  Text*          geTextMaxFPS;                  //!< Text for the max FPS
136  Text*          geTextMinFPS;                  //!< Text for the min FPS
137#endif /* NO_TEXT */
138};
139
140#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.