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

OgreD3D7RenderSystem.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 © 2000-2002 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 __D3DRENDERSYSTEM_H__
00026 #define __D3DRENDERSYSTEM_H__
00027 
00028 // Precompiler options
00029 #include "OgreD3D7Prerequisites.h"
00030 #include "OgreString.h"
00031 
00032 // Include D3D and DirectDraw stuff
00033 #define D3D_OVERLOADS
00034 #include <ddraw.h>
00035 #include <d3d.h>
00036 
00037 #include "OgreRenderSystem.h"
00038 
00039 namespace Ogre {
00040 
00041     class DDDriverList;
00042     class DDDriver;
00043 
00047     class D3DRenderSystem : public RenderSystem
00048     {
00049     private:
00050 
00051 
00052         // Direct3D rendering device
00053         // Only created after top-level window created
00054         LPDIRECT3DDEVICE7 mlpD3DDevice;
00055         D3DDEVICEDESC7 mD3DDeviceDesc;
00056 
00057 
00058         // List of DD drivers installed (video cards)
00059         // Enumerates itself
00060         DDDriverList* mDriverList;
00061         // Currently active driver
00062         DDDriver* mActiveDDDriver;
00063 
00064         // Array of up to 8 lights, indexed as per API
00065         // Note that a null value indicates a free slot
00066         #define MAX_LIGHTS 8
00067         Light* mLights[MAX_LIGHTS];
00068 
00069 
00070 
00071 
00072         HINSTANCE mhInstance;
00073 
00074 
00075 
00076 
00077         // Private utilities
00078         DDDriverList* getDirectDrawDrivers(void);
00079         void refreshDDSettings(void);
00080 
00081         // Matrix conversion
00082         D3DMATRIX makeD3DMatrix(const Matrix4& mat);
00083         Matrix4 convertD3DMatrix(const D3DMATRIX& mat);
00084 
00085         void initConfigOptions(void);
00086         void initInputDevices(void);
00087         void processInputDevices(void);
00088         void setD3DLight(int index, Light* light);
00089 
00090         D3DCMPFUNC convertCompareFunction(CompareFunction func);
00091         D3DSTENCILOP convertStencilOp(StencilOperation op);
00092     public:
00093         // Default constructor / destructor
00094         D3DRenderSystem(HINSTANCE hInstance);
00095         ~D3DRenderSystem();
00096 
00097 
00098 
00099         // ----------------------------------
00100         // Overridden RenderSystem functions
00101         // ----------------------------------
00105         const String& getName(void) const;
00109         ConfigOptionMap& getConfigOptions(void);
00113         void setConfigOption(const String &name, const String &value);
00117         String validateConfigOptions(void);
00121         RenderWindow* initialise(bool autoCreateWindow);
00125         void reinitialise(void); // Used if settings changed mid-rendering
00129         void shutdown(void);
00130 
00134         void startRendering(void);
00138         void setAmbientLight(float r, float g, float b);
00142         void setShadingType(ShadeOptions so);
00146         void setTextureFiltering(TextureFilterOptions fo);
00150         void setLightingEnabled(bool enabled);
00154         RenderWindow* createRenderWindow(const String &name, int width, int height, int colourDepth,
00155             bool fullScreen, int left = 0, int top = 0, bool depthBuffer = true,
00156             RenderWindow* parentWindowHandle = 0);
00157 
00158         RenderTexture * createRenderTexture( const String & name, int width, int height );
00159 
00163         void destroyRenderWindow(RenderWindow* pWin);
00164 
00168         String getErrorDescription(long errorNumber);
00169 
00173         void convertColourValue(const ColourValue& colour, unsigned long* pDest);
00174 
00175         // -----------------------------
00176         // Low-level overridden members
00177         // -----------------------------
00181         void _addLight(Light *lt);
00185         void _removeLight(Light *lt);
00189         void _modifyLight(Light* lt);
00193         void _removeAllLights(void);
00197         void _pushRenderState(void);
00201         void _popRenderState(void);
00205         void _setWorldMatrix(const Matrix4 &m);
00209         void _setViewMatrix(const Matrix4 &m);
00213         void _setProjectionMatrix(const Matrix4 &m);
00217         void _setSurfaceParams(const ColourValue &ambient,
00218             const ColourValue &diffuse, const ColourValue &specular,
00219             const ColourValue &emissive, Real shininess);
00223         unsigned short _getNumTextureUnits(void);
00227         void _setTexture(int unit, bool enabled, const String &texname);
00231         void _setTextureCoordSet(int stage, int index);
00235         void _setTextureCoordCalculation(int stage, TexCoordCalcMethod m);
00239         void _setTextureBlendMode(int stage, const LayerBlendModeEx& bm);
00243         void _setTextureAddressingMode(int stage, Material::TextureLayer::TextureAddressingMode tam);
00247         void _setTextureMatrix(int stage, const Matrix4& xform);
00251         void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor);
00255         void _setAlphaRejectSettings(CompareFunction func, unsigned char value);
00259         void _setViewport(Viewport *vp);
00263         void _beginFrame(void);
00267         void _render(RenderOperation& op);
00271         void _endFrame(void);
00275         void _setCullingMode(CullingMode mode);
00279         void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL);
00283         void _setDepthBufferCheckEnabled(bool enabled = true);
00287         void _setDepthBufferWriteEnabled(bool enabled = true);
00291         void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
00295         void _setDepthBias(ushort bias);
00299         void _setFog(FogMode mode, ColourValue colour, Real density, Real start, Real end);
00303         void _makeProjectionMatrix(Real fovy, Real aspect, Real nearPlane, Real farPlane, Matrix4& dest);
00307         void _setRasterisationMode(SceneDetailLevel level);
00311         void setStencilCheckEnabled(bool enabled);
00315         bool hasHardwareStencil(void);
00319         ushort getStencilBufferBitDepth(void);
00323         void setStencilBufferFunction(CompareFunction func);
00327         void setStencilBufferReferenceValue(ulong refValue);
00331         void setStencilBufferMask(ulong mask);
00335         void setStencilBufferFailOperation(StencilOperation op);
00339         void setStencilBufferDepthFailOperation(StencilOperation op);
00343         void setStencilBufferPassOperation(StencilOperation op);
00344 
00345         // ----------------------------------
00346         // End Overridden members
00347         // ----------------------------------
00348 
00349 
00350 
00351     };
00352 }
00353 #endif
00354 

Copyright © 2002 by The OGRE Team