00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022
00023 #ifndef H_SPK_RENDERER
00024 #define H_SPK_RENDERER
00025
00026 #include "Core/SPK_DEF.h"
00027 #include "Core/SPK_Registerable.h"
00028 #include "Core/SPK_BufferHandler.h"
00029
00030
00031 namespace SPK
00032 {
00033 class Group;
00034 class Particle;
00035
00041 enum BlendingMode
00042 {
00043 BLENDING_NONE,
00044 BLENDING_ADD,
00045 BLENDING_ALPHA,
00046 };
00047
00053 enum RenderingHint
00054 {
00055 ALPHA_TEST = 1 << 0,
00056 DEPTH_TEST = 1 << 1,
00057 DEPTH_WRITE = 1 << 2,
00058 };
00059
00076 class SPK_PREFIX Renderer : public Registerable,
00077 public BufferHandler
00078 {
00079 public :
00080
00082
00084
00086 Renderer();
00087
00089
00091
00093 virtual ~Renderer();
00094
00096
00098
00108 void setActive(bool active);
00109
00119 virtual void setBlending(BlendingMode blendMode) = 0;
00120
00130 virtual void enableRenderingHint(RenderingHint renderingHint,bool enable);
00131
00140 virtual void setAlphaTestThreshold(float alphaThreshold);
00141
00143
00145
00151 bool isActive() const;
00152
00158 virtual bool isRenderingHintEnabled(RenderingHint renderingHint) const;
00159
00165 float getAlphaTestThreshold() const;
00166
00168
00170
00175 virtual void render(const Group& group) = 0;
00176
00177 private :
00178
00179 bool active;
00180
00181 int renderingHintsMask;
00182 float alphaThreshold;
00183 };
00184
00185
00186 inline void Renderer::setActive(bool active)
00187 {
00188 this->active = active;
00189 }
00190
00191 inline void Renderer::enableRenderingHint(RenderingHint renderingHint,bool enable)
00192 {
00193 if (enable)
00194 renderingHintsMask |= renderingHint;
00195 else
00196 renderingHintsMask &= ~renderingHint;
00197 }
00198
00199 inline void Renderer::setAlphaTestThreshold(float alphaThreshold)
00200 {
00201 this->alphaThreshold = alphaThreshold;
00202 }
00203
00204 inline bool Renderer::isActive() const
00205 {
00206 return active;
00207 }
00208
00209 inline bool Renderer::isRenderingHintEnabled(RenderingHint renderingHint) const
00210 {
00211 return (renderingHintsMask & renderingHint) != 0;
00212 }
00213
00214 inline float Renderer::getAlphaTestThreshold() const
00215 {
00216 return alphaThreshold;
00217 }
00218 }
00219
00220 #endif