Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreRenderSystem.h

Go to the documentation of this file.
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 
00333         virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, 
00334             bool fullScreen, const NameValuePairList *miscParams = 0) = 0;
00335 
00370         virtual RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height,
00371             TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8, 
00372             const NameValuePairList *miscParams = 0 ) = 0; 
00373 
00375         virtual void destroyRenderWindow(const String& name);
00377         virtual void destroyRenderTexture(const String& name);
00379         virtual void destroyRenderTarget(const String& name);
00380 
00383         virtual void attachRenderTarget( RenderTarget &target );
00387         virtual RenderTarget * getRenderTarget( const String &name );
00393         virtual RenderTarget * detachRenderTarget( const String &name );
00394 
00396         typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator;
00397 
00399         virtual RenderTargetIterator getRenderTargetIterator(void) {
00400             return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() );
00401         }
00404         virtual String getErrorDescription(long errorNumber) const = 0;
00405 
00419         void setWaitForVerticalBlank(bool enabled);
00420 
00423         bool getWaitForVerticalBlank(void) const;
00424 
00425         // ------------------------------------------------------------------------
00426         //                     Internal Rendering Access
00427         // All methods below here are normally only called by other OGRE classes
00428         // They can be called by library user if required
00429         // ------------------------------------------------------------------------
00430 
00431 
00435         virtual void _useLights(const LightList& lights, unsigned short limit) = 0;
00437         virtual void _setWorldMatrix(const Matrix4 &m) = 0;
00439         virtual void _setWorldMatrices(const Matrix4* m, unsigned short count);
00441         virtual void _setViewMatrix(const Matrix4 &m) = 0;
00443         virtual void _setProjectionMatrix(const Matrix4 &m) = 0;
00449         virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl);
00451         virtual void _disableTextureUnit(size_t texUnit);
00453         virtual void _disableTextureUnitsFrom(size_t texUnit);
00487         virtual void _setSurfaceParams(const ColourValue &ambient,
00488             const ColourValue &diffuse, const ColourValue &specular,
00489             const ColourValue &emissive, Real shininess,
00490             TrackVertexColourType tracking = TVC_NONE) = 0;
00507         virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0;
00508 
00518         virtual void _setTextureCoordSet(size_t unit, size_t index) = 0;
00519 
00527         virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 
00528             const Frustum* frustum = 0) = 0;
00529 
00536         virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0;
00537 
00544         virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
00545             FilterOptions magFilter, FilterOptions mipFilter);
00546 
00552         virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0;
00553 
00555         virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
00556 
00558         virtual void _setTextureAddressingMode(size_t unit, TextureUnitState::TextureAddressingMode tam) = 0;
00559 
00564         virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0;
00565 
00574         virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0;
00575 
00581         virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0;
00586         virtual void _beginFrame(void) = 0;
00587 
00588 
00592         virtual void _endFrame(void) = 0;
00600         virtual void _setViewport(Viewport *vp) = 0;
00602         virtual Viewport* _getViewport(void);
00603 
00615         virtual void _setCullingMode(CullingMode mode) = 0;
00616 
00617         virtual CullingMode _getCullingMode(void) const;
00618 
00632         virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
00633 
00638         virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0;
00643         virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0;
00651         virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
00659         virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
00672         virtual void _setDepthBias(ushort bias) = 0;
00684         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;
00685 
00686 
00688         virtual void _beginGeometryCount(void);
00690         virtual unsigned int _getFaceCount(void) const;
00692         virtual unsigned int _getVertexCount(void) const;
00693 
00702         virtual void convertColourValue(const ColourValue& colour, uint32* pDest) = 0;
00703 
00710         virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 
00711             Matrix4& dest, bool forGpuProgram = false) = 0;
00712 
00719         virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, 
00720             Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0;
00727         virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 
00728             Matrix4& dest, bool forGpuProgram = false) = 0;
00729 
00746         virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 
00747             bool forGpuProgram) = 0;
00748         
00750         virtual void _setRasterisationMode(SceneDetailLevel level) = 0;
00751 
00758         virtual void setStencilCheckEnabled(bool enabled) = 0;
00774         /*virtual bool hasHardwareStencil(void) = 0;*/
00775 
00811         virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 
00812             uint32 refValue = 0, uint32 mask = 0xFFFFFFFF, 
00813             StencilOperation stencilFailOp = SOP_KEEP, 
00814             StencilOperation depthFailOp = SOP_KEEP,
00815             StencilOperation passOp = SOP_KEEP, 
00816             bool twoSidedOperation = false) = 0;
00817 
00818 
00819 
00821         virtual void setVertexDeclaration(VertexDeclaration* decl) = 0;
00823         virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0;
00824 
00835         virtual void setNormaliseNormals(bool normalise) = 0;
00836 
00849         virtual void _render(const RenderOperation& op);
00850 
00852         const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; }
00853 
00858         virtual void bindGpuProgram(GpuProgram* prg) = 0;
00859 
00861         virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0;
00866         virtual void unbindGpuProgram(GpuProgramType gptype) = 0;
00867 
00870         virtual void setClipPlanes(const PlaneList& clipPlanes) = 0;
00871 
00873         virtual void _initRenderTargets(void);
00874 
00878         virtual void _notifyCameraRemoved(const Camera* cam);
00879 
00881         virtual void _updateAllRenderTargets(void);
00882 
00884         virtual void setClipPlane (ushort index, const Plane &p);
00886         virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0;
00888         virtual void enableClipPlane (ushort index, bool enable) = 0;
00889 
00892         virtual void setInvertVertexWinding(bool invert);
00904         virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, 
00905             size_t right = 800, size_t bottom = 600) = 0;
00906 
00914         virtual void clearFrameBuffer(unsigned int buffers, 
00915             const ColourValue& colour = ColourValue::Black, 
00916             Real depth = 1.0f, unsigned short stencil = 0) = 0;
00926         virtual Real getHorizontalTexelOffset(void) = 0;
00936         virtual Real getVerticalTexelOffset(void) = 0;
00937 
00946         virtual Real getMinimumDepthInputValue(void) = 0;
00955         virtual Real getMaximumDepthInputValue(void) = 0;
00956     protected:
00957 
00958 
00960         RenderTargetMap mRenderTargets;
00962         RenderTargetPriorityMap mPrioritisedRenderTargets;
00964         RenderTarget * mActiveRenderTarget;
00965 
00966         // Texture manager
00967         // A concrete class of this will be created and
00968         // made available under the TextureManager singleton,
00969         // managed by the RenderSystem
00970         TextureManager* mTextureManager;
00971 
00973         RenderSystemCapabilities* mCapabilities;
00974 
00975         // Active viewport (dest for future rendering operations)
00976         Viewport* mActiveViewport;
00977 
00978         CullingMode mCullingMode;
00979 
00980         bool mVSync;
00981         bool mWBuffer;
00982 
00983         size_t mFaceCount;
00984         size_t mVertexCount;
00985 
00987         Matrix4 mWorldMatrices[256];
00988 
00990         ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2];
00991 
00992         bool mInvertVertexWinding;
00993 
00994     };
00995 }
00996 
00997 #endif

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Sep 25 17:35:59 2005