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 00110 class _OgreExport RenderSystem 00111 { 00112 public: 00115 RenderSystem(); 00116 00119 virtual ~RenderSystem(); 00120 00123 virtual const String& getName(void) const = 0; 00124 00146 virtual ConfigOptionMap& getConfigOptions(void) = 0; 00147 00167 virtual void setConfigOption(const String &name, const String &value) = 0; 00168 00171 virtual HardwareOcclusionQuery* createHardwareOcclusionQuery(void) = 0; 00172 00175 virtual void destroyHardwareOcclusionQuery(HardwareOcclusionQuery *hq); 00176 00181 virtual String validateConfigOptions(void) = 0; 00182 00199 virtual RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window"); 00200 00203 virtual void reinitialise(void) = 0; 00204 00207 virtual void shutdown(void); 00208 00209 00212 virtual void setAmbientLight(float r, float g, float b) = 0; 00213 00216 virtual void setShadingType(ShadeOptions so) = 0; 00217 00223 virtual void setLightingEnabled(bool enabled) = 0; 00224 00231 void setWBufferEnabled(bool enabled); 00232 00235 bool getWBufferEnabled(void) const; 00236 00338 virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, 00339 bool fullScreen, const NameValuePairList *miscParams = 0) = 0; 00340 00367 RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height, 00368 TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8, 00369 const NameValuePairList *miscParams = 0 ); 00370 00375 virtual MultiRenderTarget * createMultiRenderTarget(const String & name) = 0; 00376 00378 virtual void destroyRenderWindow(const String& name); 00380 virtual void destroyRenderTexture(const String& name); 00382 virtual void destroyRenderTarget(const String& name); 00383 00386 virtual void attachRenderTarget( RenderTarget &target ); 00390 virtual RenderTarget * getRenderTarget( const String &name ); 00396 virtual RenderTarget * detachRenderTarget( const String &name ); 00397 00399 typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator; 00400 00402 virtual RenderTargetIterator getRenderTargetIterator(void) { 00403 return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() ); 00404 } 00407 virtual String getErrorDescription(long errorNumber) const = 0; 00408 00422 void setWaitForVerticalBlank(bool enabled); 00423 00426 bool getWaitForVerticalBlank(void) const; 00427 00428 // ------------------------------------------------------------------------ 00429 // Internal Rendering Access 00430 // All methods below here are normally only called by other OGRE classes 00431 // They can be called by library user if required 00432 // ------------------------------------------------------------------------ 00433 00434 00438 virtual void _useLights(const LightList& lights, unsigned short limit) = 0; 00440 virtual void _setWorldMatrix(const Matrix4 &m) = 0; 00442 virtual void _setWorldMatrices(const Matrix4* m, unsigned short count); 00444 virtual void _setViewMatrix(const Matrix4 &m) = 0; 00446 virtual void _setProjectionMatrix(const Matrix4 &m) = 0; 00452 virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl); 00454 virtual void _disableTextureUnit(size_t texUnit); 00456 virtual void _disableTextureUnitsFrom(size_t texUnit); 00490 virtual void _setSurfaceParams(const ColourValue &ambient, 00491 const ColourValue &diffuse, const ColourValue &specular, 00492 const ColourValue &emissive, Real shininess, 00493 TrackVertexColourType tracking = TVC_NONE) = 0; 00494 00500 virtual void _setPointSpritesEnabled(bool enabled) = 0; 00501 00512 virtual void _setPointParameters(Real size, bool attenuationEnabled, 00513 Real constant, Real linear, Real quadratic, Real minSize, Real maxSize) = 0; 00514 00515 00532 virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0; 00533 00543 virtual void _setTextureCoordSet(size_t unit, size_t index) = 0; 00544 00552 virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 00553 const Frustum* frustum = 0) = 0; 00554 00561 virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0; 00562 00569 virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter, 00570 FilterOptions magFilter, FilterOptions mipFilter); 00571 00577 virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0; 00578 00580 virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0; 00581 00583 virtual void _setTextureAddressingMode(size_t unit, const TextureUnitState::UVWAddressingMode& uvw) = 0; 00584 00586 virtual void _setTextureBorderColour(size_t unit, const ColourValue& colour) = 0; 00587 00592 virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0; 00593 00602 virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0; 00603 00609 virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0; 00614 virtual void _beginFrame(void) = 0; 00615 00616 00620 virtual void _endFrame(void) = 0; 00628 virtual void _setViewport(Viewport *vp) = 0; 00630 virtual Viewport* _getViewport(void); 00631 00643 virtual void _setCullingMode(CullingMode mode) = 0; 00644 00645 virtual CullingMode _getCullingMode(void) const; 00646 00660 virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0; 00661 00666 virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0; 00671 virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0; 00679 virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0; 00687 virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0; 00700 virtual void _setDepthBias(ushort bias) = 0; 00712 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; 00713 00714 00716 virtual void _beginGeometryCount(void); 00718 virtual unsigned int _getFaceCount(void) const; 00720 virtual unsigned int _getVertexCount(void) const; 00721 00730 virtual void convertColourValue(const ColourValue& colour, uint32* pDest); 00734 virtual VertexElementType getColourVertexElementType(void) const = 0; 00735 00742 virtual void _convertProjectionMatrix(const Matrix4& matrix, 00743 Matrix4& dest, bool forGpuProgram = false) = 0; 00744 00751 virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 00752 Matrix4& dest, bool forGpuProgram = false) = 0; 00753 00760 virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, 00761 Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0; 00768 virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 00769 Matrix4& dest, bool forGpuProgram = false) = 0; 00770 00787 virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 00788 bool forGpuProgram) = 0; 00789 00791 virtual void _setPolygonMode(PolygonMode level) = 0; 00792 00799 virtual void setStencilCheckEnabled(bool enabled) = 0; 00815 /*virtual bool hasHardwareStencil(void) = 0;*/ 00816 00852 virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 00853 uint32 refValue = 0, uint32 mask = 0xFFFFFFFF, 00854 StencilOperation stencilFailOp = SOP_KEEP, 00855 StencilOperation depthFailOp = SOP_KEEP, 00856 StencilOperation passOp = SOP_KEEP, 00857 bool twoSidedOperation = false) = 0; 00858 00859 00860 00862 virtual void setVertexDeclaration(VertexDeclaration* decl) = 0; 00864 virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0; 00865 00876 virtual void setNormaliseNormals(bool normalise) = 0; 00877 00890 virtual void _render(const RenderOperation& op); 00891 00893 const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; } 00894 00899 virtual void bindGpuProgram(GpuProgram* prg); 00900 00903 virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0; 00906 virtual void bindGpuProgramPassIterationParameters(GpuProgramType gptype) = 0; 00911 virtual void unbindGpuProgram(GpuProgramType gptype); 00912 00914 virtual bool isGpuProgramBound(GpuProgramType gptype); 00915 00918 virtual void setClipPlanes(const PlaneList& clipPlanes) = 0; 00919 00921 virtual void _initRenderTargets(void); 00922 00926 virtual void _notifyCameraRemoved(const Camera* cam); 00927 00929 virtual void _updateAllRenderTargets(void); 00930 00932 virtual void setClipPlane (ushort index, const Plane &p); 00934 virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0; 00936 virtual void enableClipPlane (ushort index, bool enable) = 0; 00937 00940 virtual void setInvertVertexWinding(bool invert); 00952 virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, 00953 size_t right = 800, size_t bottom = 600) = 0; 00954 00962 virtual void clearFrameBuffer(unsigned int buffers, 00963 const ColourValue& colour = ColourValue::Black, 00964 Real depth = 1.0f, unsigned short stencil = 0) = 0; 00974 virtual Real getHorizontalTexelOffset(void) = 0; 00984 virtual Real getVerticalTexelOffset(void) = 0; 00985 00994 virtual Real getMinimumDepthInputValue(void) = 0; 01003 virtual Real getMaximumDepthInputValue(void) = 0; 01009 void setCurrentPassIterationCount(const size_t count) { mCurrentPassIterationCount = count; } 01010 01015 class _OgreExport Listener 01016 { 01017 public: 01018 Listener() {} 01019 virtual ~Listener() {} 01020 01026 virtual void eventOccurred(const String& eventName, 01027 const NameValuePairList* parameters = 0) = 0; 01028 }; 01042 virtual void addListener(Listener* l); 01045 virtual void removeListener(Listener* l); 01046 01051 virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; } 01052 protected: 01053 01054 01056 RenderTargetMap mRenderTargets; 01058 RenderTargetPriorityMap mPrioritisedRenderTargets; 01060 RenderTarget * mActiveRenderTarget; 01062 GpuProgramParametersSharedPtr mActiveVertexGpuProgramParameters; 01063 GpuProgramParametersSharedPtr mActiveFragmentGpuProgramParameters; 01064 01065 // Texture manager 01066 // A concrete class of this will be created and 01067 // made available under the TextureManager singleton, 01068 // managed by the RenderSystem 01069 TextureManager* mTextureManager; 01070 01072 RenderSystemCapabilities* mCapabilities; 01073 01074 // Active viewport (dest for future rendering operations) 01075 Viewport* mActiveViewport; 01076 01077 CullingMode mCullingMode; 01078 01079 bool mVSync; 01080 bool mWBuffer; 01081 01082 size_t mFaceCount; 01083 size_t mVertexCount; 01084 01086 Matrix4 mWorldMatrices[256]; 01087 01089 ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2]; 01090 01091 bool mInvertVertexWinding; 01092 01094 size_t mCurrentPassIterationCount; 01095 01100 bool updatePassIterationRenderState(void); 01101 01103 StringVector mEventNames; 01104 01106 virtual void fireEvent(const String& name, const NameValuePairList* params = 0); 01107 01108 typedef std::list<Listener*> ListenerList; 01109 ListenerList mEventListeners; 01110 01111 typedef std::list<HardwareOcclusionQuery*> HardwareOcclusionQueryList; 01112 HardwareOcclusionQueryList mHwOcclusionQueries; 01113 01114 bool mVertexProgramBound; 01115 bool mFragmentProgramBound; 01116 01117 01118 01119 }; 01120 } 01121 01122 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:48 2006