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_GLRENDERER
00024 #define H_SPK_GLRENDERER
00025
00026 #include "RenderingAPIs/OpenGL/SPK_GL_DEF.h"
00027 #include "Core/SPK_Renderer.h"
00028
00029 namespace SPK
00030 {
00031 namespace GL
00032 {
00037 class SPK_GL_PREFIX GLRenderer : public Renderer
00038 {
00039 public :
00040
00042
00044
00046 GLRenderer();
00047
00049
00051
00053 virtual ~GLRenderer();
00054
00056
00058
00063 virtual void enableBlending(bool blendingEnabled);
00064
00073 void setBlendingFunctions(GLuint src,GLuint dest);
00074 virtual void setBlending(BlendingMode blendMode);
00075
00083 void setTextureBlending(GLuint textureBlending);
00084
00086
00088
00093 bool isBlendingEnabled() const;
00094
00099 GLuint getSrcBlendingFunction() const;
00100
00105 GLuint getDestBlendingFunction() const;
00106
00111 GLuint getTextureBlending() const;
00112
00114
00116
00126 static void saveGLStates();
00127
00133 static void restoreGLStates();
00134
00135 protected :
00136
00138 void initBlending() const;
00139
00144 void initRenderingHints() const;
00145
00146 private :
00147
00148 bool blendingEnabled;
00149 GLuint srcBlending;
00150 GLuint destBlending;
00151
00152 GLuint textureBlending;
00153 };
00154
00155
00156 inline void GLRenderer::enableBlending(bool blendingEnabled)
00157 {
00158 this->blendingEnabled = blendingEnabled;
00159 }
00160
00161 inline void GLRenderer::setBlendingFunctions(GLuint src,GLuint dest)
00162 {
00163 srcBlending = src;
00164 destBlending = dest;
00165 }
00166
00167 inline void GLRenderer::setTextureBlending(GLuint textureBlending)
00168 {
00169 this->textureBlending = textureBlending;
00170 }
00171
00172 inline bool GLRenderer::isBlendingEnabled() const
00173 {
00174 return blendingEnabled;
00175 }
00176
00177 inline GLuint GLRenderer::getSrcBlendingFunction() const
00178 {
00179 return srcBlending;
00180 }
00181
00182 inline GLuint GLRenderer::getDestBlendingFunction() const
00183 {
00184 return destBlending;
00185 }
00186
00187 inline GLuint GLRenderer::getTextureBlending() const
00188 {
00189 return textureBlending;
00190 }
00191
00192 inline void GLRenderer::initBlending() const
00193 {
00194 if (blendingEnabled)
00195 {
00196 glBlendFunc(srcBlending,destBlending);
00197 glEnable(GL_BLEND);
00198 }
00199 else
00200 glDisable(GL_BLEND);
00201 }
00202
00203 inline void GLRenderer::initRenderingHints() const
00204 {
00205
00206 if (isRenderingHintEnabled(ALPHA_TEST))
00207 {
00208 glAlphaFunc(GL_GEQUAL,getAlphaTestThreshold());
00209 glEnable(GL_ALPHA_TEST);
00210 }
00211 else
00212 glDisable(GL_ALPHA_TEST);
00213
00214
00215 if (isRenderingHintEnabled(DEPTH_TEST))
00216 glEnable(GL_DEPTH_TEST);
00217 else
00218 glDisable(GL_DEPTH_TEST);
00219
00220
00221 glDepthMask(isRenderingHintEnabled(DEPTH_WRITE));
00222 }
00223 }}
00224
00225 #endif