00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_RENDERSYSTEM_OPENGL_H__
00009 #define __SP_RENDERSYSTEM_OPENGL_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #if defined(SP_COMPILE_WITH_OPENGL)
00015
00016
00017 #include "RenderSystem/OpenGL/spOpenGLPipelineFixed.hpp"
00018 #include "RenderSystem/OpenGL/spOpenGLPipelineProgrammable.hpp"
00019 #include "RenderSystem/OpenGL/spOpenGLTexture.hpp"
00020
00021
00022 namespace sp
00023 {
00024 namespace video
00025 {
00026
00027
00029 class SP_EXPORT OpenGLRenderSystem : public GLFixedFunctionPipeline, public GLProgrammableFunctionPipeline
00030 {
00031
00032 public:
00033
00034 OpenGLRenderSystem();
00035 ~OpenGLRenderSystem();
00036
00037
00038
00039 void setupConfiguration();
00040
00041
00042
00043 bool queryVideoSupport(const EVideoFeatureQueries Query) const;
00044
00045
00046
00047 void setAntiAlias(bool isAntiAlias);
00048
00049 void setDepthClip(bool Enable);
00050
00051
00052
00053 void setStencilMask(u32 BitMask);
00054 void setStencilMethod(const ESizeComparisionTypes Method, s32 Reference = 0, u32 BitMask = ~0);
00055 void setStencilOperation(const EStencilOperations FailOp, const EStencilOperations ZFailOp, const EStencilOperations ZPassOp);
00056 void setClearStencil(s32 Stencil);
00057
00058
00059
00060 bool setupMaterialStates(const MaterialStates* Material, bool Forced = false);
00061
00062 void endSceneRendering();
00063
00064
00065
00066 void drawMeshBuffer(const MeshBuffer* MeshBuffer);
00067 void drawMeshBufferPlain(const MeshBuffer* MeshBuffer, bool useFirstTextureLayer = false);
00068
00069
00070
00071 Shader* createCgShader(
00072 ShaderClass* ShaderClassObj, const EShaderTypes Type, const EShaderVersions Version,
00073 const std::list<io::stringc> &ShaderBuffer, const io::stringc &EntryPoint = "",
00074 const c8** CompilerOptions = 0
00075 );
00076
00077
00078
00079 void draw2DImage(
00080 const Texture* Tex, const dim::point2di &Position, const color &Color = color(255)
00081 );
00082
00083 void draw2DImage(
00084 const Texture* Tex, const dim::rect2di &Position,
00085 const dim::rect2df &Clipping = dim::rect2df(0.0f, 0.0f, 1.0f, 1.0f),
00086 const color &Color = color(255)
00087 );
00088
00089 void draw2DImage(
00090 const Texture* Tex, const dim::point2di &Position, f32 Rotation, f32 Radius, const color &Color = color(255)
00091 );
00092
00093 void draw2DImage(
00094 const Texture* Tex,
00095 const dim::point2di &lefttopPosition,
00096 const dim::point2di &righttopPosition,
00097 const dim::point2di &rightbottomPosition,
00098 const dim::point2di &leftbottomPosition,
00099 const dim::point2df &lefttopClipping = dim::point2df(0.0f, 0.0f),
00100 const dim::point2df &righttopClipping = dim::point2df(1.0f, 0.0f),
00101 const dim::point2df &rightbottomClipping = dim::point2df(1.0f, 1.0f),
00102 const dim::point2df &leftbottomClipping = dim::point2df(0.0f, 1.0f),
00103 const color &lefttopColor = color(255),
00104 const color &righttopColor = color(255),
00105 const color &rightbottomColor = color(255),
00106 const color &leftbottomColor = color(255)
00107 );
00108
00109
00110
00111 f32 getPixelDepth(const dim::point2di &Position) const;
00112
00113 void draw2DPoint(const dim::point2di &Position, const color &Color = 255);
00114
00115 void draw2DLine(
00116 const dim::point2di &PositionA, const dim::point2di &PositionB, const color &Color = 255
00117 );
00118 void draw2DLine(
00119 const dim::point2di &PositionA, const dim::point2di &PositionB, const color &ColorA, const color &ColorB
00120 );
00121
00122 void draw2DRectangle(
00123 const dim::rect2di &Rect, const color &Color = 255, bool isSolid = true
00124 );
00125 void draw2DRectangle(
00126 const dim::rect2di &Rect, const color &lefttopColor, const color &righttopColor,
00127 const color &rightbottomColor, const color &leftbottomColor, bool isSolid = true
00128 );
00129
00130
00131
00132 void draw2DPolygon(
00133 const ERenderPrimitives Type, const scene::SPrimitiveVertex2D* VerticesList, u32 Count
00134 );
00135
00136
00137
00138 void draw3DPoint(
00139 const dim::vector3df &Position, const color &Color = 255
00140 );
00141 void draw3DLine(
00142 const dim::vector3df &PositionA, const dim::vector3df &PositionB, const color &Color = 255
00143 );
00144 void draw3DLine(
00145 const dim::vector3df &PositionA, const dim::vector3df &PositionB, const color &ColorA, const color &ColorB
00146 );
00147 void draw3DEllipse(
00148 const dim::vector3df &Position, const dim::vector3df &Rotation = 0.0f,
00149 const dim::size2df &Radius = 0.5f, const color &Color = 255
00150 );
00151 void draw3DTriangle(
00152 Texture* hTexture, const dim::triangle3df &Triangle, const color &Color = 255
00153 );
00154
00155
00156
00157 Font* createBitmapFont(const io::stringc &FontName = "", s32 FontSize = 0, s32 Flags = 0);
00158
00159
00160 void draw3DText(
00161 Font* FontObj, const dim::matrix4f &Transformation, const io::stringc &Text, const color &Color = color(255)
00162 );
00163
00164
00165
00166 void setColorMatrix(const dim::matrix4f &Matrix);
00167
00168 private:
00169
00170 friend class OpenGLTexture;
00171
00172
00173
00174 #if defined(SP_PLATFORM_LINUX)
00175 struct SX11FontPackage
00176 {
00177 GLuint DisplayListsID;
00178 XID FontID;
00179 };
00180 #endif
00181
00182
00183
00184 void deleteFontObjects();
00185 void releaseFontObject(Font* FontObj);
00186
00187 void loadExtensions();
00188
00189 void defaultTextureGenMode();
00190
00191 void drawBitmapFont(const Font* FontObj, const dim::point2di &Position, const io::stringc &Text, const color &Color);
00192
00193 void bindMeshBuffer(const MeshBuffer* MeshBuffer);
00194 void unbindMeshBuffer(const MeshBuffer* MeshBuffer);
00195 void unbindPrevBoundMeshBuffer();
00196
00198 void drawPrimitiveList(
00199 const ERenderPrimitives Type,
00200 const scene::SMeshVertex3D* Vertices, u32 VertexCount, const void* Indices, u32 IndexCount,
00201 const TextureLayerListType* TextureLayers
00202 );
00203
00204
00205
00206 #if defined(SP_PLATFORM_WINDOWS)
00207 HGLRC hRC_;
00208 #endif
00209
00210 const MeshBuffer* PrevBoundMeshBuffer_;
00211
00212 };
00213
00214
00215 }
00216
00217 }
00218
00219
00220 #endif
00221
00222 #endif
00223
00224
00225
00226