00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _CEGUI_IrrlichtRenderer_h_
00029 #define _CEGUI_IrrlichtRenderer_h_
00030
00031 #include "IrrlichtRendererDef.h"
00032 #include "irrlichttexture.h"
00033 #include "IrrlichtResourceProvider.h"
00034
00035 #include "CEGUIRenderer.h"
00036 #include "CEGUIInputEvent.h"
00037
00038 #include <irrlicht.h>
00039
00040 #include <vector>
00041 #include <algorithm>
00042
00043 #if defined(_MSC_VER)
00044 # pragma warning(push)
00045 # pragma warning(disable : 4251)
00046 #endif
00047
00048 namespace CEGUI
00049 {
00050
00051 class EventPusher;
00052
00058 class IRRLICHT_GUIRENDERER_API IrrlichtRenderer: public Renderer
00059 {
00060 public:
00061
00072 IrrlichtRenderer(irr::IrrlichtDevice* dev,bool bWithIrrlichtResourceProvicer=false);
00073
00075 virtual ~IrrlichtRenderer();
00076
00077
00081 virtual ResourceProvider* createResourceProvider(void);
00082
00084 bool OnEvent(const irr::SEvent& event);
00085
00086
00087
00088
00089
00115 virtual void addQuad(const Rect& dest_rect, float z, const Texture* tex,
00116 const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode);
00117
00118
00128 virtual void doRender(void);
00129
00130
00138 virtual void clearRenderList(void);
00139
00140
00156 virtual void setQueueingEnabled(bool setting);
00157
00158
00167 virtual Texture* createTexture(void);
00168
00169
00189 virtual Texture* createTexture(const String& filename, const String& resourceGroup);
00190
00191
00207 virtual Texture* createTexture(float size);
00208
00209
00220 virtual void destroyTexture(Texture* texture);
00221
00222
00230 virtual void destroyAllTextures(void);
00231
00232
00240 virtual bool isQueueingEnabled(void) const;
00241
00242
00250 virtual float getWidth(void) const;
00251
00252
00260 virtual float getHeight(void) const;
00261
00262
00270 virtual Size getSize(void) const;
00271
00272
00281 virtual Rect getRect(void) const;
00282
00283
00291 virtual uint getMaxTextureSize(void) const;
00292
00293
00301 virtual uint getHorzScreenDPI(void) const;
00302
00303
00311 virtual uint getVertScreenDPI(void) const;
00312
00327 void setDisplaySize(const Size& sz);
00328
00329 private:
00330
00331
00332 irr::IrrlichtDevice* device;
00333
00334 irr::video::IVideoDriver* driver;
00335
00336 irr::core::dimension2d<irr::s32> resolution;
00337
00338 irr::core::dimension2d<irr::s32> screensize;
00339
00340
00341 bool bQueuingEnabled;
00342
00343 bool bSorted;
00344
00345 bool bWithIrrlichtResourceProvicer;
00346
00347
00348 struct RenderQuad
00349 {
00350 RenderQuad(){};
00351
00352 RenderQuad(float zVal,
00353 const irr::core::rect<irr::s32>& target,
00354 const irr::core::rect<irr::s32>& source,
00355 ColourRect col,const Texture*t)
00356 :z(zVal),dst(target),src(source),colours(col){
00357 tex=(IrrlichtTexture*)t;
00358 };
00359
00360 float z;
00361 irr::core::rect<irr::s32> dst;
00362 irr::core::rect<irr::s32> src;
00363 ColourRect colours;
00364 IrrlichtTexture* tex;
00365 };
00366
00367 RenderQuad dummyQuad;
00368
00369
00370 struct quadsorter
00371 : public std::binary_function<RenderQuad*, RenderQuad*, bool>
00372 {
00373 bool operator()(const RenderQuad& _Left, const RenderQuad& _Right) const
00374 {return (_Left.z > _Right.z);}
00375 };
00376
00377
00378 std::vector<RenderQuad> renderlist;
00379
00380
00381 std::vector<IrrlichtTexture*> textures;
00382
00383
00384 void sortQuads();
00385
00386
00387 void doRender(RenderQuad& quad);
00388
00389
00390 void print(RenderQuad& quad);
00391
00392
00393 inline irr::video::SColor toIrrlichtColor(CEGUI::ulong cecolor);
00394 irr::video::SColor colors[4];
00395
00396
00397
00398 EventPusher* eventpusher;
00399
00400 };
00401
00402 }
00403
00404 #if defined(_MSC_VER)
00405 # pragma warning(pop)
00406 #endif
00407
00408 #endif