00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_OPENGL_FIXEDFUNCTIONPIPELINE_H__
00009 #define __SP_OPENGL_FIXEDFUNCTIONPIPELINE_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #if defined(SP_COMPILE_WITH_OPENGL) || defined(SP_COMPILE_WITH_OPENGLES1)
00015
00016 #include "RenderSystem/OpenGL/spOpenGLPipelineBase.hpp"
00017
00018
00019 namespace sp
00020 {
00021 namespace video
00022 {
00023
00024
00025 #if defined(SP_COMPILE_WITH_OPENGLES1)
00026 # define __DRAW2DARRAYS__
00027 #endif
00028
00029
00031 class SP_EXPORT GLFixedFunctionPipeline : virtual public GLBasePipeline
00032 {
00033
00034 public:
00035
00036 virtual ~GLFixedFunctionPipeline();
00037
00038
00039
00040 virtual s32 getMultitexCount() const;
00041 virtual s32 getMaxLightCount() const;
00042
00043
00044
00045 virtual void setShadeMode(const EShadeModeTypes ShadeMode);
00046
00047
00048
00049 virtual void updateLight(
00050 u32 LightID, const scene::ELightModels LightType, bool isVolumetric,
00051 const dim::vector3df &Direction, f32 SpotInnerConeAngle, f32 SpotOuterConeAngle,
00052 f32 AttenuationConstant, f32 AttenuationLinear, f32 AttenuationQuadratic
00053 );
00054
00055
00056
00057 virtual void setupTextureLayer(
00058 u8 LayerIndex, const dim::matrix4f &TexMatrix, const ETextureEnvTypes EnvType,
00059 const EMappingGenTypes GenType, s32 MappingCoordsFlags
00060 );
00061
00062 virtual void setRenderState(const video::ERenderStates Type, s32 State);
00063 virtual s32 getRenderState(const video::ERenderStates Type) const;
00064
00065
00066
00067 virtual void addDynamicLightSource(
00068 u32 LightID, scene::ELightModels Type,
00069 video::color &Diffuse, video::color &Ambient, video::color &Specular,
00070 f32 AttenuationConstant, f32 AttenuationLinear, f32 AttenuationQuadratic
00071 );
00072
00073 virtual void setLightStatus(u32 LightID, bool Enable, bool UseAllRCs = false);
00074
00075 virtual void setLightColor(
00076 u32 LightID,
00077 const video::color &Diffuse, const video::color &Ambient, const video::color &Specular,
00078 bool UseAllRCs = false
00079 );
00080
00081
00082
00083 virtual void setFog(const EFogTypes Type);
00084 virtual void setFogColor(const video::color &Color);
00085 virtual void setFogRange(f32 Range, f32 NearPlane = 1.0f, f32 FarPlane = 1000.0f, const EFogModes Mode = FOG_PALE);
00086
00087
00088
00089 virtual void setClipPlane(u32 Index, const dim::plane3df &Plane, bool Enable);
00090
00091
00092
00093 virtual void beginDrawing2D();
00094 virtual void endDrawing2D();
00095
00096 virtual void beginDrawing3D();
00097
00098 virtual void setPointSize(s32 Size = 1);
00099
00100
00101
00102 virtual color getPixelColor(const dim::point2di &Position) const;
00103
00104
00105
00106 virtual void draw2DPolygonImage(
00107 const ERenderPrimitives Type, Texture* Tex, const scene::SPrimitiveVertex2D* VerticesList, u32 Count
00108 );
00109
00110
00111
00112 virtual Texture* createScreenShot(const dim::point2di &Position = 0, dim::size2di Size = 0);
00113 virtual void createScreenShot(Texture* Tex, const dim::point2di &Position = 0);
00114
00115
00116
00117 virtual void updateModelviewMatrix();
00118
00119 virtual void setProjectionMatrix(const dim::matrix4f &Matrix);
00120 virtual void setViewMatrix (const dim::matrix4f &Matrix);
00121 virtual void setTextureMatrix (const dim::matrix4f &Matrix, u8 TextureLayer = 0);
00122
00123 protected:
00124
00125 friend class OpenGLTexture;
00126 friend class OpenGLES1Texture;
00127 friend class OpenGLES2Texture;
00128
00129
00130
00131 #define VBO_OFFSET_PTR(i) ((char*)0 + (i))
00132
00133 #define VBO_OFFSET_VERTEX (0)
00134 #define VBO_OFFSET_NORMAL (12)
00135 #define VBO_OFFSET_TEXCOORD(i) (28 + 12*i)
00136 #define VBO_OFFSET_COLOR (28 + 12*MAX_COUNT_OF_TEXTURES)
00137 #define VBO_OFFSET_FOG (32 + 12*MAX_COUNT_OF_TEXTURES)
00138
00139 #define ARY_OFFSET_VERTEX (28)
00140 #define ARY_OFFSET_TEXCOORD (20)
00141 #define ARY_OFFSET_COLOR (44)
00142
00143
00144
00145 struct SClipPlane
00146 {
00147 SClipPlane()
00148 : Index(0), Enable(false)
00149 {
00150 }
00151 SClipPlane(u32 PlaneIndex, const dim::plane3df ClipPlane, bool PlaneEnable)
00152 : Index(PlaneIndex), Enable(PlaneEnable)
00153 {
00154 PlaneEquation[0] = ClipPlane.Normal.X;
00155 PlaneEquation[1] = ClipPlane.Normal.Y;
00156 PlaneEquation[2] = ClipPlane.Normal.Z;
00157 PlaneEquation[3] = ClipPlane.Distance;
00158 }
00159 ~SClipPlane()
00160 {
00161 }
00162
00163
00164 u32 Index;
00165 bool Enable;
00166
00167 #if defined(SP_COMPILE_WITH_OPENGL)
00168 f64 PlaneEquation[4];
00169 #else
00170 f32 PlaneEquation[4];
00171 #endif
00172 };
00173
00174
00175
00176 GLFixedFunctionPipeline();
00177
00178 void drawTexturedFont(
00179 const Font* FontObj, const dim::point2di &Position, const io::stringc &Text, const color &Color
00180 );
00181
00182
00183
00184 #if defined(SP_COMPILE_WITH_OPENGL)
00185 inline void setupTextureLayerCoordinate(GLenum RenderState, GLenum Coordinate, bool Enable, s32 GenType)
00186 {
00187 if (Enable)
00188 {
00189 glEnable(RenderState);
00190 glTexGeni(Coordinate, GL_TEXTURE_GEN_MODE, GenType);
00191 }
00192 else
00193 glDisable(RenderState);
00194 }
00195 #endif
00196
00197
00198
00199 std::vector<SClipPlane> ClippingPlanes_;
00200 scene::SPrimitiveVertex2D Vertices2D_[4];
00201
00202 GLboolean isCullFace_;
00203 f32 TempColor_[4];
00204
00205 static dim::matrix4f ExtTmpMat_;
00206
00207 };
00208
00209
00210 }
00211
00212 }
00213
00214
00215 #endif
00216
00217 #endif
00218
00219
00220
00221