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 © 2000-2002 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 00044 namespace Ogre 00045 { 00046 typedef std::map< String, RenderTarget * > RenderTargetMap; 00047 typedef std::multimap<uchar, RenderTarget * > RenderTargetPriorityMap; 00048 00049 class TextureManager; 00051 enum TexCoordCalcMethod 00052 { 00054 TEXCALC_NONE, 00056 TEXCALC_ENVIRONMENT_MAP, 00058 TEXCALC_ENVIRONMENT_MAP_PLANAR, 00059 TEXCALC_ENVIRONMENT_MAP_REFLECTION, 00060 TEXCALC_ENVIRONMENT_MAP_NORMAL 00061 }; 00063 enum StencilOperation 00064 { 00066 SOP_KEEP, 00068 SOP_ZERO, 00070 SOP_REPLACE, 00072 SOP_INCREMENT, 00074 SOP_DECREMENT, 00076 SOP_INVERT 00077 }; 00078 00102 class _OgreExport RenderSystem 00103 { 00104 public: 00107 RenderSystem(); 00108 00111 virtual ~RenderSystem(); 00112 00115 virtual const String& getName(void) const = 0; 00116 00138 virtual ConfigOptionMap& getConfigOptions(void) = 0; 00139 00159 virtual void setConfigOption(const String &name, const String &value) = 0; 00160 00165 virtual String validateConfigOptions(void) = 0; 00166 00183 virtual RenderWindow* initialise(bool autoCreateWindow); 00184 00187 virtual void reinitialise(void) = 0; 00188 00191 virtual void shutdown(void); 00192 00193 00196 virtual void setAmbientLight(float r, float g, float b) = 0; 00197 00200 virtual void setShadingType(ShadeOptions so) = 0; 00201 00207 virtual void setLightingEnabled(bool enabled) = 0; 00246 virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, unsigned int colourDepth, 00247 bool fullScreen, int left = 0, int top = 0, bool depthBuffer = true, 00248 RenderWindow* parentWindowHandle = 0) = 0; 00249 00266 virtual RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height ) = 0; 00267 00270 virtual void attachRenderTarget( RenderTarget &target ); 00274 virtual RenderTarget * getRenderTarget( const String &name ); 00280 virtual RenderTarget * detachRenderTarget( const String &name ); 00281 00284 virtual String getErrorDescription(long errorNumber) = 0; 00285 00299 void setWaitForVerticalBlank(bool enabled); 00300 00303 bool getWaitForVerticalBlank(void) const; 00304 00305 // ------------------------------------------------------------------------ 00306 // Internal Rendering Access 00307 // All methods below here are normally only called by other OGRE classes 00308 // They can be called by library user if required 00309 // ------------------------------------------------------------------------ 00310 00311 00315 virtual void _useLights(const LightList& lights, unsigned short limit) = 0; 00317 virtual void _setWorldMatrix(const Matrix4 &m) = 0; 00319 virtual void _setWorldMatrices(const Matrix4* m, unsigned short count); 00321 virtual void _setViewMatrix(const Matrix4 &m) = 0; 00323 virtual void _setProjectionMatrix(const Matrix4 &m) = 0; 00329 virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl); 00331 virtual void _disableTextureUnit(size_t texUnit); 00333 virtual void _disableTextureUnitsFrom(size_t texUnit); 00363 virtual void _setSurfaceParams(const ColourValue &ambient, 00364 const ColourValue &diffuse, const ColourValue &specular, 00365 const ColourValue &emissive, Real shininess) = 0; 00382 virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0; 00383 00393 virtual void _setTextureCoordSet(size_t unit, size_t index) = 0; 00394 00401 virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m) = 0; 00402 00409 virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0; 00410 00417 virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter, 00418 FilterOptions magFilter, FilterOptions mipFilter); 00419 00425 virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0; 00426 00428 virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0; 00429 00431 virtual void _setTextureAddressingMode(size_t unit, TextureUnitState::TextureAddressingMode tam) = 0; 00432 00437 virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0; 00438 00447 virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0; 00448 00454 virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0; 00459 virtual void _beginFrame(void) = 0; 00460 00461 00465 virtual void _endFrame(void) = 0; 00473 virtual void _setViewport(Viewport *vp) = 0; 00475 virtual Viewport* _getViewport(void); 00476 00488 virtual void _setCullingMode(CullingMode mode) = 0; 00489 00490 virtual CullingMode _getCullingMode(void) const; 00491 00505 virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0; 00506 00511 virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0; 00516 virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0; 00524 virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0; 00532 virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0; 00545 virtual void _setDepthBias(ushort bias) = 0; 00557 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; 00558 00559 00561 virtual void _beginGeometryCount(void); 00563 virtual unsigned int _getFaceCount(void) const; 00565 virtual unsigned int _getVertexCount(void) const; 00566 00575 virtual void convertColourValue(const ColourValue& colour, unsigned long* pDest) = 0; 00576 00583 virtual void _makeProjectionMatrix(Real fovy, Real aspect, Real nearPlane, Real farPlane, 00584 Matrix4& dest, bool forGpuProgram = false) = 0; 00585 00587 virtual void _setRasterisationMode(SceneDetailLevel level) = 0; 00588 00595 virtual void setStencilCheckEnabled(bool enabled) = 0; 00611 /*virtual bool hasHardwareStencil(void) = 0;*/ 00612 00645 virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 00646 ulong refValue = 0, ulong mask = 0xFFFFFFFF, 00647 StencilOperation stencilFailOp = SOP_KEEP, 00648 StencilOperation depthFailOp = SOP_KEEP, 00649 StencilOperation passOp = SOP_KEEP); 00650 00656 virtual void setStencilBufferFunction(CompareFunction func) = 0; 00664 virtual void setStencilBufferReferenceValue(ulong refValue) = 0; 00670 virtual void setStencilBufferMask(ulong mask) = 0; 00672 virtual void setStencilBufferFailOperation(StencilOperation op) = 0; 00675 virtual void setStencilBufferDepthFailOperation(StencilOperation op) = 0; 00678 virtual void setStencilBufferPassOperation(StencilOperation op) = 0; 00679 00686 virtual void softwareVertexBlend(VertexData* vertexData, Matrix4* pMatrices); 00687 00689 virtual void setVertexDeclaration(VertexDeclaration* decl) = 0; 00691 virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0; 00692 00703 virtual void setNormaliseNormals(bool normalise) = 0; 00704 00717 virtual void _render(const RenderOperation& op); 00718 00720 const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; } 00721 00726 virtual void bindGpuProgram(GpuProgram* prg) = 0; 00727 00729 virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0; 00734 virtual void unbindGpuProgram(GpuProgramType gptype) = 0; 00735 00737 virtual void _initRenderTargets(void); 00738 00740 virtual void _updateAllRenderTargets(void); 00743 virtual void setInvertVertexWinding(bool invert); 00744 protected: 00745 00746 00748 RenderTargetMap mRenderTargets; 00750 RenderTargetPriorityMap mPrioritisedRenderTargets; 00752 RenderTarget * mActiveRenderTarget; 00753 00754 // Texture manager 00755 // A concrete class of this will be created and 00756 // made available under the TextureManager singleton, 00757 // managed by the RenderSystem 00758 TextureManager* mTextureManager; 00759 00761 RenderSystemCapabilities* mCapabilities; 00762 00763 // Active viewport (dest for future rendering operations) 00764 Viewport* mActiveViewport; 00765 00766 CullingMode mCullingMode; 00767 00768 bool mVSync; 00769 00770 size_t mFaceCount; 00771 size_t mVertexCount; 00772 00774 Matrix4 mWorldMatrices[256]; 00775 00776 bool mInvertVertexWinding; 00777 00778 }; 00779 } 00780 00781 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:25 2004