Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: more fixes due to valgrind

File size: 3.6 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
[4381]17// Forward Declaration
[4245]18class Text;
[4770]19class IniParser;
[3543]20
[4458]21//! class to handle graphics
22/**
23   handles graphical SDL-initialisation, textures, resolutions, and so on
[4619]24 */
[4817]25class GraphicsEngine : public EventListener
[3610]26{
[4619]27  public:
28    virtual ~GraphicsEngine();
[4836]29    /** @returns a Pointer to the only object of this Class */
[5216]30    inline static GraphicsEngine* getInstance() { if (!GraphicsEngine::singletonRef) GraphicsEngine::singletonRef = new GraphicsEngine();  return GraphicsEngine::singletonRef; };
[1853]31
[4784]32    int init();
33    int initFromIniFile(IniParser* iniParser);
[4374]34
[4619]35    void setWindowName(const char* windowName, const char* icon);
[4831]36
[4619]37    int setResolution(int width, int height, int bpp);
38    void setFullscreen(bool fullscreen = false);
39    static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
[3611]40
[4831]41
[4836]42    /** @returns the x resolution */
[4746]43    inline int getResolutionX() const { return this->resolutionX; };
[4836]44    /** @returns the y resolution */
[4746]45    inline int getResolutionY() const { return this->resolutionY; };
[4836]46    /** @returns the Bits Per Pixel */
[4746]47    inline int getbbp() const { return this->bitsPerPixel; };
[3611]48
[4782]49    int resolutionChanged(const SDL_ResizeEvent& resizeInfo);
[3790]50
[4833]51    static void showMouse(bool show);
52    static bool isMouseVisible();
53    static void stealWMEvents(bool steal);
54    static bool isStealingEvents();
[4831]55
[4746]56    static void enter2DMode();
57    static void leave2DMode();
[3844]58
[4746]59    static void storeMatrices();
[4619]60    static GLdouble modMat[16];
61    static GLdouble projMat[16];
62    static GLint viewPort[4];
[3844]63
[5084]64    void update(float dt);
[4619]65    void tick(float dt);
[4849]66    void draw() const;
[4619]67    void displayFPS(bool display);
[3245]68
[4746]69    void listModes();
[3617]70
[4681]71    /** \brief swaps the GL_BUFFERS */
[4834]72    inline static void swapBuffers() { SDL_GL_SwapBuffers(); };
[4681]73
[4817]74    void process(const Event  &event);
[4619]75
76  private:
77    GraphicsEngine();
[4784]78    int initVideo(unsigned int resX, unsigned int resY, unsigned int bbp);
[4831]79    int setGLattribs();
[4619]80
[4784]81  public:
82    static bool             texturesEnabled; //!< if textures should be enabled (globally)
83
84
[4619]85  private:
[4784]86    static GraphicsEngine*  singletonRef;    //!< Pointer to the only instance of this Class
87    bool                    isInit;          //!< if the GraphicsEngine is initialized.
[4619]88
[4784]89    SDL_Surface*            screen;          //!< the screen we draw to
90    int                     resolutionX;     //!< the X-resoultion of the screen
91    int                     resolutionY;     //!< the Y-resolution of the screen
92    int                     bitsPerPixel;    //!< the bits per pixels of the screen
93    Uint32                  fullscreenFlag;  //!< if we are in fullscreen mode
94    Uint32                  videoFlags;      //!< flags for video
95    SDL_Rect**              videoModes;      //!< list of resolutions
[4619]96
[4784]97    bool                    bDisplayFPS;     //!< is true if the fps should be displayed
98    float                   currentFPS;      //!< the current frame rate: frames per seconds
99    float                   maxFPS;          //!< maximal frame rate we ever got since start of the game
100    float                   minFPS;          //!< minimal frame rate we ever got since start
[4619]101
102
[4536]103#ifndef NO_TEXT
[4458]104  Text*          geTextCFPS;      //!< Text for the current FPS
105  Text*          geTextMaxFPS;    //!< Text for the max FPS
106  Text*          geTextMinFPS;    //!< Text for the min FPS
[4536]107#endif /* NO_TEXT */
[1853]108};
109
[3610]110#endif /* _GRAPHICS_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.