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; 00222 00229 void setWBufferEnabled(bool enabled); 00230 00233 bool getWBufferEnabled(void) const; 00234 00273 virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, unsigned int colourDepth, 00274 bool fullScreen, int left = 0, int top = 0, bool depthBuffer = true, 00275 RenderWindow* parentWindowHandle = 0) = 0; 00276 00293 virtual RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height ) = 0; 00294 00296 virtual void destroyRenderWindow(const String& name); 00298 virtual void destroyRenderTexture(const String& name); 00300 virtual void destroyRenderTarget(const String& name); 00301 00304 virtual void attachRenderTarget( RenderTarget &target ); 00308 virtual RenderTarget * getRenderTarget( const String &name ); 00314 virtual RenderTarget * detachRenderTarget( const String &name ); 00315 00318 virtual String getErrorDescription(long errorNumber) const = 0; 00319 00333 void setWaitForVerticalBlank(bool enabled); 00334 00337 bool getWaitForVerticalBlank(void) const; 00338 00339 // ------------------------------------------------------------------------ 00340 // Internal Rendering Access 00341 // All methods below here are normally only called by other OGRE classes 00342 // They can be called by library user if required 00343 // ------------------------------------------------------------------------ 00344 00345 00349 virtual void _useLights(const LightList& lights, unsigned short limit) = 0; 00351 virtual void _setWorldMatrix(const Matrix4 &m) = 0; 00353 virtual void _setWorldMatrices(const Matrix4* m, unsigned short count); 00355 virtual void _setViewMatrix(const Matrix4 &m) = 0; 00357 virtual void _setProjectionMatrix(const Matrix4 &m) = 0; 00363 virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl); 00365 virtual void _disableTextureUnit(size_t texUnit); 00367 virtual void _disableTextureUnitsFrom(size_t texUnit); 00397 virtual void _setSurfaceParams(const ColourValue &ambient, 00398 const ColourValue &diffuse, const ColourValue &specular, 00399 const ColourValue &emissive, Real shininess) = 0; 00416 virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0; 00417 00427 virtual void _setTextureCoordSet(size_t unit, size_t index) = 0; 00428 00436 virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 00437 const Frustum* frustum = 0) = 0; 00438 00445 virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0; 00446 00453 virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter, 00454 FilterOptions magFilter, FilterOptions mipFilter); 00455 00461 virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0; 00462 00464 virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0; 00465 00467 virtual void _setTextureAddressingMode(size_t unit, TextureUnitState::TextureAddressingMode tam) = 0; 00468 00473 virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0; 00474 00483 virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0; 00484 00490 virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0; 00495 virtual void _beginFrame(void) = 0; 00496 00497 00501 virtual void _endFrame(void) = 0; 00509 virtual void _setViewport(Viewport *vp) = 0; 00511 virtual Viewport* _getViewport(void); 00512 00524 virtual void _setCullingMode(CullingMode mode) = 0; 00525 00526 virtual CullingMode _getCullingMode(void) const; 00527 00541 virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0; 00542 00547 virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0; 00552 virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0; 00560 virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0; 00568 virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0; 00581 virtual void _setDepthBias(ushort bias) = 0; 00593 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; 00594 00595 00597 virtual void _beginGeometryCount(void); 00599 virtual unsigned int _getFaceCount(void) const; 00601 virtual unsigned int _getVertexCount(void) const; 00602 00611 virtual void convertColourValue(const ColourValue& colour, unsigned long* pDest) = 0; 00612 00619 virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 00620 Matrix4& dest, bool forGpuProgram = false) = 0; 00621 00628 virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, 00629 Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0; 00636 virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 00637 Matrix4& dest, bool forGpuProgram = false) = 0; 00638 00655 virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 00656 bool forGpuProgram) = 0; 00657 00659 virtual void _setRasterisationMode(SceneDetailLevel level) = 0; 00660 00667 virtual void setStencilCheckEnabled(bool enabled) = 0; 00683 /*virtual bool hasHardwareStencil(void) = 0;*/ 00684 00720 virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 00721 ulong refValue = 0, ulong mask = 0xFFFFFFFF, 00722 StencilOperation stencilFailOp = SOP_KEEP, 00723 StencilOperation depthFailOp = SOP_KEEP, 00724 StencilOperation passOp = SOP_KEEP, 00725 bool twoSidedOperation = false) = 0; 00726 00727 00728 00730 virtual void setVertexDeclaration(VertexDeclaration* decl) = 0; 00732 virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0; 00733 00744 virtual void setNormaliseNormals(bool normalise) = 0; 00745 00758 virtual void _render(const RenderOperation& op); 00759 00761 const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; } 00762 00767 virtual void bindGpuProgram(GpuProgram* prg) = 0; 00768 00770 virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0; 00775 virtual void unbindGpuProgram(GpuProgramType gptype) = 0; 00776 00779 virtual void setClipPlanes(const PlaneList& clipPlanes) = 0; 00780 00782 virtual void _initRenderTargets(void); 00783 00787 virtual void _notifyCameraRemoved(const Camera* cam); 00788 00790 virtual void _updateAllRenderTargets(void); 00791 00793 virtual void setClipPlane (ushort index, const Plane &p); 00795 virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0; 00797 virtual void enableClipPlane (ushort index, bool enable) = 0; 00798 00801 virtual void setInvertVertexWinding(bool invert); 00813 virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, 00814 size_t right = 800, size_t bottom = 600) = 0; 00815 00823 virtual void clearFrameBuffer(unsigned int buffers, 00824 const ColourValue& colour = ColourValue::Black, 00825 Real depth = 1.0f, unsigned short stencil = 0) = 0; 00835 virtual Real getHorizontalTexelOffset(void) = 0; 00845 virtual Real getVerticalTexelOffset(void) = 0; 00846 00855 virtual Real getMinimumDepthInputValue(void) = 0; 00864 virtual Real getMaximumDepthInputValue(void) = 0; 00865 protected: 00866 00867 00869 RenderTargetMap mRenderTargets; 00871 RenderTargetPriorityMap mPrioritisedRenderTargets; 00873 RenderTarget * mActiveRenderTarget; 00874 00875 // Texture manager 00876 // A concrete class of this will be created and 00877 // made available under the TextureManager singleton, 00878 // managed by the RenderSystem 00879 TextureManager* mTextureManager; 00880 00882 RenderSystemCapabilities* mCapabilities; 00883 00884 // Active viewport (dest for future rendering operations) 00885 Viewport* mActiveViewport; 00886 00887 CullingMode mCullingMode; 00888 00889 bool mVSync; 00890 bool mWBuffer; 00891 00892 size_t mFaceCount; 00893 size_t mVertexCount; 00894 00896 Matrix4 mWorldMatrices[256]; 00897 00898 bool mInvertVertexWinding; 00899 00900 }; 00901 } 00902 00903 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:42 2004