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 
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 
00175         virtual HardwareOcclusionQuery* createHardwareOcclusionQuery() = 0;
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 
00321         virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height, 
00322             bool fullScreen, const NameValuePairList *miscParams = 0) = 0;
00323 
00358         virtual RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height,
00359             TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8, 
00360             const NameValuePairList *miscParams = 0 ) = 0; 
00361 
00363         virtual void destroyRenderWindow(const String& name);
00365         virtual void destroyRenderTexture(const String& name);
00367         virtual void destroyRenderTarget(const String& name);
00368 
00371         virtual void attachRenderTarget( RenderTarget &target );
00375         virtual RenderTarget * getRenderTarget( const String &name );
00381         virtual RenderTarget * detachRenderTarget( const String &name );
00382 
00385         virtual String getErrorDescription(long errorNumber) const = 0;
00386 
00400         void setWaitForVerticalBlank(bool enabled);
00401 
00404         bool getWaitForVerticalBlank(void) const;
00405 
00406         // ------------------------------------------------------------------------
00407         //                     Internal Rendering Access
00408         // All methods below here are normally only called by other OGRE classes
00409         // They can be called by library user if required
00410         // ------------------------------------------------------------------------
00411 
00412 
00416         virtual void _useLights(const LightList& lights, unsigned short limit) = 0;
00418         virtual void _setWorldMatrix(const Matrix4 &m) = 0;
00420         virtual void _setWorldMatrices(const Matrix4* m, unsigned short count);
00422         virtual void _setViewMatrix(const Matrix4 &m) = 0;
00424         virtual void _setProjectionMatrix(const Matrix4 &m) = 0;
00430         virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl);
00432         virtual void _disableTextureUnit(size_t texUnit);
00434         virtual void _disableTextureUnitsFrom(size_t texUnit);
00468         virtual void _setSurfaceParams(const ColourValue &ambient,
00469             const ColourValue &diffuse, const ColourValue &specular,
00470             const ColourValue &emissive, Real shininess,
00471             TrackVertexColourType tracking = TVC_NONE) = 0;
00488         virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0;
00489 
00499         virtual void _setTextureCoordSet(size_t unit, size_t index) = 0;
00500 
00508         virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 
00509             const Frustum* frustum = 0) = 0;
00510 
00517         virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0;
00518 
00525         virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
00526             FilterOptions magFilter, FilterOptions mipFilter);
00527 
00533         virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0;
00534 
00536         virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
00537 
00539         virtual void _setTextureAddressingMode(size_t unit, TextureUnitState::TextureAddressingMode tam) = 0;
00540 
00545         virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0;
00546 
00555         virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0;
00556 
00562         virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0;
00567         virtual void _beginFrame(void) = 0;
00568 
00569 
00573         virtual void _endFrame(void) = 0;
00581         virtual void _setViewport(Viewport *vp) = 0;
00583         virtual Viewport* _getViewport(void);
00584 
00596         virtual void _setCullingMode(CullingMode mode) = 0;
00597 
00598         virtual CullingMode _getCullingMode(void) const;
00599 
00613         virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
00614 
00619         virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0;
00624         virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0;
00632         virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
00640         virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
00653         virtual void _setDepthBias(ushort bias) = 0;
00665         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;
00666 
00667 
00669         virtual void _beginGeometryCount(void);
00671         virtual unsigned int _getFaceCount(void) const;
00673         virtual unsigned int _getVertexCount(void) const;
00674 
00683         virtual void convertColourValue(const ColourValue& colour, uint32* pDest) = 0;
00684 
00691         virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 
00692             Matrix4& dest, bool forGpuProgram = false) = 0;
00693 
00700         virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, 
00701             Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0;
00708         virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 
00709             Matrix4& dest, bool forGpuProgram = false) = 0;
00710 
00727         virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 
00728             bool forGpuProgram) = 0;
00729         
00731         virtual void _setRasterisationMode(SceneDetailLevel level) = 0;
00732 
00739         virtual void setStencilCheckEnabled(bool enabled) = 0;
00755         /*virtual bool hasHardwareStencil(void) = 0;*/
00756 
00792         virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 
00793             uint32 refValue = 0, uint32 mask = 0xFFFFFFFF, 
00794             StencilOperation stencilFailOp = SOP_KEEP, 
00795             StencilOperation depthFailOp = SOP_KEEP,
00796             StencilOperation passOp = SOP_KEEP, 
00797             bool twoSidedOperation = false) = 0;
00798 
00799 
00800 
00802         virtual void setVertexDeclaration(VertexDeclaration* decl) = 0;
00804         virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0;
00805 
00816         virtual void setNormaliseNormals(bool normalise) = 0;
00817 
00830         virtual void _render(const RenderOperation& op);
00831 
00833         const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; }
00834 
00839         virtual void bindGpuProgram(GpuProgram* prg) = 0;
00840 
00842         virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0;
00847         virtual void unbindGpuProgram(GpuProgramType gptype) = 0;
00848 
00851         virtual void setClipPlanes(const PlaneList& clipPlanes) = 0;
00852 
00854         virtual void _initRenderTargets(void);
00855 
00859         virtual void _notifyCameraRemoved(const Camera* cam);
00860 
00862         virtual void _updateAllRenderTargets(void);
00863 
00865         virtual void setClipPlane (ushort index, const Plane &p);
00867         virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0;
00869         virtual void enableClipPlane (ushort index, bool enable) = 0;
00870 
00873         virtual void setInvertVertexWinding(bool invert);
00885         virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, 
00886             size_t right = 800, size_t bottom = 600) = 0;
00887 
00895         virtual void clearFrameBuffer(unsigned int buffers, 
00896             const ColourValue& colour = ColourValue::Black, 
00897             Real depth = 1.0f, unsigned short stencil = 0) = 0;
00907         virtual Real getHorizontalTexelOffset(void) = 0;
00917         virtual Real getVerticalTexelOffset(void) = 0;
00918 
00927         virtual Real getMinimumDepthInputValue(void) = 0;
00936         virtual Real getMaximumDepthInputValue(void) = 0;
00937     protected:
00938 
00939 
00941         RenderTargetMap mRenderTargets;
00943         RenderTargetPriorityMap mPrioritisedRenderTargets;
00945         RenderTarget * mActiveRenderTarget;
00946 
00947         // Texture manager
00948         // A concrete class of this will be created and
00949         // made available under the TextureManager singleton,
00950         // managed by the RenderSystem
00951         TextureManager* mTextureManager;
00952 
00954         RenderSystemCapabilities* mCapabilities;
00955 
00956         // Active viewport (dest for future rendering operations)
00957         Viewport* mActiveViewport;
00958 
00959         CullingMode mCullingMode;
00960 
00961         bool mVSync;
00962         bool mWBuffer;
00963 
00964         size_t mFaceCount;
00965         size_t mVertexCount;
00966 
00968         Matrix4 mWorldMatrices[256];
00969 
00971         ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2];
00972 
00973         bool mInvertVertexWinding;
00974 
00975     };
00976 }
00977 
00978 #endif

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Apr 10 23:21:21 2005