Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6787 was 6753, checked in by patrick, 19 years ago

trunk: merged network back to trunk

File size: 5.1 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"
[3543]16
[6142]17#include <list>
18
[4381]19// Forward Declaration
[4245]20class Text;
[4770]21class IniParser;
[5260]22class SubString;
[6142]23class WorldEntity;
[6753]24class GraphicsEffect;
[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
[4784]37    int init();
38    int initFromIniFile(IniParser* iniParser);
[4374]39
[4619]40    void setWindowName(const char* windowName, const char* icon);
[4831]41
[4619]42    int setResolution(int width, int height, int bpp);
43    void setFullscreen(bool fullscreen = false);
44    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
[3611]45
[4831]46
[4836]47    /** @returns the x resolution */
[4746]48    inline int getResolutionX() const { return this->resolutionX; };
[4836]49    /** @returns the y resolution */
[4746]50    inline int getResolutionY() const { return this->resolutionY; };
[4836]51    /** @returns the Bits Per Pixel */
[4746]52    inline int getbbp() const { return this->bitsPerPixel; };
[3611]53
[4782]54    int resolutionChanged(const SDL_ResizeEvent& resizeInfo);
[3790]55
[4833]56    static void showMouse(bool show);
57    static bool isMouseVisible();
58    static void stealWMEvents(bool steal);
59    static bool isStealingEvents();
[4831]60
[4746]61    static void enter2DMode();
62    static void leave2DMode();
[3844]63
[6522]64    void wireframe();
65
[4746]66    static void storeMatrices();
[4619]67    static GLdouble modMat[16];
68    static GLdouble projMat[16];
69    static GLint viewPort[4];
[3844]70
[5084]71    void update(float dt);
[4619]72    void tick(float dt);
[4849]73    void draw() const;
[6142]74    void draw(const std::list<WorldEntity*>& drawList) const;
[4619]75    void displayFPS(bool display);
[3245]76
[4746]77    void listModes();
[5261]78    bool hwSupportsEXT(const char* 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
[6753]85    bool loadGraphicsEffect(GraphicsEffect* effect);
86    bool unloadGraphicsEffect(GraphicsEffect* effect);
87
88
89
[4619]90  private:
91    GraphicsEngine();
[4784]92    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
[4831]93    int setGLattribs();
[5260]94    void grabHardwareSettings();
[4619]95
[4784]96  public:
97
[4619]98  private:
[6753]99    static GraphicsEngine*     singletonRef;       //!< Pointer to the only instance of this Class
100    bool                       isInit;             //!< if the GraphicsEngine is initialized.
[4619]101
[5346]102    // state.
[6753]103    SDL_Surface*               screen;             //!< the screen we draw to
104    int                        resolutionX;        //!< the X-resoultion of the screen
105    int                        resolutionY;        //!< the Y-resolution of the screen
106    int                        bitsPerPixel;       //!< the bits per pixels of the screen
107    Uint32                     fullscreenFlag;     //!< if we are in fullscreen mode
108    Uint32                     videoFlags;         //!< flags for video
109    SDL_Rect**                 videoModes;         //!< list of resolutions
[4619]110
[6753]111    bool                       fogEnabled;         //!< If Fog should be enabled.
112    bool                       shadowsEnabled;     //!< If Shadows should be enabled.
113    bool                       particlesEnabled;   //!< If particles should be enabled.
114    int                        particlesValue;     //!< How many particles
115    int                        textureQuality;     //!< the quality of Textures
116    int                        filteringMethod;    //!< The filtering Method of textures.
117    int                        modelQuality;       //!< The quality of the Models loaded.
118    int                        antialiasingDepth;  //!< the Depth of the AntiAlias-Filter.
[4619]119
[5260]120    // HARDWARE-Settings:
[6753]121    char*                      hwRenderer;         //!< HW-renderer-string
122    char*                      hwVendor;           //!< HW-vendor-string
123    char*                      hwVersion;          //!< HW-version-string
124    SubString*                 hwExtensions;       //!< All suported Extensions.
[4619]125
[5346]126    // FPS-related
[6753]127    bool                       bDisplayFPS;        //!< is true if the fps should be displayed
128    float                      currentFPS;         //!< the current frame rate: frames per seconds
129    float                      maxFPS;             //!< maximal frame rate we ever got since start of the game
130    float                      minFPS;             //!< minimal frame rate we ever got since start.
[5346]131
[6753]132    std::list<GraphicsEffect*> graphicsEffects;    //!< list of graphics effects
133
134
[4536]135#ifndef NO_TEXT
[5346]136  Text*          geTextCFPS;                    //!< Text for the current FPS
137  Text*          geTextMaxFPS;                  //!< Text for the max FPS
138  Text*          geTextMinFPS;                  //!< Text for the min FPS
[4536]139#endif /* NO_TEXT */
[1853]140};
141
[3610]142#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.