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 #include "OgreIteratorWrappers.h" 00045 00046 namespace Ogre 00047 { 00048 typedef std::map< String, RenderTarget * > RenderTargetMap; 00049 typedef std::multimap<uchar, RenderTarget * > RenderTargetPriorityMap; 00050 00051 class TextureManager; 00053 enum TexCoordCalcMethod 00054 { 00056 TEXCALC_NONE, 00058 TEXCALC_ENVIRONMENT_MAP, 00060 TEXCALC_ENVIRONMENT_MAP_PLANAR, 00061 TEXCALC_ENVIRONMENT_MAP_REFLECTION, 00062 TEXCALC_ENVIRONMENT_MAP_NORMAL, 00064 TEXCALC_PROJECTIVE_TEXTURE 00065 }; 00067 enum StencilOperation 00068 { 00070 SOP_KEEP, 00072 SOP_ZERO, 00074 SOP_REPLACE, 00076 SOP_INCREMENT, 00078 SOP_DECREMENT, 00080 SOP_INCREMENT_WRAP, 00082 SOP_DECREMENT_WRAP, 00084 SOP_INVERT 00085 }; 00086 00088 enum FrameBufferType { 00089 FBT_COLOUR = 0x1, 00090 FBT_DEPTH = 0x2, 00091 FBT_STENCIL = 0x4 00092 }; 00093 00117 class _OgreExport RenderSystem 00118 { 00119 public: 00122 RenderSystem(); 00123 00126 virtual ~RenderSystem(); 00127 00130 virtual const String& getName(void) const = 0; 00131 00153 virtual ConfigOptionMap& getConfigOptions(void) = 0; 00154 00174 virtual void setConfigOption(const String &name, const String &value) = 0; 00175 00176 virtual HardwareOcclusionQuery* createHardwareOcclusionQuery() = 0; 00177 00182 virtual String validateConfigOptions(void) = 0; 00183 00200 virtual RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window"); 00201 00204 virtual void reinitialise(void) = 0; 00205 00208 virtual void shutdown(void); 00209 00210 00213 virtual void setAmbientLight(float r, float g, float b) = 0; 00214 00217 virtual void setShadingType(ShadeOptions so) = 0; 00218 00224 virtual void setLightingEnabled(bool enabled) = 0; 00225 00232 void setWBufferEnabled(bool enabled); 00233 00236 bool getWBufferEnabled(void) const; 00237 00334 virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, 00335 bool fullScreen, const NameValuePairList *miscParams = 0) = 0; 00336 00371 virtual RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height, 00372 TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8, 00373 const NameValuePairList *miscParams = 0 ) = 0; 00374 00376 virtual void destroyRenderWindow(const String& name); 00378 virtual void destroyRenderTexture(const String& name); 00380 virtual void destroyRenderTarget(const String& name); 00381 00384 virtual void attachRenderTarget( RenderTarget &target ); 00388 virtual RenderTarget * getRenderTarget( const String &name ); 00394 virtual RenderTarget * detachRenderTarget( const String &name ); 00395 00397 typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator; 00398 00400 virtual RenderTargetIterator getRenderTargetIterator(void) { 00401 return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() ); 00402 } 00405 virtual String getErrorDescription(long errorNumber) const = 0; 00406 00420 void setWaitForVerticalBlank(bool enabled); 00421 00424 bool getWaitForVerticalBlank(void) const; 00425 00426 // ------------------------------------------------------------------------ 00427 // Internal Rendering Access 00428 // All methods below here are normally only called by other OGRE classes 00429 // They can be called by library user if required 00430 // ------------------------------------------------------------------------ 00431 00432 00436 virtual void _useLights(const LightList& lights, unsigned short limit) = 0; 00438 virtual void _setWorldMatrix(const Matrix4 &m) = 0; 00440 virtual void _setWorldMatrices(const Matrix4* m, unsigned short count); 00442 virtual void _setViewMatrix(const Matrix4 &m) = 0; 00444 virtual void _setProjectionMatrix(const Matrix4 &m) = 0; 00450 virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl); 00452 virtual void _disableTextureUnit(size_t texUnit); 00454 virtual void _disableTextureUnitsFrom(size_t texUnit); 00488 virtual void _setSurfaceParams(const ColourValue &ambient, 00489 const ColourValue &diffuse, const ColourValue &specular, 00490 const ColourValue &emissive, Real shininess, 00491 TrackVertexColourType tracking = TVC_NONE) = 0; 00508 virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0; 00509 00519 virtual void _setTextureCoordSet(size_t unit, size_t index) = 0; 00520 00528 virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 00529 const Frustum* frustum = 0) = 0; 00530 00537 virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0; 00538 00545 virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter, 00546 FilterOptions magFilter, FilterOptions mipFilter); 00547 00553 virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0; 00554 00556 virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0; 00557 00559 virtual void _setTextureAddressingMode(size_t unit, TextureUnitState::TextureAddressingMode tam) = 0; 00560 00565 virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0; 00566 00575 virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0; 00576 00582 virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0; 00587 virtual void _beginFrame(void) = 0; 00588 00589 00593 virtual void _endFrame(void) = 0; 00601 virtual void _setViewport(Viewport *vp) = 0; 00603 virtual Viewport* _getViewport(void); 00604 00616 virtual void _setCullingMode(CullingMode mode) = 0; 00617 00618 virtual CullingMode _getCullingMode(void) const; 00619 00633 virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0; 00634 00639 virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0; 00644 virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0; 00652 virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0; 00660 virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0; 00673 virtual void _setDepthBias(ushort bias) = 0; 00685 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; 00686 00687 00689 virtual void _beginGeometryCount(void); 00691 virtual unsigned int _getFaceCount(void) const; 00693 virtual unsigned int _getVertexCount(void) const; 00694 00703 virtual void convertColourValue(const ColourValue& colour, uint32* pDest) = 0; 00704 00711 virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 00712 Matrix4& dest, bool forGpuProgram = false) = 0; 00713 00720 virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, 00721 Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0; 00728 virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 00729 Matrix4& dest, bool forGpuProgram = false) = 0; 00730 00747 virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 00748 bool forGpuProgram) = 0; 00749 00751 virtual void _setRasterisationMode(SceneDetailLevel level) = 0; 00752 00759 virtual void setStencilCheckEnabled(bool enabled) = 0; 00775 /*virtual bool hasHardwareStencil(void) = 0;*/ 00776 00812 virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 00813 uint32 refValue = 0, uint32 mask = 0xFFFFFFFF, 00814 StencilOperation stencilFailOp = SOP_KEEP, 00815 StencilOperation depthFailOp = SOP_KEEP, 00816 StencilOperation passOp = SOP_KEEP, 00817 bool twoSidedOperation = false) = 0; 00818 00819 00820 00822 virtual void setVertexDeclaration(VertexDeclaration* decl) = 0; 00824 virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0; 00825 00836 virtual void setNormaliseNormals(bool normalise) = 0; 00837 00850 virtual void _render(const RenderOperation& op); 00851 00853 const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; } 00854 00859 virtual void bindGpuProgram(GpuProgram* prg) = 0; 00860 00862 virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0; 00867 virtual void unbindGpuProgram(GpuProgramType gptype) = 0; 00868 00871 virtual void setClipPlanes(const PlaneList& clipPlanes) = 0; 00872 00874 virtual void _initRenderTargets(void); 00875 00879 virtual void _notifyCameraRemoved(const Camera* cam); 00880 00882 virtual void _updateAllRenderTargets(void); 00883 00885 virtual void setClipPlane (ushort index, const Plane &p); 00887 virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0; 00889 virtual void enableClipPlane (ushort index, bool enable) = 0; 00890 00893 virtual void setInvertVertexWinding(bool invert); 00905 virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, 00906 size_t right = 800, size_t bottom = 600) = 0; 00907 00915 virtual void clearFrameBuffer(unsigned int buffers, 00916 const ColourValue& colour = ColourValue::Black, 00917 Real depth = 1.0f, unsigned short stencil = 0) = 0; 00927 virtual Real getHorizontalTexelOffset(void) = 0; 00937 virtual Real getVerticalTexelOffset(void) = 0; 00938 00947 virtual Real getMinimumDepthInputValue(void) = 0; 00956 virtual Real getMaximumDepthInputValue(void) = 0; 00957 00962 class _OgreExport Listener 00963 { 00964 public: 00965 Listener() {} 00966 virtual ~Listener() {} 00967 00973 virtual void eventOccurred(const String& eventName, 00974 const NameValuePairList* parameters = 0) = 0; 00975 }; 00989 virtual void addListener(Listener* l); 00992 virtual void removeListener(Listener* l); 00993 00998 virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; } 00999 protected: 01000 01001 01003 RenderTargetMap mRenderTargets; 01005 RenderTargetPriorityMap mPrioritisedRenderTargets; 01007 RenderTarget * mActiveRenderTarget; 01008 01009 // Texture manager 01010 // A concrete class of this will be created and 01011 // made available under the TextureManager singleton, 01012 // managed by the RenderSystem 01013 TextureManager* mTextureManager; 01014 01016 RenderSystemCapabilities* mCapabilities; 01017 01018 // Active viewport (dest for future rendering operations) 01019 Viewport* mActiveViewport; 01020 01021 CullingMode mCullingMode; 01022 01023 bool mVSync; 01024 bool mWBuffer; 01025 01026 size_t mFaceCount; 01027 size_t mVertexCount; 01028 01030 Matrix4 mWorldMatrices[256]; 01031 01033 ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2]; 01034 01035 bool mInvertVertexWinding; 01036 01038 StringVector mEventNames; 01039 01041 virtual void fireEvent(const String& name, const NameValuePairList* params = 0); 01042 01043 typedef std::list<Listener*> ListenerList; 01044 ListenerList mEventListeners; 01045 01046 }; 01047 } 01048 01049 #endif
Copyright © 2000-2005 by The OGRE Team
Last modified Sun Nov 20 12:36:05 2005