Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/collision_detection/src/lib/graphics/graphics_engine.h @ 6776

Last change on this file since 6776 was 5366, checked in by bensch, 19 years ago

orxonox/trunk: more definitions of GLGui.
also a patch to the resource-manager

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