Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
E:/Programming/MyProject/K_Game_hg/GameEngine/include/render/RenderDriver.h
Go to the documentation of this file.
00001 // Copyright 2006-2011 by Kat'Oun
00002 
00003 #ifndef _RENDER_DRIVER_H_
00004 #define _RENDER_DRIVER_H_
00005 
00006 #include <EngineConfig.h>
00007 #include <core/Types.h>
00008 #include <core/Matrix4.h>
00009 #include <render/Material.h>
00010 #include <render/BlendMode.h>
00011 #include <render/Color.h>
00012 #include <render/RenderOperation.h>
00013 
00014 #include <vector>
00015 
00016 namespace core
00017 {
00018 class sphere3d;
00019 }
00020 
00021 namespace resource
00022 {
00023 enum BufferUsage;
00024 enum PixelFormat;
00025 }
00026 
00027 namespace render
00028 {
00029 
00030 class Frustum;
00031 class Light;
00032 class Camera;
00033 class MeshData;
00034 class Overlay;
00035 class PanelOverlay;
00036 class TextOverlay;
00037 class Font;
00038 class MeshData;
00039 class Viewport;
00040 class RenderWindow;
00041 class RenderDriver;
00042 class FrameEventReceiver;
00043 struct FrameEvent;
00044 class Shader;
00045 class VertexBuffer;
00046 class IndexBuffer;
00047 class PixelBuffer;
00048 class Texture;
00049 class ShaderParamData;
00050 enum IndexType;
00051 enum ShaderType;
00052 
00054 #define GAME_MAX_TEXTURE_LAYERS 16
00055 
00057 #define GAME_MAX_SIMULTANEOUS_LIGHTS 8
00058 
00067 class ENGINE_PUBLIC_EXPORT RenderDriver
00068 {
00069 public:
00070 
00071         // Default Constructor
00072         RenderDriver();
00073 
00074         // Destructor
00075         virtual ~RenderDriver();
00076 
00077         virtual void initialize();
00078 
00079         virtual void start();
00080 
00081         virtual void stop();
00082         
00084         virtual RenderWindow* createRenderWindow(s32 width, s32 height, s32 colorDepth,
00085                 bool fullScreen, s32 left = 0, s32 top = 0, bool depthBuffer = true, void* windowId = NULL) = 0;
00086 
00088         virtual VertexBuffer* createVertexBuffer(u32 vertexSize, u32 numVertices, resource::BufferUsage usage, bool useShadowBuffer = false) = 0;
00090         virtual void removeVertexBuffer(VertexBuffer* buf) = 0;
00091 
00093         virtual IndexBuffer* createIndexBuffer(IndexType idxType, u32 numIndexes, resource::BufferUsage usage, bool useShadowBuffer = false) = 0;
00095         virtual void removeIndexBuffer(IndexBuffer* buf) = 0;
00096 
00098         virtual PixelBuffer* createPixelBuffer(u32 width, u32 height, u32 depth, resource::PixelFormat format, resource::BufferUsage usage, bool useShadowBuffer = false) = 0;
00100         virtual void removePixelBuffer(PixelBuffer* buf) = 0;
00101 
00104         virtual void beginFrame(Viewport *vp) = 0;
00105 
00115         virtual void render(RenderOperation& op);
00116 
00117         virtual void renderGrid(u32 lineSpacing, u32 lineNumber) = 0;
00118 
00119         virtual void renderTestPlane(u32 lineSpacing, u32 lineNumber) = 0;//just for testing
00120 
00121         virtual void renderWorldAxes() = 0;
00122 
00123         virtual void renderAxes(const core::vector3d& position, const core::vector3d& right, const core::vector3d& target, const core::vector3d& up) = 0;//for debugging
00124 
00125         virtual void renderBoundingSphere(const core::sphere3d& sphere) = 0;//for debugging
00126 
00127         virtual void renderBoundingBox(const core::aabox3d& box) = 0;//for debugging
00128 
00129         virtual void renderFrustumVolume(const core::vector3d* corners) = 0;//for debugging
00130 
00132         virtual void endFrame() = 0;
00133 
00134         virtual void beginGeometryCount();
00135 
00136         virtual u32 getVertexCount();
00137 
00138         virtual u32 getFaceCount();
00139 
00140         virtual void endGeometryCount();
00141 
00142         virtual void setViewport(Viewport *vp) = 0;
00143 
00144         virtual void setWorldMatrix(const core::matrix4& m) = 0;
00145 
00146         virtual void setViewMatrix(const core::matrix4& m) = 0;
00147 
00148         virtual void setProjectionMatrix(const core::matrix4& m) = 0;
00149 
00150         core::matrix4& getWorldMatrix();
00151 
00152         core::matrix4& getViewMatrix();
00153 
00154         core::matrix4& getProjectionMatrix();
00155 
00157         virtual void convertProjectionMatrix(const core::matrix4& matrix, core::matrix4& dest);
00158 
00159         virtual void setShadingType(ShadeOptions so) = 0;
00160 
00177         virtual void setSurfaceParams(const Color& ambient, const Color& diffuse,
00178                         const Color& specular, const Color& emissive, f32 shininess) = 0;
00179 
00181         virtual void setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0;
00182         
00184         virtual void setTextureUnitSettings(u32 texUnit, TextureUnit* tu);
00185 
00187         virtual void disableTextureUnit(u32 texUnit);
00188 
00190         virtual void disableTextureUnitsFrom(u32 texUnit);
00191         
00197         virtual void setTexture(bool enabled, u32 unit, Texture* tex) = 0;
00198 
00200         virtual void setTextureCoordSet(u32 unit, u32 index);
00201 
00205         virtual void setTextureBlendMode(u32 unit, const LayerBlendMode& bm) = 0;
00206 
00207         virtual void setLightingEnabled(bool enabled) = 0;
00208 
00209         virtual void setAmbientLight(f32 red, f32 green, f32 blue, f32 alpha) = 0;
00210 
00212         virtual void setLights(const std::vector<Light*>& lights) = 0;
00213 
00215         virtual void setDepthBufferCheckEnabled(bool enabled = true) = 0;
00216 
00218         virtual void setDepthBufferWriteEnabled(bool enabled = true) = 0;
00219 
00221         virtual void setFog(FogMode mode = FM_NONE, const Color& color = Color::White, f32 expDensity = 1.0f, f32 linearStart = 0.0f, f32 linearEnd = 1.0f) = 0;
00222 
00224         virtual u32 getNumTextureUnits() = 0;
00225 
00227         virtual void bindShader(Shader* shader);
00228 
00230         virtual void unbindShader(ShaderType type);
00231 
00233         virtual bool isShaderBound(ShaderType type);
00234 
00236         virtual void updateShaderAutoParameters(Shader* shader, ShaderParamData& data);
00237 
00239         virtual f32 getMinimumDepthInputValue() = 0;
00241         virtual f32 getMaximumDepthInputValue() = 0;
00242 
00244         virtual f32 getHorizontalTexelOffset() = 0;
00246         virtual f32 getVerticalTexelOffset() = 0;
00247 
00248 protected:
00249 
00250         u32 mFaceCount;
00251         u32 mVertexCount;
00252         
00253         core::matrix4 mWorldMatrix;
00254         core::matrix4 mViewMatrix;
00255         core::matrix4 mProjMatrix;
00256 
00257         u32 mTextureCoordIndex[GAME_MAX_TEXTURE_COORD_SETS];
00258 
00259         // Array of up to 8 lights, indexed as per API
00260         // Note that a null value indicates a free slot
00261         Light* mLights[GAME_MAX_SIMULTANEOUS_LIGHTS];
00262 
00263         // Saved manual color blends
00264         Color mManualBlendColors[GAME_MAX_TEXTURE_LAYERS][2];
00265 
00266         // Texture units from this upwards are disabled
00267         u32 mDisabledTexUnitsFrom;
00268 
00269         Shader* mCurrentVertexShader;
00270         Shader* mCurrentFragmentShader;
00271         Shader* mCurrentGeometryShader;
00272 };
00273 
00274 } // end namespace render
00275 
00276 #endif

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:04 by Doxygen (1.7.4)