00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024 #ifndef SPK_IRRRENDERER
00025 #define SPK_IRRRENDERER
00026
00027 #include "RenderingAPIs/Irrlicht/SPK_IRR_DEF.h"
00028 #include "RenderingAPIs/Irrlicht/SPK_IRRBuffer.h"
00029 #include "Core/SPK_Renderer.h"
00030 #include "Core/SPK_Group.h"
00031
00032
00033 namespace SPK
00034 {
00035 namespace IRR
00036 {
00047 class SPK_IRR_PREFIX IRRRenderer : public Renderer
00048 {
00049 public :
00050
00052
00054
00059 IRRRenderer(irr::IrrlichtDevice* d);
00060
00062
00064
00066 virtual ~IRRRenderer(){};
00067
00069
00071
00083 void setBlending(irr::video::E_BLEND_FACTOR srcFunc,irr::video::E_BLEND_FACTOR destFunc,unsigned int alphaSrc);
00084 virtual void setBlending(BlendingMode blendMode);
00085
00086 virtual void enableRenderingHint(RenderingHint renderingHint,bool enable);
00087 virtual void setAlphaTestThreshold(float alphaThreshold);
00088
00090
00092
00097 irr::IrrlichtDevice* getDevice() const;
00098
00103 irr::video::E_BLEND_FACTOR getBlendSrcFunc() const;
00104
00109 irr::video::E_BLEND_FACTOR getBlendDestFunc() const;
00110
00115 unsigned int getAlphaSource() const;
00116
00124 const irr::video::SMaterial& getMaterial() const;
00125
00126 virtual bool isRenderingHintEnabled(RenderingHint renderingHint) const;
00127
00129
00131
00132 virtual void destroyBuffers(const Group& group);
00133
00134 protected :
00135
00136 irr::IrrlichtDevice* device;
00137 irr::video::SMaterial material;
00138
00139 mutable IRRBuffer* currentBuffer;
00140
00141 virtual bool checkBuffers(const Group& group);
00142 static unsigned int getVBOFlag();
00143
00144 private :
00145
00146 irr::video::E_BLEND_FACTOR blendSrcFunc;
00147 irr::video::E_BLEND_FACTOR blendDestFunc;
00148 unsigned int alphaSource;
00149
00157 virtual const std::string& getBufferName() const = 0;
00158
00159 void updateMaterialBlendingMode();
00160 };
00161
00162
00163 inline void IRRRenderer::setAlphaTestThreshold(float alphaThreshold)
00164 {
00165 Renderer::setAlphaTestThreshold(0.0f);
00166 }
00167
00168 inline irr::IrrlichtDevice* IRRRenderer::getDevice() const
00169 {
00170 return device;
00171 }
00172
00173 inline irr::video::E_BLEND_FACTOR IRRRenderer::getBlendSrcFunc() const
00174 {
00175 return blendSrcFunc;
00176 }
00177
00178 inline irr::video::E_BLEND_FACTOR IRRRenderer::getBlendDestFunc() const
00179 {
00180 return blendDestFunc;
00181 }
00182
00183 inline unsigned int IRRRenderer::getAlphaSource() const
00184 {
00185 return alphaSource;
00186 }
00187
00188 inline const irr::video::SMaterial& IRRRenderer::getMaterial() const
00189 {
00190 return material;
00191 }
00192
00193 inline void IRRRenderer::destroyBuffers(const Group& group)
00194 {
00195 group.destroyBuffer(getBufferName());
00196 }
00197
00198 inline bool IRRRenderer::checkBuffers(const Group& group)
00199 {
00200 currentBuffer = dynamic_cast<IRRBuffer*>(group.getBuffer(getBufferName(),getVBOFlag()));
00201 return currentBuffer != NULL;
00202 }
00203
00204 inline unsigned int IRRRenderer::getVBOFlag()
00205 {
00206 return IRRBuffer::isVBOHintActivated() ? 1 : 0;
00207 }
00208
00209 inline void IRRRenderer::updateMaterialBlendingMode()
00210 {
00211 material.MaterialTypeParam = irr::video::pack_texureBlendFunc(
00212 blendSrcFunc,
00213 blendDestFunc,
00214 irr::video::EMFN_MODULATE_1X,
00215 alphaSource);
00216 }
00217 }}
00218
00219 #endif