00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
00312 irr::IrrlichtDevice* device;
00313
00314 irr::video::IVideoDriver* driver;
00315
00316 irr::core::dimension2d<irr::s32> resolution;
00317
00318 irr::core::dimension2d<irr::s32> screensize;
00319
00320
00321 bool bQueuingEnabled;
00322
00323 bool bSorted;
00324
00325 bool bWithIrrlichtResourceProvicer;
00326
00327
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
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
00358 std::vector<RenderQuad> renderlist;
00359
00360
00361 std::vector<IrrlichtTexture*> textures;
00362
00363
00364 void sortQuads();
00365
00366
00367 void doRender(RenderQuad& quad);
00368
00369
00370 void print(RenderQuad& quad);
00371
00372
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 }
00383
00384 #if defined(_MSC_VER)
00385 # pragma warning(pop)
00386 #endif
00387
00388 #endif