Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/graphics/graphics_engine.h @ 8475

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

yeah a fullscreen button :)

File size: 5.0 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);
[8475]46    void toggleFullscreen();
[4619]47    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
[3611]48
[4831]49
[4836]50    /** @returns the x resolution */
[4746]51    inline int getResolutionX() const { return this->resolutionX; };
[4836]52    /** @returns the y resolution */
[4746]53    inline int getResolutionY() const { return this->resolutionY; };
[4836]54    /** @returns the Bits Per Pixel */
[4746]55    inline int getbbp() const { return this->bitsPerPixel; };
[3611]56
[8316]57    void resolutionChanged(const SDL_ResizeEvent& resizeInfo);
[3790]58
[4746]59    static void enter2DMode();
60    static void leave2DMode();
[3844]61
[6522]62    void wireframe();
63
[4746]64    static void storeMatrices();
[4619]65    static GLdouble modMat[16];
66    static GLdouble projMat[16];
67    static GLint viewPort[4];
[3844]68
[5084]69    void update(float dt);
[4619]70    void tick(float dt);
[7840]71
72    void drawBackgroundElements() const;
[4849]73    void draw() const;
[4619]74    void displayFPS(bool display);
[3245]75
[4746]76    void listModes();
[7221]77    bool hwSupportsEXT(const std::string& extension);
[3617]78
[5366]79    /** @brief swaps the GL_BUFFERS */
[4834]80    inline static void swapBuffers() { SDL_GL_SwapBuffers(); };
[4681]81
[4817]82    void process(const Event  &event);
[4619]83
[6979]84    void loadGraphicsEffects(const TiXmlElement* root);
[6753]85
86
87
[4619]88  private:
89    GraphicsEngine();
[4784]90    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
[8316]91    void setGLattribs();
[5260]92    void grabHardwareSettings();
[4619]93
[4784]94  public:
95
[4619]96  private:
[6753]97    static GraphicsEngine*     singletonRef;       //!< Pointer to the only instance of this Class
98    bool                       isInit;             //!< if the GraphicsEngine is initialized.
[4619]99
[5346]100    // state.
[6753]101    SDL_Surface*               screen;             //!< the screen we draw to
102    int                        resolutionX;        //!< the X-resoultion of the screen
103    int                        resolutionY;        //!< the Y-resolution of the screen
104    int                        bitsPerPixel;       //!< the bits per pixels of the screen
105    Uint32                     fullscreenFlag;     //!< if we are in fullscreen mode
106    Uint32                     videoFlags;         //!< flags for video
107    SDL_Rect**                 videoModes;         //!< list of resolutions
[4619]108
[6753]109    bool                       fogEnabled;         //!< If Fog should be enabled.
110    bool                       shadowsEnabled;     //!< If Shadows should be enabled.
111    bool                       particlesEnabled;   //!< If particles should be enabled.
112    int                        particlesValue;     //!< How many particles
113    int                        textureQuality;     //!< the quality of Textures
114    int                        filteringMethod;    //!< The filtering Method of textures.
115    int                        modelQuality;       //!< The quality of the Models loaded.
116    int                        antialiasingDepth;  //!< the Depth of the AntiAlias-Filter.
[4619]117
[5260]118    // HARDWARE-Settings:
[7221]119    std::string                hwRenderer;         //!< HW-renderer-string
120    std::string                hwVendor;           //!< HW-vendor-string
121    std::string                hwVersion;          //!< HW-version-string
122    SubString                  hwExtensions;       //!< All suported Extensions.
[4619]123
[5346]124    // FPS-related
[6753]125    bool                       bDisplayFPS;        //!< is true if the fps should be displayed
126    float                      currentFPS;         //!< the current frame rate: frames per seconds
127    float                      maxFPS;             //!< maximal frame rate we ever got since start of the game
128    float                      minFPS;             //!< minimal frame rate we ever got since start.
[5346]129
[6979]130    const std::list<BaseObject*>* graphicsEffects; //!< list of graphics effects
[6753]131
132
[4536]133#ifndef NO_TEXT
[5346]134  Text*          geTextCFPS;                    //!< Text for the current FPS
135  Text*          geTextMaxFPS;                  //!< Text for the max FPS
136  Text*          geTextMinFPS;                  //!< Text for the min FPS
[4536]137#endif /* NO_TEXT */
[1853]138};
139
[3610]140#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.