00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_RENDERSYSTEM_H__
00009 #define __SP_RENDERSYSTEM_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spMaterialStates.hpp"
00014 #include "Base/spImageManagement.hpp"
00015 #include "Base/spTransformation2D.hpp"
00016 #include "Base/spMathSpline.hpp"
00017 #include "Base/spVertexFormatList.hpp"
00018 #include "Base/spIndexFormat.hpp"
00019 #include "Base/spInputOutput.hpp"
00020 #include "Base/spDimension.hpp"
00021 #include "Base/spGeometryStructures.hpp"
00022 #include "Base/spMaterialColor.hpp"
00023 #include "FileFormats/Image/spImageFileFormats.hpp"
00024 #include "RenderSystem/spShaderProgram.hpp"
00025 #include "RenderSystem/spTextureBase.hpp"
00026 #include "RenderSystem/spRenderSystemMovie.hpp"
00027 #include "RenderSystem/spRenderSystemFont.hpp"
00028
00029 #include <map>
00030 #include <boost/shared_ptr.hpp>
00031
00032
00033 namespace sp
00034 {
00035
00036 class SoftPixelDevice;
00037
00038 #if defined(SP_PLATFORM_WINDOWS)
00039 class SoftPixelDeviceWin32;
00040 #endif
00041
00042 #if defined(SP_PLATFORM_LINUX)
00043 class SoftPixelDeviceLinux;
00044 #endif
00045
00046 namespace scene
00047 {
00048
00049 class Camera;
00050 class Mesh;
00051 class MaterialNode;
00052 class SceneGraph;
00053
00054 }
00055
00056 namespace video
00057 {
00058
00059
00060 class TextureLayer;
00061 class RenderContext;
00062
00063
00069 class SP_EXPORT RenderSystem
00070 {
00071
00072 public:
00073
00074 virtual ~RenderSystem();
00075
00076
00077
00078 virtual void setupConfiguration() = 0;
00079
00080
00081
00082 static io::stringc getVendorNameByID(const u32 VendorID);
00083
00084 virtual io::stringc getRenderer() const = 0;
00085 virtual io::stringc getVersion() const = 0;
00086 virtual io::stringc getVendor() const = 0;
00087 virtual io::stringc getShaderVersion() const = 0;
00088
00089 virtual bool queryVideoSupport(const EVideoFeatureQueries Query) const = 0;
00090
00095 virtual bool queryExtensionSupport(const io::stringc &TargetExtension) const;
00096
00097 virtual s32 getMultitexCount() const = 0;
00098 virtual s32 getMaxAnisotropicFilter() const = 0;
00099 virtual s32 getMaxLightCount() const = 0;
00100
00101 virtual dim::EMatrixCoordinateSystmes getProjectionMatrixType() const;
00102
00103 virtual void printWarning();
00104
00105
00106
00116 virtual void clearBuffers(const s32 ClearFlags = BUFFER_COLOR | BUFFER_DEPTH) = 0;
00117
00118
00119
00121 virtual void setShadeMode(const EShadeModeTypes ShadeMode);
00122
00124 virtual void setFrontFace(bool isFrontFace);
00125
00131 virtual void setClearColor(const color &Color);
00132
00134 virtual void setColorMask(bool isRed, bool isGreen, bool isBlue, bool isAlpha = true);
00135
00137 virtual void setDepthMask(bool Enable);
00138
00140 virtual void setAntiAlias(bool isAntiAlias);
00141
00149 virtual void setDepthRange(f32 Near, f32 Far);
00154 virtual void getDepthRange(f32 &Near, f32 &Far) const;
00155
00157 virtual void setDepthClip(bool Enable);
00158
00159
00160
00162 virtual void setStencilMask(u32 BitMask);
00163
00171 virtual void setStencilMethod(const ESizeComparisionTypes Method, s32 Reference = 0, u32 BitMask = ~0);
00172
00180 virtual void setStencilOperation(const EStencilOperations FailOp, const EStencilOperations ZFailOp, const EStencilOperations ZPassOp);
00181
00183 virtual void setClearStencil(s32 Stencil);
00184
00185
00186
00196 virtual bool setupMaterialStates(const MaterialStates* Material, bool Forced = false) = 0;
00197
00199 virtual void setupTextureLayer(
00200 u8 LayerIndex, const dim::matrix4f &TexMatrix, const ETextureEnvTypes EnvType,
00201 const EMappingGenTypes GenType, s32 MappingCoordsFlags
00202 );
00203
00205 virtual void bindTextureLayers(const TextureLayerListType &TexLayers);
00207 virtual void unbindTextureLayers(const TextureLayerListType &TexLayers);
00208
00210 virtual void setupShaderClass(const scene::MaterialNode* Object, ShaderClass* ShaderObject);
00211
00213 virtual void updateMaterialStates(MaterialStates* Material, bool isClear = false);
00214
00219 virtual void updateLight(
00220 u32 LightID, const scene::ELightModels LightType, bool isVolumetric,
00221 const dim::vector3df &Direction, f32 SpotInnerConeAngle, f32 SpotOuterConeAngle,
00222 f32 AttenuationConstant, f32 AttenuationLinear, f32 AttenuationQuadratic
00223 );
00224
00225
00226
00228 virtual void createVertexBuffer(void* &BufferID) = 0;
00230 virtual void createIndexBuffer(void* &BufferID) = 0;
00231
00233 virtual void deleteVertexBuffer(void* &BufferID) = 0;
00235 virtual void deleteIndexBuffer(void* &BufferID) = 0;
00236
00238 virtual void updateVertexBuffer(
00239 void* BufferID, const dim::UniversalBuffer &BufferData, const VertexFormat* Format, const EHWBufferUsage Usage
00240 ) = 0;
00242 virtual void updateIndexBuffer(
00243 void* BufferID, const dim::UniversalBuffer &BufferData, const IndexFormat* Format, const EHWBufferUsage Usage
00244 ) = 0;
00245
00247 virtual void updateVertexBufferElement(void* BufferID, const dim::UniversalBuffer &BufferData, u32 Index) = 0;
00249 virtual void updateIndexBufferElement(void* BufferID, const dim::UniversalBuffer &BufferData, u32 Index) = 0;
00250
00252 virtual void drawMeshBuffer(const MeshBuffer* MeshBuffer) = 0;
00253
00262 virtual void drawMeshBufferPlain(const MeshBuffer* MeshBuffer, bool useFirstTextureLayer = false);
00263
00264
00265
00273 virtual void setRenderMode(const ERenderModes Mode);
00274
00302 virtual void setRenderState(const ERenderStates Type, s32 State) = 0;
00304 virtual s32 getRenderState(const ERenderStates Type) const = 0;
00305
00306
00307
00308 virtual void addDynamicLightSource(
00309 u32 LightID, scene::ELightModels Type,
00310 video::color &Diffuse, video::color &Ambient, video::color &Specular,
00311 f32 AttenuationConstant, f32 AttenuationLinear, f32 AttenuationQuadratic
00312 );
00313
00321 virtual void setLightStatus(u32 LightID, bool Enable, bool UseAllRCs = false);
00322
00332 virtual void setLightColor(
00333 u32 LightID,
00334 const video::color &Diffuse, const video::color &Ambient, const video::color &Specular,
00335 bool UseAllRCs = false
00336 );
00337
00338
00339
00344 virtual void setFog(const EFogTypes Type);
00345 virtual EFogTypes getFog() const;
00346
00348 virtual void setFogColor(const video::color &Color);
00349 virtual video::color getFogColor() const;
00350
00351 virtual void setFogRange(f32 Range, f32 NearPlane = 1.0f, f32 FarPlane = 1000.0f, const EFogModes Mode = FOG_PALE);
00352 virtual void getFogRange(f32 &Range, f32 &NearPlane, f32 &FarPlane, EFogModes &Mode);
00353
00354
00355
00363 virtual void setClipPlane(u32 Index, const dim::plane3df &Plane, bool Enable);
00364
00365
00366
00374 virtual ShaderClass* createShaderClass(VertexFormat* VertexInputLayout = 0);
00380 virtual void deleteShaderClass(ShaderClass* ShaderClassObj, bool DeleteAppendantShaders = false);
00381
00404 virtual Shader* loadShader(
00405 ShaderClass* ShaderClassObj, const EShaderTypes Type, const EShaderVersions Version,
00406 const io::stringc &Filename, const io::stringc &EntryPoint = "", s32 Flags = 0,
00407 const std::list<io::stringc> &PreShaderCode = std::list<io::stringc>()
00408 );
00409
00414 virtual Shader* createShader(
00415 ShaderClass* ShaderClassObj, const EShaderTypes Type, const EShaderVersions Version,
00416 const std::list<io::stringc> &ShaderBuffer, const io::stringc &EntryPoint = ""
00417 );
00418
00420 virtual ShaderClass* loadShaderClass(
00421 const io::stringc &FilenameVertex, const io::stringc &FilenamePixel,
00422 const EShaderVersions VersionVertex, const EShaderVersions VersionPixel,
00423 const io::stringc &EntryPointVertex = "", const io::stringc &EntryPointPixel = ""
00424 );
00425
00427 virtual ShaderClass* createCgShaderClass(VertexFormat* VertexInputLayout = 0);
00428
00436 virtual Shader* createCgShader(
00437 ShaderClass* ShaderClassObj, const EShaderTypes Type, const EShaderVersions Version,
00438 const std::list<io::stringc> &ShaderBuffer, const io::stringc &EntryPoint = "",
00439 const c8** CompilerOptions = 0
00440 );
00441
00443 virtual void deleteShader(Shader* ShaderObj);
00444
00446 virtual void unbindShaders();
00447
00457 virtual bool runComputeShader(
00458 Shader* ShaderObj, ComputeShaderIO* IOInterface, const dim::vector3di &GroupSize
00459 );
00460
00466 virtual ComputeShaderIO* createComputeShaderIO();
00467 virtual void deleteComputeShaderIO(ComputeShaderIO* &IOInterface);
00468
00469
00470
00472 virtual void beginSceneRendering();
00474 virtual void endSceneRendering();
00475
00482 virtual void beginDrawing2D();
00483 virtual void endDrawing2D();
00484
00489 virtual void beginDrawing3D();
00490 virtual void endDrawing3D();
00491
00499 virtual void setBlending(const EBlendingTypes SourceBlend, const EBlendingTypes DestBlend);
00500
00507 virtual void setClipping(bool Enable, const dim::point2di &Position, const dim::size2di &Size);
00508
00514 virtual void setViewport(const dim::point2di &Position, const dim::size2di &Size);
00515
00522 virtual bool setRenderTarget(Texture* Target);
00523 virtual Texture* getRenderTarget() const;
00524
00526 virtual void setLineSize(s32 Size = 1);
00527
00529 virtual void setPointSize(s32 Size = 1);
00530
00531
00532
00540 virtual void draw2DImage(
00541 const Texture* Tex, const dim::point2di &Position, const color &Color = color(255)
00542 );
00543
00550 virtual void draw2DImage(
00551 const Texture* Tex, const dim::rect2di &Position,
00552 const dim::rect2df &Clipping = dim::rect2df(0.0f, 0.0f, 1.0f, 1.0f),
00553 const color &Color = color(255)
00554 );
00555
00561 virtual void draw2DImage(
00562 const Texture* Tex, const dim::point2di &Position, f32 Rotation, f32 Radius, const color &Color = color(255)
00563 );
00564
00574 virtual void draw2DImage(
00575 const Texture* Tex,
00576 dim::rect2di Position,
00577 const dim::rect2df &Clipping,
00578 f32 Rotation,
00579 const dim::point2df &RotationPoint = dim::point2df(0.5f, 0.5f),
00580 const color &lefttopColor = color(255),
00581 const color &righttopColor = color(255),
00582 const color &rightbottomColor = color(255),
00583 const color &leftbottomColor = color(255)
00584 );
00585
00587 virtual void draw2DImage(
00588 const Texture* Tex,
00589 const dim::point2di &lefttopPosition,
00590 const dim::point2di &righttopPosition,
00591 const dim::point2di &rightbottomPosition,
00592 const dim::point2di &leftbottomPosition,
00593 const dim::point2df &lefttopClipping = dim::point2df(0.0f, 0.0f),
00594 const dim::point2df &righttopClipping = dim::point2df(1.0f, 0.0f),
00595 const dim::point2df &rightbottomClipping = dim::point2df(1.0f, 1.0f),
00596 const dim::point2df &leftbottomClipping = dim::point2df(0.0f, 1.0f),
00597 const color &lefttopColor = color(255),
00598 const color &righttopColor = color(255),
00599 const color &rightbottomColor = color(255),
00600 const color &leftbottomColor = color(255)
00601 );
00602
00603
00604
00606 virtual color getPixelColor(const dim::point2di &Position) const;
00607
00609 virtual f32 getPixelDepth(const dim::point2di &Position) const;
00610
00612 virtual void draw2DPoint(const dim::point2di &Position, const color &Color = color(255));
00613
00615 virtual void draw2DLine(
00616 const dim::point2di &PositionA, const dim::point2di &PositionB, const color &Color = color(255)
00617 );
00618
00620 virtual void draw2DLine(
00621 const dim::point2di &PositionA, const dim::point2di &PositionB, const color &ColorA, const color &ColorB
00622 );
00623
00631 virtual void draw2DRectangle(
00632 const dim::rect2di &Rect, const color &Color = 255, bool isSolid = true
00633 );
00634
00636 virtual void draw2DRectangle(
00637 const dim::rect2di &Rect, const color &lefttopColor, const color &righttopColor,
00638 const color &rightbottomColor, const color &leftbottomColor, bool isSolid = true
00639 );
00640
00646 virtual void draw2DBox(
00647 const dim::point2di &Position, const dim::size2di &Size, const color &Color = 255, bool isSolid = true
00648 );
00649
00655 virtual void draw2DCircle(const dim::point2di &Position, s32 Radius, const color &Color = 255);
00656
00658 virtual void draw2DEllipse(
00659 const dim::point2di &Position, const dim::size2di &Radius, const color &Color = 255
00660 );
00661
00662
00663
00664 virtual void draw2DPolygon(
00665 const ERenderPrimitives Type, const scene::SPrimitiveVertex2D* VerticesList, u32 Count
00666 );
00667 virtual void draw2DPolygonImage(
00668 const ERenderPrimitives Type, Texture* Tex, const scene::SPrimitiveVertex2D* VerticesList, u32 Count
00669 );
00670
00671
00672
00673 virtual void draw3DPoint(
00674 const dim::vector3df &Position, const color &Color = 255
00675 );
00676 virtual void draw3DLine(
00677 const dim::vector3df &PositionA, const dim::vector3df &PositionB, const color &Color = 255
00678 );
00679 virtual void draw3DLine(
00680 const dim::vector3df &PositionA, const dim::vector3df &PositionB, const color &ColorA, const color &ColorB
00681 );
00682 virtual void draw3DEllipse(
00683 const dim::vector3df &Position, const dim::vector3df &Rotation = 0.0f,
00684 const dim::size2df &Radius = 0.5f, const color &Color = 255
00685 );
00686 virtual void draw3DTriangle(
00687 Texture* Tex, const dim::triangle3df &Triangle, const color &Color = 255
00688 );
00689
00694 virtual void draw3DBox(
00695 const dim::aabbox3df &BoundBox, const dim::matrix4f &Transformation, const color &Color = color(255)
00696 );
00697
00699 virtual void draw3DBox(const dim::obbox3df &BoundBox, const color &Color = color(255));
00700
00701
00702
00708 void setTextureGenFlags(const ETextureGenFlags Flag, const s32 Value);
00709
00711 EImageFileFormats getImageFileFormat(io::File* TexFile) const;
00713 EImageFileFormats getImageFileFormat(const io::stringc &Filename) const;
00714
00723 virtual Texture* loadTexture(const io::stringc &Filename);
00724
00726 virtual Texture* loadTexture(ImageLoader* Loader);
00727
00733 virtual Texture* getTexture(const io::stringc &Filename);
00734
00740 virtual std::list<Texture*> loadTextureList(const io::stringc &Filename);
00741
00749 bool saveTexture(const Texture* Tex, io::stringc Filename, const EImageFileFormats FileFormat = IMAGEFORMAT_BMP);
00750
00752 void deleteTexture(Texture* &Tex);
00753
00755 virtual bool isTexture(const Texture* Tex) const;
00756
00758 virtual Texture* copyTexture(const Texture* Tex);
00759
00769 virtual Texture* createTexture(
00770 const dim::size2di &Size, const EPixelFormats Format = PIXELFORMAT_RGB, const u8* ImageBuffer = 0
00771 );
00772
00774 virtual Texture* createTexture(
00775 const dim::size2di &Size, const EPixelFormats Format, const f32* ImageBuffer
00776 );
00777
00779 virtual Texture* createTexture(const STextureCreationFlags &CreationFlags) = 0;
00780
00794 virtual Texture* createCubeMap(const dim::size2di &Size, bool isRenderTarget = true);
00795
00804 virtual Texture* createScreenShot(const dim::point2di &Position = 0, dim::size2di Size = 0);
00805
00807 virtual void createScreenShot(Texture* Tex, const dim::point2di &Position = 0);
00808
00810 virtual void setFillColor(const video::color &Color);
00811
00812 virtual void clearTextureList();
00813 virtual void reloadTextureList();
00814
00829 Texture* createTextureFromDeviceBitmap(void* BitmapDC, void* Bitmap);
00830
00832 void deleteVertexFormat(VertexFormat* Format);
00833
00834
00835
00842 Movie* loadMovie(const io::stringc &Filename, s32 Resolution = 256);
00843 void deleteMovie(Movie* &MovieObject);
00844
00845
00846
00855 virtual Font* createFont(const io::stringc &FontName = "", s32 FontSize = 0, s32 Flags = 0);
00856
00857 virtual Font* createTexturedFont(const io::stringc &FontName = "", s32 FontSize = 0, s32 Flags = 0);
00858 virtual Font* createBitmapFont(const io::stringc &FontName = "", s32 FontSize = 0, s32 Flags = 0);
00859
00861 virtual Font* createFont(video::Texture* FontTexture);
00863 virtual Font* createFont(video::Texture* FontTexture, const io::stringc &FontXMLFile);
00864 virtual Font* createFont(video::Texture* FontTexture, const std::vector<SFontGlyph> &GlyphList, s32 FontHeight);
00865
00875 virtual Texture* createFontTexture(
00876 std::vector<SFontGlyph> &GlyphList, const io::stringc &FontName = "", s32 FontSize = 0, s32 Flags = 0
00877 );
00878
00880 virtual void deleteFont(Font* FontObj);
00881
00891 virtual void draw2DText(
00892 const Font* FontObject, const dim::point2di &Position, const io::stringc &Text,
00893 const color &Color = color(255), s32 Flags = 0
00894 );
00895
00903 virtual void draw3DText(
00904 const Font* FontObject, const dim::matrix4f &Transformation, const io::stringc &Text, const color &Color = color(255)
00905 );
00906
00907
00908
00909
00910 virtual void updateModelviewMatrix() = 0;
00911
00912 virtual void matrixWorldViewReset();
00913
00914 virtual void setProjectionMatrix(const dim::matrix4f &Matrix);
00915 virtual void setViewMatrix (const dim::matrix4f &Matrix);
00916 virtual void setWorldMatrix (const dim::matrix4f &Matrix);
00917 virtual void setTextureMatrix (const dim::matrix4f &Matrix, u8 TextureLayer = 0);
00918 virtual void setColorMatrix (const dim::matrix4f &Matrix);
00919
00920 virtual dim::matrix4f getProjectionMatrix() const;
00921 virtual dim::matrix4f getViewMatrix () const;
00922 virtual dim::matrix4f getWorldMatrix () const;
00923 virtual dim::matrix4f getTextureMatrix (u8 TextureLayer = 0) const;
00924 virtual dim::matrix4f getColorMatrix () const;
00925
00926
00927
00933 static u32 queryDrawCalls();
00939 static u32 queryMeshBufferBindings();
00946 static u32 queryTextureLayerBindings();
00947
00948 static u32 queryMaterialUpdates();
00949
00950
00951
00956 inline ERenderSystems getRendererType() const
00957 {
00958 return RendererType_;
00959 }
00960
00961 #if defined(SP_PLATFORM_WINDOWS)
00962 inline HDC getDeviceContext() const
00963 {
00964 return DeviceContext_;
00965 }
00966 #endif
00967
00969 inline bool getDepthClip() const
00970 {
00971 return DepthRange_.Enabled;
00972 }
00973
00975 inline const std::list<Shader*>& getShaderList() const
00976 {
00977 return ShaderList_;
00978 }
00980 inline const std::list<ShaderClass*>& getShaderClassList() const
00981 {
00982 return ShaderClassList_;
00983 }
00985 inline const std::list<ComputeShaderIO*>& getComputeShaderIOList() const
00986 {
00987 return ComputeShaderIOList_;
00988 }
00989
00990 inline void setSurfaceCallback(const ShaderSurfaceCallback &CallbackProc)
00991 {
00992 ShaderSurfaceCallback_ = CallbackProc;
00993 }
00994
00996 inline void setGlobalShaderClass(ShaderClass* GlobalShaderClass)
00997 {
00998 GlobalShaderClass_ = GlobalShaderClass;
00999 }
01000 inline ShaderClass* getGlobalShaderClass() const
01001 {
01002 return GlobalShaderClass_;
01003 }
01004
01006 inline void setTextureGenFlags(const STextureCreationFlags &Flags)
01007 {
01008 TexGenFlags_ = Flags;
01009 }
01011 inline STextureCreationFlags getTextureGenFlags() const
01012 {
01013 return TexGenFlags_;
01014 }
01015
01017 inline std::list<Texture*> getTextureList() const
01018 {
01019 return TextureList_;
01020 }
01021
01026 inline void setFontTransformation(const dim::matrix4f &Transform)
01027 {
01028 FontTransform_ = Transform;
01029 }
01031 inline dim::matrix4f getFontTransformation() const
01032 {
01033 return FontTransform_;
01034 }
01035
01041 inline void setTexLayerVisibleMask(s32 VisibleMask)
01042 {
01043 TexLayerVisibleMask_ = VisibleMask;
01044 }
01046 inline s32 getTexLayerVisibleMask() const
01047 {
01048 return TexLayerVisibleMask_;
01049 }
01050
01058 inline void setClipping(bool Enable)
01059 {
01060 setClipping(Enable, 0, 0);
01061 }
01062
01067 inline void setupDefaultBlending()
01068 {
01069 setBlending(BLEND_SRCALPHA, BLEND_INVSRCALPHA);
01070 }
01071
01076 inline ERenderModes getRenderMode() const
01077 {
01078 return RenderMode_;
01079 }
01080
01086 template <class T> T* createVertexFormat()
01087 {
01088 T* NewFormat = new T();
01089 VertexFormatList_.push_back(NewFormat);
01090 return NewFormat;
01091 }
01092
01094 inline VertexFormatDefault* getVertexFormatDefault() const
01095 {
01096 return VertexFormatDefault_;
01097 }
01099 inline VertexFormatReduced* getVertexFormatReduced() const
01100 {
01101 return VertexFormatReduced_;
01102 }
01104 inline VertexFormatExtended* getVertexFormatExtended() const
01105 {
01106 return VertexFormatExtended_;
01107 }
01109 inline VertexFormatFull* getVertexFormatFull() const
01110 {
01111 return VertexFormatFull_;
01112 }
01113
01115 inline const MaterialStates* getMaterialDrawing2D() const
01116 {
01117 return Material2DDrawing_;
01118 }
01120 inline const MaterialStates* getMaterialDrawing3D() const
01121 {
01122 return Material3DDrawing_;
01123 }
01124
01126 inline const std::list<VertexFormat*>& getVertexFormatList() const
01127 {
01128 return VertexFormatList_;
01129 }
01130
01138 inline const video::Texture* getDefaultTexture(const EDefaultTextures Type)
01139 {
01140 return Type < DEFAULT_TEXTURE_COUNT ? DefaultTextures_[Type] : 0;
01141 }
01142
01143 protected:
01144
01145
01146
01147 friend class Font;
01148 friend class GLTextureBase;
01149 friend class OpenGLTexture;
01150 friend class OpenGLES1Texture;
01151 friend class GLFramebufferObject;
01152 friend class sp::SoftPixelDevice;
01153 friend class VertexFormat;
01154 friend class VertexFormatUniversal;
01155 friend class Texture;
01156 friend class TextureLayer;
01157 friend class MeshBuffer;
01158 friend class SoftPixelDevice;
01159
01160 #if defined(SP_PLATFORM_WINDOWS)
01161 friend class sp::SoftPixelDeviceWin32;
01162 #endif
01163
01164 #if defined(SP_PLATFORM_LINUX)
01165 friend class sp::SoftPixelDeviceLinux;
01166 #endif
01167
01168 #if defined(SP_PLATFORM_ANDROID)
01169 friend class sp::SoftPixelDeviceAndroid;
01170 #endif
01171
01172
01173
01174 enum ERenderQueries
01175 {
01176 RENDERQUERY_SHADER = 0,
01177 RENDERQUERY_GEOMETRY_SHADER,
01178 RENDERQUERY_TESSELLATION_SHADER,
01179 RENDERQUERY_CONSTANT_BUFFER,
01180
01181 RENDERQUERY_RENDERTARGET,
01182 RENDERQUERY_MULTISAMPLE_RENDERTARGET,
01183 RENDERQUERY_MULTI_TEXTURE,
01184 RENDERQUERY_CUBEMAP_ARRAY,
01185
01186 RENDERQUERY_HARDWARE_MESHBUFFER,
01187 RENDERQUERY_HARDWARE_INSTANCING,
01188
01189 RENDERQUERY_FOG_COORD,
01190
01191 RENDERQUERY_COUNT,
01192 };
01193
01194
01195
01196 struct SFogStates
01197 {
01198 SFogStates() :
01199 Type (FOG_NONE ),
01200 Mode (FOG_PALE ),
01201 Range (0.0f ),
01202 Near (0.0f ),
01203 Far (0.0f )
01204 {
01205 }
01206 ~SFogStates()
01207 {
01208 }
01209
01210
01211 EFogTypes Type;
01212 EFogModes Mode;
01213 f32 Range, Near, Far;
01214 video::color Color;
01215 };
01216
01217 struct SDepthRange
01218 {
01219 SDepthRange() :
01220 Enabled (true),
01221 Near (0.0f),
01222 Far (1.0f)
01223 {
01224 }
01225 ~SDepthRange()
01226 {
01227 }
01228
01229
01230 bool Enabled;
01231 f32 Near, Far;
01232 };
01233
01234
01235
01236 RenderSystem(const ERenderSystems Type);
01237
01238 virtual void setup2DDrawing();
01239 virtual void setup3DDrawing();
01240
01241 virtual Shader* createEmptyShaderWithError(
01242 const io::stringc &Message, ShaderClass* ShaderClassObj, const EShaderTypes Type, const EShaderVersions Version
01243 );
01244
01245 virtual void createDeviceFont(
01246 void* FontObject, const io::stringc &FontName, const dim::size2di &FontSize,
01247 s32 Flags = 0, s32 CharSet = 0
01248 ) const;
01249
01250 virtual std::vector<SFontGlyph> getCharWidths(void* FontObject) const;
01251
01252 virtual void updateVertexInputLayout(VertexFormat* Format, bool isCreate);
01253
01254 virtual void createDefaultResources();
01255 virtual void deleteDefaultResources();
01256
01257 virtual void releaseFontObject(Font* FontObj);
01258
01259 virtual void drawTexturedFont(const Font* FontObj, const dim::point2di &Position, const io::stringc &Text, const color &Color);
01260 virtual void drawBitmapFont(const Font* FontObj, const dim::point2di &Position, const io::stringc &Text, const color &Color);
01261
01262 void unbindPrevTextureLayers();
01263 void noticeTextureLayerChanged(const TextureLayer* TexLayer);
01264
01265
01266
01267 static void resetQueryCounters();
01268
01269
01270
01271
01272 ERenderSystems RendererType_;
01273
01274
01275 #if defined(SP_PLATFORM_WINDOWS)
01276 HDC DeviceContext_;
01277 UINT PixelFormat_;
01278 #elif defined(SP_PLATFORM_LINUX)
01279 Display* Display_;
01280 Window* Window_;
01281 #endif
01282
01283
01284 std::list<Texture*> TextureList_;
01285 std::list<Shader*> ShaderList_;
01286 std::list<ShaderClass*> ShaderClassList_;
01287 std::list<ComputeShaderIO*> ComputeShaderIOList_;
01288 std::list<Font*> FontList_;
01289 std::list<Movie*> MovieList_;
01290
01291 std::map<std::string, Texture*> TextureMap_;
01292
01293 std::vector<RenderContext*> ContextList_;
01294
01295
01296 CriticalSection TextureListSemaphore_;
01297
01298
01299 u8 StdFillColor_[4];
01300
01301 SFogStates Fog_;
01302 STextureCreationFlags TexGenFlags_;
01303 SDepthRange DepthRange_;
01304
01305
01306 ERenderModes RenderMode_;
01307
01308 dim::matrix4f Matrix2D_;
01309 dim::matrix4f FontTransform_;
01310 u32 MaxClippingPlanes_;
01311
01312 bool isFrontFace_;
01313
01314 s32 TexLayerVisibleMask_;
01315
01316
01317 Texture* RenderTarget_;
01318
01319
01320 ShaderClass* CurShaderClass_;
01321 ShaderClass* GlobalShaderClass_;
01322 ShaderSurfaceCallback ShaderSurfaceCallback_;
01323
01324 const MaterialStates* PrevMaterial_;
01325 const TextureLayerListType* PrevTextureLayers_;
01326
01327 MaterialStates* Material2DDrawing_;
01328 MaterialStates* Material3DDrawing_;
01329
01330
01331 std::list<VertexFormat*> VertexFormatList_;
01332
01333 VertexFormatDefault* VertexFormatDefault_;
01334 VertexFormatReduced* VertexFormatReduced_;
01335 VertexFormatExtended* VertexFormatExtended_;
01336 VertexFormatFull* VertexFormatFull_;
01337
01338
01339 bool RenderQuery_[RENDERQUERY_COUNT];
01340
01341 #ifdef SP_DEBUGMODE
01342
01343 static u32 NumDrawCalls_;
01344 static u32 NumMeshBufferBindings_;
01345 static u32 NumTexLayerBindings_;
01346 static u32 NumMaterialUpdates_;
01347
01348 #endif
01349
01350 private:
01351
01352
01353
01354 void createDefaultVertexFormats();
01355 void createDefaultTextures();
01356 void createDrawingMaterials();
01357
01358 bool loadShaderResourceFile(
01359 io::FileSystem &FileSys, const io::stringc &Filename, std::list<io::stringc> &ShaderBuffer
01360 );
01361
01362 static bool hasStringIncludeDirective(const io::stringc &Line, io::stringc &Filename);
01363
01364
01365
01366 video::Texture* DefaultTextures_[DEFAULT_TEXTURE_COUNT];
01367
01368 };
01369
01370
01371 }
01372
01373 }
01374
01375
01376 #endif
01377
01378
01379
01380