- Main Page
- Namespaces
- Classes
- Files
- Directories
- 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://www.ogre3d.org
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    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 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __RenderSystem_H_
    00030 #define __RenderSystem_H_
    00031
    00032 // Precompiler options
    00033 #include "OgrePrerequisites.h"
    00034
    00035 #include "OgreString.h"
    00036
    00037 #include "OgreTextureUnitState.h"
    00038 #include "OgreCommon.h"
    00039
    00040 #include "OgreRenderOperation.h"
    00041 #include "OgreRenderSystemCapabilities.h"
    00042 #include "OgreRenderTarget.h"
    00043 #include "OgreRenderTexture.h"
    00044 #include "OgreFrameListener.h"
    00045 #include "OgreConfigOptionMap.h"
    00046 #include "OgreGpuProgram.h"
    00047 #include "OgrePlane.h"
    00048 #include "OgreIteratorWrappers.h"
    00049
    00050 namespace Ogre
    00051 {
    00052     typedef std::map< String, RenderTarget * > RenderTargetMap;
    00053     typedef std::multimap<uchar, RenderTarget * > RenderTargetPriorityMap;
    00054
    00055     class TextureManager;
    00057     enum TexCoordCalcMethod
    00058     {
    00060         TEXCALC_NONE,
    00062         TEXCALC_ENVIRONMENT_MAP,
    00064         TEXCALC_ENVIRONMENT_MAP_PLANAR,
    00065         TEXCALC_ENVIRONMENT_MAP_REFLECTION,
    00066         TEXCALC_ENVIRONMENT_MAP_NORMAL,
    00068         TEXCALC_PROJECTIVE_TEXTURE
    00069     };
    00071     enum StencilOperation
    00072     {
    00074         SOP_KEEP,
    00076         SOP_ZERO,
    00078         SOP_REPLACE,
    00080         SOP_INCREMENT,
    00082         SOP_DECREMENT,
    00084         SOP_INCREMENT_WRAP,
    00086         SOP_DECREMENT_WRAP,
    00088         SOP_INVERT
    00089     };
    00090
    00114     class _OgreExport RenderSystem
    00115     {
    00116     public:
    00119         RenderSystem();
    00120
    00123         virtual ~RenderSystem();
    00124
    00127         virtual const String& getName(void) const = 0;
    00128
    00150         virtual ConfigOptionMap& getConfigOptions(void) = 0;
    00151
    00171         virtual void setConfigOption(const String &name, const String &value) = 0;
    00172
    00175         virtual HardwareOcclusionQuery* createHardwareOcclusionQuery(void) = 0;
    00176
    00179         virtual void destroyHardwareOcclusionQuery(HardwareOcclusionQuery *hq);
    00180
    00185         virtual String validateConfigOptions(void) = 0;
    00186
    00203         virtual RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
    00204
    00207         virtual void reinitialise(void) = 0;
    00208
    00211         virtual void shutdown(void);
    00212
    00213
    00216         virtual void setAmbientLight(float r, float g, float b) = 0;
    00217
    00220         virtual void setShadingType(ShadeOptions so) = 0;
    00221
    00227         virtual void setLightingEnabled(bool enabled) = 0;
    00228
    00235         void setWBufferEnabled(bool enabled);
    00236
    00239         bool getWBufferEnabled(void) const;
    00240
    00359         virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
    00360             bool fullScreen, const NameValuePairList *miscParams = 0) = 0;
    00361
    00388         RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height,
    00389             TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8,
    00390             const NameValuePairList *miscParams = 0 );
    00391
    00396         virtual MultiRenderTarget * createMultiRenderTarget(const String & name) = 0;
    00397
    00399         virtual void destroyRenderWindow(const String& name);
    00401         virtual void destroyRenderTexture(const String& name);
    00403         virtual void destroyRenderTarget(const String& name);
    00404
    00407         virtual void attachRenderTarget( RenderTarget &target );
    00411         virtual RenderTarget * getRenderTarget( const String &name );
    00417         virtual RenderTarget * detachRenderTarget( const String &name );
    00418
    00420         typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator;
    00421
    00423         virtual RenderTargetIterator getRenderTargetIterator(void) {
    00424             return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() );
    00425         }
    00428         virtual String getErrorDescription(long errorNumber) const = 0;
    00429
    00443         void setWaitForVerticalBlank(bool enabled);
    00444
    00447         bool getWaitForVerticalBlank(void) const;
    00448
    00449         // ------------------------------------------------------------------------
    00450         //                     Internal Rendering Access
    00451         // All methods below here are normally only called by other OGRE classes
    00452         // They can be called by library user if required
    00453         // ------------------------------------------------------------------------
    00454
    00455
    00459         virtual void _useLights(const LightList& lights, unsigned short limit) = 0;
    00461         virtual void _setWorldMatrix(const Matrix4 &m) = 0;
    00463         virtual void _setWorldMatrices(const Matrix4* m, unsigned short count);
    00465         virtual void _setViewMatrix(const Matrix4 &m) = 0;
    00467         virtual void _setProjectionMatrix(const Matrix4 &m) = 0;
    00473         virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl);
    00475         virtual void _disableTextureUnit(size_t texUnit);
    00477         virtual void _disableTextureUnitsFrom(size_t texUnit);
    00511         virtual void _setSurfaceParams(const ColourValue &ambient,
    00512             const ColourValue &diffuse, const ColourValue &specular,
    00513             const ColourValue &emissive, Real shininess,
    00514             TrackVertexColourType tracking = TVC_NONE) = 0;
    00515
    00521         virtual void _setPointSpritesEnabled(bool enabled) = 0;
    00522
    00533         virtual void _setPointParameters(Real size, bool attenuationEnabled,
    00534             Real constant, Real linear, Real quadratic, Real minSize, Real maxSize) = 0;
    00535
    00536
    00549         virtual void _setTexture(size_t unit, bool enabled,
    00550             const TexturePtr &texPtr) = 0;
    00564         virtual void _setTexture(size_t unit, bool enabled, const String &texname);
    00565
    00575         virtual void _setVertexTexture(size_t unit, const TexturePtr& tex);
    00576
    00586         virtual void _setTextureCoordSet(size_t unit, size_t index) = 0;
    00587
    00595         virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m,
    00596             const Frustum* frustum = 0) = 0;
    00597
    00604         virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0;
    00605
    00612         virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
    00613             FilterOptions magFilter, FilterOptions mipFilter);
    00614
    00620         virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0;
    00621
    00623         virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
    00624
    00626         virtual void _setTextureAddressingMode(size_t unit, const TextureUnitState::UVWAddressingMode& uvw) = 0;
    00627
    00629         virtual void _setTextureBorderColour(size_t unit, const ColourValue& colour) = 0;
    00630
    00639         virtual void _setTextureMipmapBias(size_t unit, float bias) = 0;
    00640
    00645         virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0;
    00646
    00655         virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0;
    00656
    00662         virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0;
    00667         virtual void _beginFrame(void) = 0;
    00668
    00669
    00673         virtual void _endFrame(void) = 0;
    00681         virtual void _setViewport(Viewport *vp) = 0;
    00683         virtual Viewport* _getViewport(void);
    00684
    00696         virtual void _setCullingMode(CullingMode mode) = 0;
    00697
    00698         virtual CullingMode _getCullingMode(void) const;
    00699
    00713         virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
    00714
    00719         virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0;
    00724         virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0;
    00732         virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
    00740         virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
    00763         virtual void _setDepthBias(float constantBias, float slopeScaleBias = 0.0f) = 0;
    00775         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;
    00776
    00777
    00779         virtual void _beginGeometryCount(void);
    00781         virtual unsigned int _getFaceCount(void) const;
    00783         virtual unsigned int _getBatchCount(void) const;
    00785         virtual unsigned int _getVertexCount(void) const;
    00786
    00795         virtual void convertColourValue(const ColourValue& colour, uint32* pDest);
    00799         virtual VertexElementType getColourVertexElementType(void) const = 0;
    00800
    00807         virtual void _convertProjectionMatrix(const Matrix4& matrix,
    00808             Matrix4& dest, bool forGpuProgram = false) = 0;
    00809
    00816         virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane,
    00817             Matrix4& dest, bool forGpuProgram = false) = 0;
    00818
    00825         virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top,
    00826             Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0;
    00833         virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane,
    00834             Matrix4& dest, bool forGpuProgram = false) = 0;
    00835
    00852         virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane,
    00853             bool forGpuProgram) = 0;
    00854
    00856         virtual void _setPolygonMode(PolygonMode level) = 0;
    00857
    00864         virtual void setStencilCheckEnabled(bool enabled) = 0;
    00880         /*virtual bool hasHardwareStencil(void) = 0;*/
    00881
    00917         virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS,
    00918             uint32 refValue = 0, uint32 mask = 0xFFFFFFFF,
    00919             StencilOperation stencilFailOp = SOP_KEEP,
    00920             StencilOperation depthFailOp = SOP_KEEP,
    00921             StencilOperation passOp = SOP_KEEP,
    00922             bool twoSidedOperation = false) = 0;
    00923
    00924
    00925
    00927         virtual void setVertexDeclaration(VertexDeclaration* decl) = 0;
    00929         virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0;
    00930
    00941         virtual void setNormaliseNormals(bool normalise) = 0;
    00942
    00955         virtual void _render(const RenderOperation& op);
    00956
    00958         const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; }
    00959
    00964         virtual void bindGpuProgram(GpuProgram* prg);
    00965
    00968         virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0;
    00971         virtual void bindGpuProgramPassIterationParameters(GpuProgramType gptype) = 0;
    00976         virtual void unbindGpuProgram(GpuProgramType gptype);
    00977
    00979         virtual bool isGpuProgramBound(GpuProgramType gptype);
    00980
    00983         virtual void setClipPlanes(const PlaneList& clipPlanes) = 0;
    00984
    00986         virtual void _initRenderTargets(void);
    00987
    00991         virtual void _notifyCameraRemoved(const Camera* cam);
    00992
    00994         virtual void _updateAllRenderTargets(void);
    00995
    00997         virtual void setClipPlane (ushort index, const Plane &p);
    00999         virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0;
    01001         virtual void enableClipPlane (ushort index, bool enable) = 0;
    01002
    01005         virtual void setInvertVertexWinding(bool invert);
    01017         virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0,
    01018             size_t right = 800, size_t bottom = 600) = 0;
    01019
    01027         virtual void clearFrameBuffer(unsigned int buffers,
    01028             const ColourValue& colour = ColourValue::Black,
    01029             Real depth = 1.0f, unsigned short stencil = 0) = 0;
    01039         virtual Real getHorizontalTexelOffset(void) = 0;
    01049         virtual Real getVerticalTexelOffset(void) = 0;
    01050
    01059         virtual Real getMinimumDepthInputValue(void) = 0;
    01068         virtual Real getMaximumDepthInputValue(void) = 0;
    01074         void setCurrentPassIterationCount(const size_t count) { mCurrentPassIterationCount = count; }
    01075
    01080         class _OgreExport Listener
    01081         {
    01082         public:
    01083             Listener() {}
    01084             virtual ~Listener() {}
    01085
    01091             virtual void eventOccurred(const String& eventName,
    01092                 const NameValuePairList* parameters = 0) = 0;
    01093         };
    01107         virtual void addListener(Listener* l);
    01110         virtual void removeListener(Listener* l);
    01111
    01116         virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; }
    01117
    01134         virtual void preExtraThreadsStarted() = 0;
    01135
    01136         /* Tell the rendersystem to perform any tasks it needs to directly
    01137             after other threads which might access the rendering API are registered.
    01138         @see RenderSystem::preExtraThreadsStarted
    01139         */
    01140         virtual void postExtraThreadsStarted() = 0;
    01141
    01154         virtual void registerThread() = 0;
    01155
    01159         virtual void unregisterThread() = 0;
    01160     protected:
    01161
    01162
    01164         RenderTargetMap mRenderTargets;
    01166         RenderTargetPriorityMap mPrioritisedRenderTargets;
    01168         RenderTarget * mActiveRenderTarget;
    01170         GpuProgramParametersSharedPtr mActiveVertexGpuProgramParameters;
    01171         GpuProgramParametersSharedPtr mActiveFragmentGpuProgramParameters;
    01172
    01173         // Texture manager
    01174         // A concrete class of this will be created and
    01175         // made available under the TextureManager singleton,
    01176         // managed by the RenderSystem
    01177         TextureManager* mTextureManager;
    01178
    01180         RenderSystemCapabilities* mCapabilities;
    01181
    01182         // Active viewport (dest for future rendering operations)
    01183         Viewport* mActiveViewport;
    01184
    01185         CullingMode mCullingMode;
    01186
    01187         bool mVSync;
    01188         bool mWBuffer;
    01189
    01190         size_t mBatchCount;
    01191         size_t mFaceCount;
    01192         size_t mVertexCount;
    01193
    01195         ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2];
    01196
    01197         bool mInvertVertexWinding;
    01198
    01200         size_t mDisabledTexUnitsFrom;
    01201
    01203         size_t mCurrentPassIterationCount;
    01204
    01209         bool updatePassIterationRenderState(void);
    01210
    01212         StringVector mEventNames;
    01213
    01215         virtual void fireEvent(const String& name, const NameValuePairList* params = 0);
    01216
    01217         typedef std::list<Listener*> ListenerList;
    01218         ListenerList mEventListeners;
    01219
    01220         typedef std::list<HardwareOcclusionQuery*> HardwareOcclusionQueryList;
    01221         HardwareOcclusionQueryList mHwOcclusionQueries;
    01222
    01223         bool mVertexProgramBound;
    01224         bool mFragmentProgramBound;
    01225
    01226
    01227
    01228     };
    01229 }
    01230
    01231 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Mon Jun 16 12:48:55 2008