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 #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; 00260 virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, unsigned int colourDepth, 00261 bool fullScreen, int left = 0, int top = 0, bool depthBuffer = true, 00262 RenderWindow* parentWindowHandle = 0) = 0; 00263 00280 virtual RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height ) = 0; 00281 00283 virtual void destroyRenderWindow(const String& name); 00285 virtual void destroyRenderTexture(const String& name); 00287 virtual void destroyRenderTarget(const String& name); 00288 00291 virtual void attachRenderTarget( RenderTarget &target ); 00295 virtual RenderTarget * getRenderTarget( const String &name ); 00301 virtual RenderTarget * detachRenderTarget( const String &name ); 00302 00305 virtual String getErrorDescription(long errorNumber) const = 0; 00306 00320 void setWaitForVerticalBlank(bool enabled); 00321 00324 bool getWaitForVerticalBlank(void) const; 00325 00326 // ------------------------------------------------------------------------ 00327 // Internal Rendering Access 00328 // All methods below here are normally only called by other OGRE classes 00329 // They can be called by library user if required 00330 // ------------------------------------------------------------------------ 00331 00332 00336 virtual void _useLights(const LightList& lights, unsigned short limit) = 0; 00338 virtual void _setWorldMatrix(const Matrix4 &m) = 0; 00340 virtual void _setWorldMatrices(const Matrix4* m, unsigned short count); 00342 virtual void _setViewMatrix(const Matrix4 &m) = 0; 00344 virtual void _setProjectionMatrix(const Matrix4 &m) = 0; 00350 virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl); 00352 virtual void _disableTextureUnit(size_t texUnit); 00354 virtual void _disableTextureUnitsFrom(size_t texUnit); 00384 virtual void _setSurfaceParams(const ColourValue &ambient, 00385 const ColourValue &diffuse, const ColourValue &specular, 00386 const ColourValue &emissive, Real shininess) = 0; 00403 virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0; 00404 00414 virtual void _setTextureCoordSet(size_t unit, size_t index) = 0; 00415 00423 virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 00424 const Frustum* frustum = 0) = 0; 00425 00432 virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0; 00433 00440 virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter, 00441 FilterOptions magFilter, FilterOptions mipFilter); 00442 00448 virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0; 00449 00451 virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0; 00452 00454 virtual void _setTextureAddressingMode(size_t unit, TextureUnitState::TextureAddressingMode tam) = 0; 00455 00460 virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0; 00461 00470 virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0; 00471 00477 virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0; 00482 virtual void _beginFrame(void) = 0; 00483 00484 00488 virtual void _endFrame(void) = 0; 00496 virtual void _setViewport(Viewport *vp) = 0; 00498 virtual Viewport* _getViewport(void); 00499 00511 virtual void _setCullingMode(CullingMode mode) = 0; 00512 00513 virtual CullingMode _getCullingMode(void) const; 00514 00528 virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0; 00529 00534 virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0; 00539 virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0; 00547 virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0; 00555 virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0; 00568 virtual void _setDepthBias(ushort bias) = 0; 00580 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; 00581 00582 00584 virtual void _beginGeometryCount(void); 00586 virtual unsigned int _getFaceCount(void) const; 00588 virtual unsigned int _getVertexCount(void) const; 00589 00598 virtual void convertColourValue(const ColourValue& colour, unsigned long* pDest) = 0; 00599 00606 virtual void _makeProjectionMatrix(Real fovy, Real aspect, Real nearPlane, Real farPlane, 00607 Matrix4& dest, bool forGpuProgram = false) = 0; 00608 00615 virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, 00616 Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0; 00623 virtual void _makeOrthoMatrix(Real fovy, Real aspect, Real nearPlane, Real farPlane, 00624 Matrix4& dest, bool forGpuProgram = false) = 0; 00626 virtual void _setRasterisationMode(SceneDetailLevel level) = 0; 00627 00634 virtual void setStencilCheckEnabled(bool enabled) = 0; 00650 /*virtual bool hasHardwareStencil(void) = 0;*/ 00651 00687 virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 00688 ulong refValue = 0, ulong mask = 0xFFFFFFFF, 00689 StencilOperation stencilFailOp = SOP_KEEP, 00690 StencilOperation depthFailOp = SOP_KEEP, 00691 StencilOperation passOp = SOP_KEEP, 00692 bool twoSidedOperation = false) = 0; 00693 00694 00695 00697 virtual void setVertexDeclaration(VertexDeclaration* decl) = 0; 00699 virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0; 00700 00711 virtual void setNormaliseNormals(bool normalise) = 0; 00712 00725 virtual void _render(const RenderOperation& op); 00726 00728 const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; } 00729 00734 virtual void bindGpuProgram(GpuProgram* prg) = 0; 00735 00737 virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0; 00742 virtual void unbindGpuProgram(GpuProgramType gptype) = 0; 00743 00746 virtual void setClipPlanes(const PlaneList& clipPlanes) = 0; 00747 00749 virtual void _initRenderTargets(void); 00750 00754 virtual void _notifyCameraRemoved(const Camera* cam); 00755 00757 virtual void _updateAllRenderTargets(void); 00758 00760 virtual void setClipPlane (ushort index, const Plane &p); 00762 virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0; 00764 virtual void enableClipPlane (ushort index, bool enable) = 0; 00765 00768 virtual void setInvertVertexWinding(bool invert); 00780 virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, 00781 size_t right = 800, size_t bottom = 600) = 0; 00782 00790 virtual void clearFrameBuffer(unsigned int buffers, 00791 const ColourValue& colour = ColourValue::Black, 00792 Real depth = 1.0f, unsigned short stencil = 0) = 0; 00793 protected: 00794 00795 00797 RenderTargetMap mRenderTargets; 00799 RenderTargetPriorityMap mPrioritisedRenderTargets; 00801 RenderTarget * mActiveRenderTarget; 00802 00803 // Texture manager 00804 // A concrete class of this will be created and 00805 // made available under the TextureManager singleton, 00806 // managed by the RenderSystem 00807 TextureManager* mTextureManager; 00808 00810 RenderSystemCapabilities* mCapabilities; 00811 00812 // Active viewport (dest for future rendering operations) 00813 Viewport* mActiveViewport; 00814 00815 CullingMode mCullingMode; 00816 00817 bool mVSync; 00818 00819 size_t mFaceCount; 00820 size_t mVertexCount; 00821 00823 Matrix4 mWorldMatrices[256]; 00824 00825 bool mInvertVertexWinding; 00826 00827 }; 00828 } 00829 00830 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:39 2004