Crazy Eddies GUI System: irrlichtrenderer.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# irrlichtrenderer.h

    00001 /************************************************************************
    00002         filename:       irrlichtrenderer.h
    00003         created:        20/7/2004
    00004         author:         Thomas Suter
    00005 *************************************************************************/
    00006 /*************************************************************************
    00007     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00008     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00009
    00010     This library is free software; you can redistribute it and/or
    00011     modify it under the terms of the GNU Lesser General Public
    00012     License as published by the Free Software Foundation; either
    00013     version 2.1 of the License, or (at your option) any later version.
    00014
    00015     This library is distributed in the hope that it will be useful,
    00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018     Lesser General Public License for more details.
    00019
    00020     You should have received a copy of the GNU Lesser General Public
    00021     License along with this library; if not, write to the Free Software
    00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00023 *************************************************************************/
    00024 #ifndef _CEGUI_IrrlichtRenderer_h_
    00025 #define _CEGUI_IrrlichtRenderer_h_
    00026
    00027 #include "IrrlichtRendererDef.h"
    00028 #include "irrlichttexture.h"
    00029 #include "IrrlichtResourceProvider.h"
    00030
    00031 #include "CEGUIRenderer.h"
    00032 #include "CEGUIInputEvent.h"
    00033
    00034 #include <irrlicht.h>
    00035
    00036 #include <vector>
    00037 #include <algorithm>
    00038
    00039 #if defined(_MSC_VER)
    00040 #       pragma warning(push)
    00041 #       pragma warning(disable : 4251)
    00042 #endif
    00043
    00044 namespace CEGUI
    00045 {
    00046
    00047         class EventPusher;
    00048
    00054         class IRRLICHT_GUIRENDERER_API IrrlichtRenderer: public Renderer
    00055         {
    00056         public:
    00057
    00068                 IrrlichtRenderer(irr::IrrlichtDevice* dev,bool bWithIrrlichtResourceProvicer=false);
    00069
    00071                 virtual ~IrrlichtRenderer();
    00072
    00073
    00077                 virtual ResourceProvider* createResourceProvider(void);
    00078
    00080                 bool OnEvent(irr::SEvent& event);
    00081
    00082
    00083                 /*************************************************************************
    00084                 Abstract interface methods
    00085                 *************************************************************************/
    00111                 virtual void    addQuad(const Rect& dest_rect, float z, const Texture* tex,
    00112                         const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode);
    00113
    00114
    00124                 virtual void    doRender(void);
    00125
    00126
    00134                 virtual void    clearRenderList(void);
    00135
    00136
    00152                 virtual void    setQueueingEnabled(bool setting);
    00153
    00154
    00163                 virtual Texture*        createTexture(void);
    00164
    00165
    00185                 virtual Texture*        createTexture(const String& filename, const String& resourceGroup);
    00186
    00187
    00203                 virtual Texture*        createTexture(float size);
    00204
    00205
    00216                 virtual void            destroyTexture(Texture* texture);
    00217
    00218
    00226                 virtual void            destroyAllTextures(void);
    00227
    00228
    00236                 virtual bool    isQueueingEnabled(void) const;
    00237
    00238
    00246                 virtual float   getWidth(void) const;
    00247
    00248
    00256                 virtual float   getHeight(void) const;
    00257
    00258
    00266                 virtual Size    getSize(void) const;
    00267
    00268
    00277                 virtual Rect    getRect(void) const;
    00278
    00279
    00287                 virtual uint    getMaxTextureSize(void) const;
    00288
    00289
    00297                 virtual uint    getHorzScreenDPI(void) const;
    00298
    00299
    00307                 virtual uint    getVertScreenDPI(void) const;
    00308
    00309                 private:
    00310
    00311                         // the irrlicht device
    00312                         irr::IrrlichtDevice* device;
    00313                         // video driver
    00314                         irr::video::IVideoDriver* driver;
    00315                         // window width,height
    00316                         irr::core::dimension2d<irr::s32> resolution;
    00317                         // screen resolution
    00318                         irr::core::dimension2d<irr::s32> screensize;
    00319
    00320                         // is queueing enabled
    00321                         bool bQueuingEnabled;
    00322                         // is quad queue sorted
    00323                         bool bSorted;
    00324                         // enable irrlicht resource provider
    00325                         bool bWithIrrlichtResourceProvicer;
    00326
    00327                         // quad structure used for rendering the gui
    00328                         struct RenderQuad
    00329                         {
    00330                                 RenderQuad(){};
    00331
    00332                                 RenderQuad(float zVal,
    00333                                         const irr::core::rect<irr::s32>& target,
    00334                                         const irr::core::rect<irr::s32>& source,
    00335                                         ColourRect col,const Texture*t)
    00336                                         :z(zVal),dst(target),src(source),colours(col){
    00337                                                 tex=(IrrlichtTexture*)t;
    00338                                         };
    00339
    00340                                 float z;
    00341                                 irr::core::rect<irr::s32> dst;
    00342                                 irr::core::rect<irr::s32> src;
    00343                                 ColourRect colours;
    00344                                 IrrlichtTexture* tex;
    00345                         };
    00346
    00347                         RenderQuad dummyQuad;
    00348
    00349                         // std sorting RenderQuad class
    00350                         struct quadsorter
    00351                                 : public std::binary_function<RenderQuad*, RenderQuad*, bool>
    00352                         {
    00353                                 bool operator()(const RenderQuad& _Left, const RenderQuad& _Right) const
    00354                                 {return (_Left.z > _Right.z);}
    00355                         };
    00356
    00357                         // list ot quads we want to render
    00358                         std::vector<RenderQuad> renderlist;
    00359
    00360                         // list of textures used for rendering
    00361                         std::vector<IrrlichtTexture*> textures;
    00362
    00363                         // sort the quads in the renderlist
    00364                         void sortQuads();
    00365
    00366                         // render the quad
    00367                         void doRender(RenderQuad& quad);
    00368
    00369                         // print some debug output
    00370                         void print(RenderQuad& quad);
    00371
    00372                         // convert cegui colour to irrlicht scolor
    00373                         inline irr::video::SColor toIrrlichtColor(CEGUI::ulong cecolor);
    00374                         irr::video::SColor colors[4];
    00375
    00376
    00377
    00378                         EventPusher* eventpusher;
    00379
    00380         };
    00381
    00382 } // End of  CEGUI namespace section
    00383
    00384 #if defined(_MSC_VER)
    00385 #       pragma warning(pop)
    00386 #endif
    00387
    00388 #endif