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 "OgreMaterial.h" 00034 #include "OgreCommon.h" 00035 00036 #include "OgreRenderOperation.h" 00037 #include "OgreRenderTarget.h" 00038 #include "OgreRenderTexture.h" 00039 #include "OgreFrameListener.h" 00040 #include "OgreConfigOptionMap.h" 00041 00042 namespace Ogre 00043 { 00044 typedef std::map< String, RenderTarget * > RenderTargetMap; 00045 typedef std::multimap<uchar, RenderTarget * > RenderTargetPriorityMap; 00046 00047 class TextureManager; 00049 enum TexCoordCalcMethod 00050 { 00052 TEXCALC_NONE, 00054 TEXCALC_ENVIRONMENT_MAP, 00056 TEXCALC_ENVIRONMENT_MAP_PLANAR 00057 }; 00059 enum StencilOperation 00060 { 00062 SOP_KEEP, 00064 SOP_ZERO, 00066 SOP_REPLACE, 00068 SOP_INCREMENT, 00070 SOP_DECREMENT, 00072 SOP_INVERT 00073 }; 00074 00098 class _OgreExport RenderSystem 00099 { 00100 public: 00103 RenderSystem(); 00104 00107 virtual ~RenderSystem(); 00108 00111 virtual const String& getName(void) const = 0; 00112 00134 virtual ConfigOptionMap& getConfigOptions(void) = 0; 00135 00155 virtual void setConfigOption(const String &name, const String &value) = 0; 00156 00161 virtual String validateConfigOptions(void) = 0; 00162 00179 virtual RenderWindow* initialise(bool autoCreateWindow); 00180 00183 virtual void reinitialise(void) = 0; 00184 00187 virtual void shutdown(void); 00188 00202 virtual void addFrameListener(FrameListener* newListener); 00203 00206 virtual void removeFrameListener(FrameListener* oldListener); 00207 00229 virtual void startRendering(void); 00230 00233 virtual void setAmbientLight(float r, float g, float b) = 0; 00234 00237 virtual void setShadingType(ShadeOptions so) = 0; 00238 00248 virtual void setTextureFiltering(TextureFilterOptions fo) = 0; 00249 00255 virtual void setLightingEnabled(bool enabled) = 0; 00294 virtual RenderWindow* createRenderWindow(const String &name, int width, int height, int colourDepth, 00295 bool fullScreen, int left = 0, int top = 0, bool depthBuffer = true, 00296 RenderWindow* parentWindowHandle = 0) = 0; 00297 00314 virtual RenderTexture * createRenderTexture( const String & name, int width, int height ) = 0; 00315 00318 virtual void attachRenderTarget( RenderTarget &target ); 00322 virtual RenderTarget * getRenderTarget( const String &name ); 00328 virtual RenderTarget * detachRenderTarget( const String &name ); 00329 00332 virtual String getErrorDescription(long errorNumber) = 0; 00333 00347 void setWaitForVerticalBlank(bool enabled); 00348 00351 bool getWaitForVerticalBlank(void); 00352 00353 // ------------------------------------------------------------------------ 00354 // Internal Rendering Access 00355 // All methods below here are normally only called by other OGRE classes 00356 // They can be called by library user if required 00357 // ------------------------------------------------------------------------ 00358 00359 00368 virtual void _addLight(Light *lt) = 0; 00376 virtual void _removeLight(Light *lt) = 0; 00380 virtual void _modifyLight(Light* lt) = 0; 00388 virtual void _removeAllLights(void) = 0; 00389 00401 virtual void _pushRenderState(void) = 0; 00403 virtual void _popRenderState(void) = 0; 00405 virtual void _setWorldMatrix(const Matrix4 &m) = 0; 00407 virtual void _setWorldMatrices(const Matrix4* m, unsigned short count); 00409 virtual void _setViewMatrix(const Matrix4 &m) = 0; 00411 virtual void _setProjectionMatrix(const Matrix4 &m) = 0; 00417 virtual void _setTextureUnitSettings(int texUnit, Material::TextureLayer& tl); 00419 virtual void _disableTextureUnit(int texUnit); 00449 virtual void _setSurfaceParams(const ColourValue &ambient, 00450 const ColourValue &diffuse, const ColourValue &specular, 00451 const ColourValue &emissive, Real shininess) = 0; 00468 virtual void _setTexture(int unit, bool enabled, const String &texname) = 0; 00478 virtual unsigned short _getNumTextureUnits(void) = 0; 00479 00489 virtual void _setTextureCoordSet(int unit, int index) = 0; 00490 00497 virtual void _setTextureCoordCalculation(int unit, TexCoordCalcMethod m) = 0; 00498 00505 virtual void _setTextureBlendMode(int unit, const LayerBlendModeEx& bm) = 0; 00506 00508 virtual void _setTextureAddressingMode(int unit, Material::TextureLayer::TextureAddressingMode tam) = 0; 00509 00514 virtual void _setTextureMatrix(int unit, const Matrix4& xform) = 0; 00515 00524 virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0; 00525 00531 virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0; 00536 virtual void _beginFrame(void) = 0; 00537 00550 virtual void _render(RenderOperation& op); 00551 00552 00556 virtual void _endFrame(void) = 0; 00564 virtual void _setViewport(Viewport *vp) = 0; 00566 virtual Viewport* _getViewport(void); 00567 00579 virtual void _setCullingMode(CullingMode mode) = 0; 00580 00581 virtual CullingMode _getCullingMode(void); 00582 00596 virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0; 00597 00602 virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0; 00607 virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0; 00615 virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0; 00628 virtual void _setDepthBias(ushort bias) = 0; 00640 virtual void _setFog(FogMode mode = FOG_NONE, ColourValue colour = ColourValue::White, Real expDensity = 1.0, Real linearStart = 0.0, Real linearEnd = 1.0) = 0; 00641 00642 00644 virtual void _beginGeometryCount(void); 00646 virtual unsigned int _getFaceCount(void); 00648 virtual unsigned int _getVertexCount(void); 00649 00658 virtual void convertColourValue(const ColourValue& colour, unsigned long* pDest) = 0; 00659 00663 virtual bool _isVertexBlendSupported(void); 00664 00666 virtual unsigned short _getNumVertexBlendMatrices(void); 00667 00674 virtual void _makeProjectionMatrix(Real fovy, Real aspect, Real nearPlane, Real farPlane, Matrix4& dest) = 0; 00675 00677 virtual void _setRasterisationMode(SceneDetailLevel level) = 0; 00678 00685 virtual void setStencilCheckEnabled(bool enabled) = 0; 00701 virtual bool hasHardwareStencil(void) = 0; 00702 00708 virtual ushort getStencilBufferBitDepth(void) = 0; 00709 00742 virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 00743 ulong refValue = 0, ulong mask = 0xFFFFFFFF, 00744 StencilOperation stencilFailOp = SOP_KEEP, 00745 StencilOperation depthFailOp = SOP_KEEP, 00746 StencilOperation passOp = SOP_KEEP); 00747 00753 virtual void setStencilBufferFunction(CompareFunction func) = 0; 00761 virtual void setStencilBufferReferenceValue(ulong refValue) = 0; 00767 virtual void setStencilBufferMask(ulong mask) = 0; 00769 virtual void setStencilBufferFailOperation(StencilOperation op) = 0; 00772 virtual void setStencilBufferDepthFailOperation(StencilOperation op) = 0; 00775 virtual void setStencilBufferPassOperation(StencilOperation op) = 0; 00776 00787 void softwareVertexBlend(RenderOperation& op, Matrix4* pMatrices); 00788 00789 00790 00791 protected: 00792 00794 std::set<FrameListener*> mFrameListeners; 00795 00797 bool fireFrameStarted(FrameEvent& evt); 00799 bool fireFrameEnded(FrameEvent& evt); 00800 // Stored options 00801 ConfigOptionMap mOptions; 00802 00804 RenderTargetMap mRenderTargets; 00806 RenderTargetPriorityMap mPrioritisedRenderTargets; 00808 RenderTarget * mActiveRenderTarget; 00809 00810 // Texture manager 00811 // A concrete class of this will be created and 00812 // made available under the TextureManager singleton, 00813 // managed by the RenderSystem 00814 TextureManager* mTextureManager; 00815 00816 // Active viewport (dest for future rendering operations) 00817 Viewport* mActiveViewport; 00818 00819 CullingMode mCullingMode; 00820 00821 bool mVSync; 00822 00823 // Store record of texture unit settings for efficient alterations 00824 Material::TextureLayer mTextureUnits[OGRE_MAX_TEXTURE_LAYERS]; 00825 00826 unsigned int mFaceCount; 00827 unsigned int mVertexCount; 00828 00830 Matrix4 mWorldMatrices[256]; 00831 00833 std::vector<Real> mTempVertexBlendBuffer; 00834 std::vector<Real> mTempNormalBlendBuffer; 00835 }; 00836 } 00837 00838 #endif
Copyright © 2002 by The OGRE Team