Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8506 was 8490, checked in by patrick, 18 years ago

merged the bsp branche back to trunk

File size: 5.2 KB
RevLine 
[4619]1/*!
[5039]2 * @file graphics_engine.h
[4619]3
[4836]4  *  defines a Interface between orxonox and graphical input
[3329]5
[3610]6    handles graphical SDL-initialisation, textures, resolutions, and so on
[4817]7 */
[1853]8
[3610]9#ifndef _GRAPHICS_ENGINE_H
10#define _GRAPHICS_ENGINE_H
[1853]11
[4817]12#include "event_listener.h"
[1853]13
[4381]14#include "sdlincl.h"
15#include "glincl.h"
[6142]16#include <list>
17
[7221]18#include "substring.h"
19
[4381]20// Forward Declaration
[4245]21class Text;
[6142]22class WorldEntity;
[6753]23class GraphicsEffect;
[6815]24class TiXmlElement;
[3543]25
[4458]26//! class to handle graphics
27/**
28   handles graphical SDL-initialisation, textures, resolutions, and so on
[4619]29 */
[4817]30class GraphicsEngine : public EventListener
[3610]31{
[4619]32  public:
33    virtual ~GraphicsEngine();
[4836]34    /** @returns a Pointer to the only object of this Class */
[5216]35    inline static GraphicsEngine* getInstance() { if (!GraphicsEngine::singletonRef) GraphicsEngine::singletonRef = new GraphicsEngine();  return GraphicsEngine::singletonRef; };
[1853]36
[6815]37    virtual void loadParams(const TiXmlElement* root);
38
[4784]39    int init();
[7256]40    int initFromPreferences();
[4374]41
[7221]42    void setWindowName(const std::string& windowName, const std::string& icon);
[4831]43
[4619]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);
[3611]47
[8490]48    inline void setAntialiasing(bool flag) { this->bAntialiasing = flag; }
49    inline bool getAntialiasing() { return this->bAntialiasing; }
[4831]50
[4836]51    /** @returns the x resolution */
[4746]52    inline int getResolutionX() const { return this->resolutionX; };
[4836]53    /** @returns the y resolution */
[4746]54    inline int getResolutionY() const { return this->resolutionY; };
[4836]55    /** @returns the Bits Per Pixel */
[4746]56    inline int getbbp() const { return this->bitsPerPixel; };
[3611]57
[8316]58    void resolutionChanged(const SDL_ResizeEvent& resizeInfo);
[3790]59
[4746]60    static void enter2DMode();
61    static void leave2DMode();
[3844]62
[6522]63    void wireframe();
64
[4746]65    static void storeMatrices();
[4619]66    static GLdouble modMat[16];
67    static GLdouble projMat[16];
68    static GLint viewPort[4];
[3844]69
[5084]70    void update(float dt);
[4619]71    void tick(float dt);
[7840]72
73    void drawBackgroundElements() const;
[4849]74    void draw() const;
[4619]75    void displayFPS(bool display);
[3245]76
[4746]77    void listModes();
[7221]78    bool hwSupportsEXT(const std::string& extension);
[3617]79
[5366]80    /** @brief swaps the GL_BUFFERS */
[4834]81    inline static void swapBuffers() { SDL_GL_SwapBuffers(); };
[4681]82
[4817]83    void process(const Event  &event);
[4619]84
[6979]85    void loadGraphicsEffects(const TiXmlElement* root);
[6753]86
87
88
[4619]89  private:
90    GraphicsEngine();
[4784]91    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
[8316]92    void setGLattribs();
[5260]93    void grabHardwareSettings();
[4619]94
[4784]95  public:
96
[4619]97  private:
[6753]98    static GraphicsEngine*     singletonRef;       //!< Pointer to the only instance of this Class
99    bool                       isInit;             //!< if the GraphicsEngine is initialized.
[4619]100
[5346]101    // state.
[6753]102    SDL_Surface*               screen;             //!< the screen we draw to
103    int                        resolutionX;        //!< the X-resoultion of the screen
104    int                        resolutionY;        //!< the Y-resolution of the screen
105    int                        bitsPerPixel;       //!< the bits per pixels of the screen
106    Uint32                     fullscreenFlag;     //!< if we are in fullscreen mode
107    Uint32                     videoFlags;         //!< flags for video
108    SDL_Rect**                 videoModes;         //!< list of resolutions
[4619]109
[6753]110    bool                       fogEnabled;         //!< If Fog should be enabled.
111    bool                       shadowsEnabled;     //!< If Shadows should be enabled.
112    bool                       particlesEnabled;   //!< If particles should be enabled.
[8490]113    bool                       bAntialiasing;      //!< true if antialiasing enabled
114
[6753]115    int                        particlesValue;     //!< How many particles
116    int                        textureQuality;     //!< the quality of Textures
117    int                        filteringMethod;    //!< The filtering Method of textures.
118    int                        modelQuality;       //!< The quality of the Models loaded.
119    int                        antialiasingDepth;  //!< the Depth of the AntiAlias-Filter.
[4619]120
[5260]121    // HARDWARE-Settings:
[7221]122    std::string                hwRenderer;         //!< HW-renderer-string
123    std::string                hwVendor;           //!< HW-vendor-string
124    std::string                hwVersion;          //!< HW-version-string
125    SubString                  hwExtensions;       //!< All suported Extensions.
[4619]126
[5346]127    // FPS-related
[6753]128    bool                       bDisplayFPS;        //!< is true if the fps should be displayed
129    float                      currentFPS;         //!< the current frame rate: frames per seconds
130    float                      maxFPS;             //!< maximal frame rate we ever got since start of the game
131    float                      minFPS;             //!< minimal frame rate we ever got since start.
[5346]132
[6979]133    const std::list<BaseObject*>* graphicsEffects; //!< list of graphics effects
[6753]134
135
[4536]136#ifndef NO_TEXT
[5346]137  Text*          geTextCFPS;                    //!< Text for the current FPS
138  Text*          geTextMaxFPS;                  //!< Text for the max FPS
139  Text*          geTextMinFPS;                  //!< Text for the min FPS
[4536]140#endif /* NO_TEXT */
[1853]141};
142
[3610]143#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.