Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7616 was 7256, checked in by bensch, 19 years ago

orxonox/trunk: merged the preferences back to the trunk
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/preferences . -r7233:HEAD
no conflicts… nice work

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