Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6579 was 6522, checked in by bensch, 19 years ago

trunk: switch to WireFrame with
Shell → GraphicsEngine wireframe

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    void wireframe();
64
65    static void storeMatrices();
66    static GLdouble modMat[16];
67    static GLdouble projMat[16];
68    static GLint viewPort[4];
69
70    void update(float dt);
71    void tick(float dt);
72    void draw() const;
73    void draw(const std::list<WorldEntity*>& drawList) const;
74    void displayFPS(bool display);
75
76    void listModes();
77    bool hwSupportsEXT(const char* 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  private:
85    GraphicsEngine();
86    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
87    int setGLattribs();
88    void grabHardwareSettings();
89
90  public:
91
92  private:
93    static GraphicsEngine*  singletonRef;       //!< Pointer to the only instance of this Class
94    bool                    isInit;             //!< if the GraphicsEngine is initialized.
95
96    // state.
97    SDL_Surface*            screen;             //!< the screen we draw to
98    int                     resolutionX;        //!< the X-resoultion of the screen
99    int                     resolutionY;        //!< the Y-resolution of the screen
100    int                     bitsPerPixel;       //!< the bits per pixels of the screen
101    Uint32                  fullscreenFlag;     //!< if we are in fullscreen mode
102    Uint32                  videoFlags;         //!< flags for video
103    SDL_Rect**              videoModes;         //!< list of resolutions
104
105    bool                    fogEnabled;         //!< If Fog should be enabled.
106    bool                    shadowsEnabled;     //!< If Shadows should be enabled.
107    bool                    particlesEnabled;   //!< If particles should be enabled.
108    int                     particlesValue;     //!< How many particles
109    int                     textureQuality;     //!< the quality of Textures
110    int                     filteringMethod;    //!< The filtering Method of textures.
111    int                     modelQuality;       //!< The quality of the Models loaded.
112    int                     antialiasingDepth;  //!< the Depth of the AntiAlias-Filter.
113
114    // HARDWARE-Settings:
115    char*                   hwRenderer;         //!< HW-renderer-string
116    char*                   hwVendor;           //!< HW-vendor-string
117    char*                   hwVersion;          //!< HW-version-string
118    SubString*              hwExtensions;       //!< All suported Extensions.
119
120    // FPS-related
121    bool                    bDisplayFPS;        //!< is true if the fps should be displayed
122    float                   currentFPS;         //!< the current frame rate: frames per seconds
123    float                   maxFPS;             //!< maximal frame rate we ever got since start of the game
124    float                   minFPS;             //!< minimal frame rate we ever got since start.
125
126#ifndef NO_TEXT
127  Text*          geTextCFPS;                    //!< Text for the current FPS
128  Text*          geTextMaxFPS;                  //!< Text for the max FPS
129  Text*          geTextMinFPS;                  //!< Text for the min FPS
130#endif /* NO_TEXT */
131};
132
133#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.