Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/spaceshipcontrol/src/lib/graphics/graphics_engine.h @ 6104

Last change on this file since 6104 was 5857, checked in by bensch, 19 years ago

orxonox/trunk: enableTexture now a property of Texture and not GraphicsEngine → Texture is a Leaf now

@patrick: as you said so long ago, this is the better idea

File size: 4.7 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
86  private:
87    static GraphicsEngine*  singletonRef;       //!< Pointer to the only instance of this Class
88    bool                    isInit;             //!< if the GraphicsEngine is initialized.
89
90    // state.
91    SDL_Surface*            screen;             //!< the screen we draw to
92    int                     resolutionX;        //!< the X-resoultion of the screen
93    int                     resolutionY;        //!< the Y-resolution of the screen
94    int                     bitsPerPixel;       //!< the bits per pixels of the screen
95    Uint32                  fullscreenFlag;     //!< if we are in fullscreen mode
96    Uint32                  videoFlags;         //!< flags for video
97    SDL_Rect**              videoModes;         //!< list of resolutions
98
99    bool                    fogEnabled;         //!< If Fog should be enabled.
100    bool                    shadowsEnabled;     //!< If Shadows should be enabled.
101    bool                    particlesEnabled;   //!< If particles should be enabled.
102    int                     particlesValue;     //!< How many particles
103    int                     textureQuality;     //!< the quality of Textures
104    int                     filteringMethod;    //!< The filtering Method of textures.
105    int                     modelQuality;       //!< The quality of the Models loaded.
106    int                     antialiasingDepth;  //!< the Depth of the AntiAlias-Filter.
107
108    // HARDWARE-Settings:
109    char*                   hwRenderer;         //!< HW-renderer-string
110    char*                   hwVendor;           //!< HW-vendor-string
111    char*                   hwVersion;          //!< HW-version-string
112    SubString*              hwExtensions;       //!< All suported Extensions.
113
114    // FPS-related
115    bool                    bDisplayFPS;        //!< is true if the fps should be displayed
116    float                   currentFPS;         //!< the current frame rate: frames per seconds
117    float                   maxFPS;             //!< maximal frame rate we ever got since start of the game
118    float                   minFPS;             //!< minimal frame rate we ever got since start.
119
120#ifndef NO_TEXT
121  Text*          geTextCFPS;                    //!< Text for the current FPS
122  Text*          geTextMaxFPS;                  //!< Text for the max FPS
123  Text*          geTextMinFPS;                  //!< Text for the min FPS
124#endif /* NO_TEXT */
125};
126
127#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.