Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/powerups/src/lib/graphics/graphics_engine.h @ 6479

Last change on this file since 6479 was 6142, checked in by bensch, 19 years ago

orxonox/trunk: merge the ObjectManager to the trunk
merged with command:
svn merge -r6082:HEAD objectmanager/ ../trunk/

conflicts resolution was easy this time :)
but specially merged the world to network_world

File size: 4.8 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;
24
25//! class to handle graphics
26/**
27   handles graphical SDL-initialisation, textures, resolutions, and so on
28 */
29class GraphicsEngine : public EventListener
30{
31  public:
32    virtual ~GraphicsEngine();
33    /** @returns a Pointer to the only object of this Class */
34    inline static GraphicsEngine* getInstance() { if (!GraphicsEngine::singletonRef) GraphicsEngine::singletonRef = new GraphicsEngine();  return GraphicsEngine::singletonRef; };
35
36    int init();
37    int initFromIniFile(IniParser* iniParser);
38
39    void setWindowName(const char* windowName, const char* icon);
40
41    int setResolution(int width, int height, int bpp);
42    void setFullscreen(bool fullscreen = false);
43    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
44
45
46    /** @returns the x resolution */
47    inline int getResolutionX() const { return this->resolutionX; };
48    /** @returns the y resolution */
49    inline int getResolutionY() const { return this->resolutionY; };
50    /** @returns the Bits Per Pixel */
51    inline int getbbp() const { return this->bitsPerPixel; };
52
53    int resolutionChanged(const SDL_ResizeEvent& resizeInfo);
54
55    static void showMouse(bool show);
56    static bool isMouseVisible();
57    static void stealWMEvents(bool steal);
58    static bool isStealingEvents();
59
60    static void enter2DMode();
61    static void leave2DMode();
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 char* 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  private:
83    GraphicsEngine();
84    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
85    int setGLattribs();
86    void grabHardwareSettings();
87
88  public:
89
90  private:
91    static GraphicsEngine*  singletonRef;       //!< Pointer to the only instance of this Class
92    bool                    isInit;             //!< if the GraphicsEngine is initialized.
93
94    // state.
95    SDL_Surface*            screen;             //!< the screen we draw to
96    int                     resolutionX;        //!< the X-resoultion of the screen
97    int                     resolutionY;        //!< the Y-resolution of the screen
98    int                     bitsPerPixel;       //!< the bits per pixels of the screen
99    Uint32                  fullscreenFlag;     //!< if we are in fullscreen mode
100    Uint32                  videoFlags;         //!< flags for video
101    SDL_Rect**              videoModes;         //!< list of resolutions
102
103    bool                    fogEnabled;         //!< If Fog should be enabled.
104    bool                    shadowsEnabled;     //!< If Shadows should be enabled.
105    bool                    particlesEnabled;   //!< If particles should be enabled.
106    int                     particlesValue;     //!< How many particles
107    int                     textureQuality;     //!< the quality of Textures
108    int                     filteringMethod;    //!< The filtering Method of textures.
109    int                     modelQuality;       //!< The quality of the Models loaded.
110    int                     antialiasingDepth;  //!< the Depth of the AntiAlias-Filter.
111
112    // HARDWARE-Settings:
113    char*                   hwRenderer;         //!< HW-renderer-string
114    char*                   hwVendor;           //!< HW-vendor-string
115    char*                   hwVersion;          //!< HW-version-string
116    SubString*              hwExtensions;       //!< All suported Extensions.
117
118    // FPS-related
119    bool                    bDisplayFPS;        //!< is true if the fps should be displayed
120    float                   currentFPS;         //!< the current frame rate: frames per seconds
121    float                   maxFPS;             //!< maximal frame rate we ever got since start of the game
122    float                   minFPS;             //!< minimal frame rate we ever got since start.
123
124#ifndef NO_TEXT
125  Text*          geTextCFPS;                    //!< Text for the current FPS
126  Text*          geTextMaxFPS;                  //!< Text for the max FPS
127  Text*          geTextMinFPS;                  //!< Text for the min FPS
128#endif /* NO_TEXT */
129};
130
131#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.