# 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
    00178         virtual HardwareOcclusionQuery* createHardwareOcclusionQuery(void) = 0;
    00179
    00182         virtual void destroyHardwareOcclusionQuery(HardwareOcclusionQuery *hq);
    00183
    00188         virtual String validateConfigOptions(void) = 0;
    00189
    00206         virtual RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
    00207
    00210         virtual void reinitialise(void) = 0;
    00211
    00214         virtual void shutdown(void);
    00215
    00216
    00219         virtual void setAmbientLight(float r, float g, float b) = 0;
    00220
    00223         virtual void setShadingType(ShadeOptions so) = 0;
    00224
    00230         virtual void setLightingEnabled(bool enabled) = 0;
    00231
    00238         void setWBufferEnabled(bool enabled);
    00239
    00242         bool getWBufferEnabled(void) const;
    00243
    00340         virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
    00341             bool fullScreen, const NameValuePairList *miscParams = 0) = 0;
    00342
    00377         virtual RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height,
    00378             TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8,
    00379             const NameValuePairList *miscParams = 0 ) = 0;
    00380
    00382         virtual void destroyRenderWindow(const String& name);
    00384         virtual void destroyRenderTexture(const String& name);
    00386         virtual void destroyRenderTarget(const String& name);
    00387
    00390         virtual void attachRenderTarget( RenderTarget &target );
    00394         virtual RenderTarget * getRenderTarget( const String &name );
    00400         virtual RenderTarget * detachRenderTarget( const String &name );
    00401
    00403         typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator;
    00404
    00406         virtual RenderTargetIterator getRenderTargetIterator(void) {
    00407             return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() );
    00408         }
    00411         virtual String getErrorDescription(long errorNumber) const = 0;
    00412
    00426         void setWaitForVerticalBlank(bool enabled);
    00427
    00430         bool getWaitForVerticalBlank(void) const;
    00431
    00432         // ------------------------------------------------------------------------
    00433         //                     Internal Rendering Access
    00434         // All methods below here are normally only called by other OGRE classes
    00435         // They can be called by library user if required
    00436         // ------------------------------------------------------------------------
    00437
    00438
    00442         virtual void _useLights(const LightList& lights, unsigned short limit) = 0;
    00444         virtual void _setWorldMatrix(const Matrix4 &m) = 0;
    00446         virtual void _setWorldMatrices(const Matrix4* m, unsigned short count);
    00448         virtual void _setViewMatrix(const Matrix4 &m) = 0;
    00450         virtual void _setProjectionMatrix(const Matrix4 &m) = 0;
    00456         virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl);
    00458         virtual void _disableTextureUnit(size_t texUnit);
    00460         virtual void _disableTextureUnitsFrom(size_t texUnit);
    00494         virtual void _setSurfaceParams(const ColourValue &ambient,
    00495             const ColourValue &diffuse, const ColourValue &specular,
    00496             const ColourValue &emissive, Real shininess,
    00497             TrackVertexColourType tracking = TVC_NONE) = 0;
    00514         virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0;
    00515
    00525         virtual void _setTextureCoordSet(size_t unit, size_t index) = 0;
    00526
    00534         virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m,
    00535             const Frustum* frustum = 0) = 0;
    00536
    00543         virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0;
    00544
    00551         virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
    00552             FilterOptions magFilter, FilterOptions mipFilter);
    00553
    00559         virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0;
    00560
    00562         virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
    00563
    00565         virtual void _setTextureAddressingMode(size_t unit, TextureUnitState::TextureAddressingMode tam) = 0;
    00566
    00571         virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0;
    00572
    00581         virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0;
    00582
    00588         virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0;
    00593         virtual void _beginFrame(void) = 0;
    00594
    00595
    00599         virtual void _endFrame(void) = 0;
    00607         virtual void _setViewport(Viewport *vp) = 0;
    00609         virtual Viewport* _getViewport(void);
    00610
    00622         virtual void _setCullingMode(CullingMode mode) = 0;
    00623
    00624         virtual CullingMode _getCullingMode(void) const;
    00625
    00639         virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
    00640
    00645         virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0;
    00650         virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0;
    00658         virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
    00666         virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
    00679         virtual void _setDepthBias(ushort bias) = 0;
    00691         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;
    00692
    00693
    00695         virtual void _beginGeometryCount(void);
    00697         virtual unsigned int _getFaceCount(void) const;
    00699         virtual unsigned int _getVertexCount(void) const;
    00700
    00709         virtual void convertColourValue(const ColourValue& colour, uint32* pDest) = 0;
    00710
    00717         virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane,
    00718             Matrix4& dest, bool forGpuProgram = false) = 0;
    00719
    00726         virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top,
    00727             Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0;
    00734         virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane,
    00735             Matrix4& dest, bool forGpuProgram = false) = 0;
    00736
    00753         virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane,
    00754             bool forGpuProgram) = 0;
    00755
    00757         virtual void _setRasterisationMode(SceneDetailLevel level) = 0;
    00758
    00765         virtual void setStencilCheckEnabled(bool enabled) = 0;
    00781         /*virtual bool hasHardwareStencil(void) = 0;*/
    00782
    00818         virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS,
    00819             uint32 refValue = 0, uint32 mask = 0xFFFFFFFF,
    00820             StencilOperation stencilFailOp = SOP_KEEP,
    00821             StencilOperation depthFailOp = SOP_KEEP,
    00822             StencilOperation passOp = SOP_KEEP,
    00823             bool twoSidedOperation = false) = 0;
    00824
    00825
    00826
    00828         virtual void setVertexDeclaration(VertexDeclaration* decl) = 0;
    00830         virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0;
    00831
    00842         virtual void setNormaliseNormals(bool normalise) = 0;
    00843
    00856         virtual void _render(const RenderOperation& op);
    00857
    00859         const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; }
    00860
    00865         virtual void bindGpuProgram(GpuProgram* prg) = 0;
    00866
    00868         virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0;
    00873         virtual void unbindGpuProgram(GpuProgramType gptype) = 0;
    00874
    00877         virtual void setClipPlanes(const PlaneList& clipPlanes) = 0;
    00878
    00880         virtual void _initRenderTargets(void);
    00881
    00885         virtual void _notifyCameraRemoved(const Camera* cam);
    00886
    00888         virtual void _updateAllRenderTargets(void);
    00889
    00891         virtual void setClipPlane (ushort index, const Plane &p);
    00893         virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0;
    00895         virtual void enableClipPlane (ushort index, bool enable) = 0;
    00896
    00899         virtual void setInvertVertexWinding(bool invert);
    00911         virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0,
    00912             size_t right = 800, size_t bottom = 600) = 0;
    00913
    00921         virtual void clearFrameBuffer(unsigned int buffers,
    00922             const ColourValue& colour = ColourValue::Black,
    00923             Real depth = 1.0f, unsigned short stencil = 0) = 0;
    00933         virtual Real getHorizontalTexelOffset(void) = 0;
    00943         virtual Real getVerticalTexelOffset(void) = 0;
    00944
    00953         virtual Real getMinimumDepthInputValue(void) = 0;
    00962         virtual Real getMaximumDepthInputValue(void) = 0;
    00963
    00968         class _OgreExport Listener
    00969         {
    00970         public:
    00971             Listener() {}
    00972             virtual ~Listener() {}
    00973
    00979             virtual void eventOccurred(const String& eventName,
    00980                 const NameValuePairList* parameters = 0) = 0;
    00981         };
    00995         virtual void addListener(Listener* l);
    00998         virtual void removeListener(Listener* l);
    00999
    01004         virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; }
    01005     protected:
    01006
    01007
    01009         RenderTargetMap mRenderTargets;
    01011         RenderTargetPriorityMap mPrioritisedRenderTargets;
    01013         RenderTarget * mActiveRenderTarget;
    01014
    01015         // Texture manager
    01016         // A concrete class of this will be created and
    01017         // made available under the TextureManager singleton,
    01018         // managed by the RenderSystem
    01019         TextureManager* mTextureManager;
    01020
    01022         RenderSystemCapabilities* mCapabilities;
    01023
    01024         // Active viewport (dest for future rendering operations)
    01025         Viewport* mActiveViewport;
    01026
    01027         CullingMode mCullingMode;
    01028
    01029         bool mVSync;
    01030         bool mWBuffer;
    01031
    01032         size_t mFaceCount;
    01033         size_t mVertexCount;
    01034
    01036         Matrix4 mWorldMatrices[256];
    01037
    01039         ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2];
    01040
    01041         bool mInvertVertexWinding;
    01042
    01044         StringVector mEventNames;
    01045
    01047         virtual void fireEvent(const String& name, const NameValuePairList* params = 0);
    01048
    01049         typedef std::list<Listener*> ListenerList;
    01050         ListenerList mEventListeners;
    01051
    01052         typedef std::list<HardwareOcclusionQuery*> HardwareOcclusionQueryList;
    01053         HardwareOcclusionQueryList mHwOcclusionQueries;
    01054
    01055
    01056     };
    01057 }
    01058
    01059 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:51 2006