00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 00006 00007 Copyright (c) 2000-2005 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #ifndef __RenderSystem_H_ 00026 #define __RenderSystem_H_ 00027 00028 // Precompiler options 00029 #include "OgrePrerequisites.h" 00030 00031 #include "OgreString.h" 00032 00033 #include "OgreTextureUnitState.h" 00034 #include "OgreCommon.h" 00035 00036 #include "OgreRenderOperation.h" 00037 #include "OgreRenderSystemCapabilities.h" 00038 #include "OgreRenderTarget.h" 00039 #include "OgreRenderTexture.h" 00040 #include "OgreFrameListener.h" 00041 #include "OgreConfigOptionMap.h" 00042 #include "OgreGpuProgram.h" 00043 #include "OgrePlane.h" 00044 00045 namespace Ogre 00046 { 00047 typedef std::map< String, RenderTarget * > RenderTargetMap; 00048 typedef std::multimap<uchar, RenderTarget * > RenderTargetPriorityMap; 00049 00050 class TextureManager; 00052 enum TexCoordCalcMethod 00053 { 00055 TEXCALC_NONE, 00057 TEXCALC_ENVIRONMENT_MAP, 00059 TEXCALC_ENVIRONMENT_MAP_PLANAR, 00060 TEXCALC_ENVIRONMENT_MAP_REFLECTION, 00061 TEXCALC_ENVIRONMENT_MAP_NORMAL, 00063 TEXCALC_PROJECTIVE_TEXTURE 00064 }; 00066 enum StencilOperation 00067 { 00069 SOP_KEEP, 00071 SOP_ZERO, 00073 SOP_REPLACE, 00075 SOP_INCREMENT, 00077 SOP_DECREMENT, 00079 SOP_INCREMENT_WRAP, 00081 SOP_DECREMENT_WRAP, 00083 SOP_INVERT 00084 }; 00085 00087 enum FrameBufferType { 00088 FBT_COLOUR = 0x1, 00089 FBT_DEPTH = 0x2, 00090 FBT_STENCIL = 0x4 00091 }; 00092 00116 class _OgreExport RenderSystem 00117 { 00118 public: 00121 RenderSystem(); 00122 00125 virtual ~RenderSystem(); 00126 00129 virtual const String& getName(void) const = 0; 00130 00152 virtual ConfigOptionMap& getConfigOptions(void) = 0; 00153 00173 virtual void setConfigOption(const String &name, const String &value) = 0; 00174 00179 virtual String validateConfigOptions(void) = 0; 00180 00197 virtual RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window"); 00198 00201 virtual void reinitialise(void) = 0; 00202 00205 virtual void shutdown(void); 00206 00207 00210 virtual void setAmbientLight(float r, float g, float b) = 0; 00211 00214 virtual void setShadingType(ShadeOptions so) = 0; 00215 00221 virtual void setLightingEnabled(bool enabled) = 0; 00222 00229 void setWBufferEnabled(bool enabled); 00230 00233 bool getWBufferEnabled(void) const; 00234 00319 virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, 00320 bool fullScreen, const NameValuePairList *miscParams = 0) = 0; 00321 00356 virtual RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height, 00357 TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8, 00358 const NameValuePairList *miscParams = 0 ) = 0; 00359 00361 virtual void destroyRenderWindow(const String& name); 00363 virtual void destroyRenderTexture(const String& name); 00365 virtual void destroyRenderTarget(const String& name); 00366 00369 virtual void attachRenderTarget( RenderTarget &target ); 00373 virtual RenderTarget * getRenderTarget( const String &name ); 00379 virtual RenderTarget * detachRenderTarget( const String &name ); 00380 00383 virtual String getErrorDescription(long errorNumber) const = 0; 00384 00398 void setWaitForVerticalBlank(bool enabled); 00399 00402 bool getWaitForVerticalBlank(void) const; 00403 00404 // ------------------------------------------------------------------------ 00405 // Internal Rendering Access 00406 // All methods below here are normally only called by other OGRE classes 00407 // They can be called by library user if required 00408 // ------------------------------------------------------------------------ 00409 00410 00414 virtual void _useLights(const LightList& lights, unsigned short limit) = 0; 00416 virtual void _setWorldMatrix(const Matrix4 &m) = 0; 00418 virtual void _setWorldMatrices(const Matrix4* m, unsigned short count); 00420 virtual void _setViewMatrix(const Matrix4 &m) = 0; 00422 virtual void _setProjectionMatrix(const Matrix4 &m) = 0; 00428 virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl); 00430 virtual void _disableTextureUnit(size_t texUnit); 00432 virtual void _disableTextureUnitsFrom(size_t texUnit); 00466 virtual void _setSurfaceParams(const ColourValue &ambient, 00467 const ColourValue &diffuse, const ColourValue &specular, 00468 const ColourValue &emissive, Real shininess, 00469 TrackVertexColourType tracking = TVC_NONE) = 0; 00486 virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0; 00487 00497 virtual void _setTextureCoordSet(size_t unit, size_t index) = 0; 00498 00506 virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 00507 const Frustum* frustum = 0) = 0; 00508 00515 virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0; 00516 00523 virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter, 00524 FilterOptions magFilter, FilterOptions mipFilter); 00525 00531 virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0; 00532 00534 virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0; 00535 00537 virtual void _setTextureAddressingMode(size_t unit, TextureUnitState::TextureAddressingMode tam) = 0; 00538 00543 virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0; 00544 00553 virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0; 00554 00560 virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0; 00565 virtual void _beginFrame(void) = 0; 00566 00567 00571 virtual void _endFrame(void) = 0; 00579 virtual void _setViewport(Viewport *vp) = 0; 00581 virtual Viewport* _getViewport(void); 00582 00594 virtual void _setCullingMode(CullingMode mode) = 0; 00595 00596 virtual CullingMode _getCullingMode(void) const; 00597 00611 virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0; 00612 00617 virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0; 00622 virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0; 00630 virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0; 00638 virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0; 00651 virtual void _setDepthBias(ushort bias) = 0; 00663 virtual void _setFog(FogMode mode = FOG_NONE, const ColourValue& colour = ColourValue::White, Real expDensity = 1.0, Real linearStart = 0.0, Real linearEnd = 1.0) = 0; 00664 00665 00667 virtual void _beginGeometryCount(void); 00669 virtual unsigned int _getFaceCount(void) const; 00671 virtual unsigned int _getVertexCount(void) const; 00672 00681 virtual void convertColourValue(const ColourValue& colour, uint32* pDest) = 0; 00682 00689 virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 00690 Matrix4& dest, bool forGpuProgram = false) = 0; 00691 00698 virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, 00699 Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0; 00706 virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 00707 Matrix4& dest, bool forGpuProgram = false) = 0; 00708 00725 virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 00726 bool forGpuProgram) = 0; 00727 00729 virtual void _setRasterisationMode(SceneDetailLevel level) = 0; 00730 00737 virtual void setStencilCheckEnabled(bool enabled) = 0; 00753 /*virtual bool hasHardwareStencil(void) = 0;*/ 00754 00790 virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 00791 uint32 refValue = 0, uint32 mask = 0xFFFFFFFF, 00792 StencilOperation stencilFailOp = SOP_KEEP, 00793 StencilOperation depthFailOp = SOP_KEEP, 00794 StencilOperation passOp = SOP_KEEP, 00795 bool twoSidedOperation = false) = 0; 00796 00797 00798 00800 virtual void setVertexDeclaration(VertexDeclaration* decl) = 0; 00802 virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0; 00803 00814 virtual void setNormaliseNormals(bool normalise) = 0; 00815 00828 virtual void _render(const RenderOperation& op); 00829 00831 const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; } 00832 00837 virtual void bindGpuProgram(GpuProgram* prg) = 0; 00838 00840 virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0; 00845 virtual void unbindGpuProgram(GpuProgramType gptype) = 0; 00846 00849 virtual void setClipPlanes(const PlaneList& clipPlanes) = 0; 00850 00852 virtual void _initRenderTargets(void); 00853 00857 virtual void _notifyCameraRemoved(const Camera* cam); 00858 00860 virtual void _updateAllRenderTargets(void); 00861 00863 virtual void setClipPlane (ushort index, const Plane &p); 00865 virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0; 00867 virtual void enableClipPlane (ushort index, bool enable) = 0; 00868 00871 virtual void setInvertVertexWinding(bool invert); 00883 virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, 00884 size_t right = 800, size_t bottom = 600) = 0; 00885 00893 virtual void clearFrameBuffer(unsigned int buffers, 00894 const ColourValue& colour = ColourValue::Black, 00895 Real depth = 1.0f, unsigned short stencil = 0) = 0; 00905 virtual Real getHorizontalTexelOffset(void) = 0; 00915 virtual Real getVerticalTexelOffset(void) = 0; 00916 00925 virtual Real getMinimumDepthInputValue(void) = 0; 00934 virtual Real getMaximumDepthInputValue(void) = 0; 00935 protected: 00936 00937 00939 RenderTargetMap mRenderTargets; 00941 RenderTargetPriorityMap mPrioritisedRenderTargets; 00943 RenderTarget * mActiveRenderTarget; 00944 00945 // Texture manager 00946 // A concrete class of this will be created and 00947 // made available under the TextureManager singleton, 00948 // managed by the RenderSystem 00949 TextureManager* mTextureManager; 00950 00952 RenderSystemCapabilities* mCapabilities; 00953 00954 // Active viewport (dest for future rendering operations) 00955 Viewport* mActiveViewport; 00956 00957 CullingMode mCullingMode; 00958 00959 bool mVSync; 00960 bool mWBuffer; 00961 00962 size_t mFaceCount; 00963 size_t mVertexCount; 00964 00966 Matrix4 mWorldMatrices[256]; 00967 00968 bool mInvertVertexWinding; 00969 00970 }; 00971 } 00972 00973 #endif
Copyright © 2000-2005 by The OGRE Team
Last modified Wed Feb 23 00:19:12 2005