1 /* 2 ----------------------------------------------------------------------------- 3 This source file is part of OGRE 4 (Object-oriented Graphics Rendering Engine) 5 For the latest info, see http://www.ogre3d.org/ 6 7 Copyright (c) 2000-2013 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 #ifndef __D3D9MAPPINGS_H__ 29 #define __D3D9MAPPINGS_H__ 30 31 #include "OgreD3D9Prerequisites.h" 32 #include "OgreCommon.h" 33 #include "OgreLight.h" 34 #include "OgreMaterial.h" 35 #include "OgreRenderSystem.h" 36 #include "OgreHardwareBuffer.h" 37 #include "OgreHardwareIndexBuffer.h" 38 39 namespace Ogre 40 { 41 class _OgreD3D9Export D3D9Mappings 42 { 43 public: 44 /// enum identifying D3D9 tex. types 45 enum eD3DTexType 46 { 47 /// standard texture 48 D3D_TEX_TYPE_NORMAL, 49 /// cube texture 50 D3D_TEX_TYPE_CUBE, 51 /// volume texture 52 D3D_TEX_TYPE_VOLUME, 53 /// just to have it... 54 D3D_TEX_TYPE_NONE 55 }; 56 57 /// enum identifying D3D9 filter usage type 58 enum eD3DFilterUsage 59 { 60 /// min filter 61 D3D_FUSAGE_MIN, 62 /// mag filter 63 D3D_FUSAGE_MAG, 64 /// mip filter 65 D3D_FUSAGE_MIP 66 }; 67 68 /// return a D3D9 equivalent for a Ogre ShadeOptions value 69 static DWORD get(ShadeOptions so); 70 /// return a D3D9 equivalent for a Ogre LightTypes value 71 static D3DLIGHTTYPE get(Ogre::Light::LightTypes lightType); 72 /// return a D3D9 equivalent for a Ogre TexCoordCalsMethod value 73 static DWORD get(TexCoordCalcMethod m, const D3DCAPS9& caps); 74 /// return a D3D9 equivalent for a Ogre TextureAddressingMode value 75 static D3DTEXTUREADDRESS get(TextureUnitState::TextureAddressingMode tam, const D3DCAPS9& devCaps); 76 /// return a D3D9 equivalent for a Ogre LayerBlendType value 77 static D3DTEXTURESTAGESTATETYPE get(LayerBlendType lbt); 78 /// return a D3D9 equivalent for a Ogre LayerBlendOperationEx value 79 static DWORD get(LayerBlendOperationEx lbo, const D3DCAPS9& devCaps); 80 /// return a D3D9 equivalent for a Ogre LayerBlendSource value 81 static DWORD get(LayerBlendSource lbs, bool perStageConstants); 82 /// return a D3D9 equivalent for a Ogre SceneBlendFactor value 83 static D3DBLEND get(SceneBlendFactor sbf); 84 /// return a D3D9 equivalent for a Ogre SceneBlendOperation value 85 static D3DBLENDOP get(SceneBlendOperation sbo); 86 /// return a D3D9 equivalent for a Ogre CompareFunction value 87 static DWORD get(CompareFunction cf); 88 /// return a D3D9 equivalent for a Ogre CillingMode value 89 static DWORD get(CullingMode cm, bool flip); 90 /// return a D3D9 equivalent for a Ogre FogMode value 91 static D3DFOGMODE get(FogMode fm); 92 /// return a D3D9 equivalent for a Ogre PolygonMode value 93 static D3DFILLMODE get(PolygonMode level); 94 /// return a D3D9 equivalent for a Ogre StencilOperation value 95 static DWORD get(StencilOperation op, bool invert = false); 96 /// return a D3D9 state type for Ogre FilterType value 97 static D3DSAMPLERSTATETYPE get(FilterType ft); 98 /// return a D3D9 filter option for Ogre FilterType & FilterOption value 99 static DWORD get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, eD3DTexType texType); 100 /// return the D3DtexType equivalent of a Ogre tex. type 101 static eD3DTexType get(TextureType ogreTexType); 102 /// return the combination of D3DUSAGE values for Ogre buffer usage 103 static DWORD get(HardwareBuffer::Usage usage); 104 /// Get lock options 105 static DWORD get(HardwareBuffer::LockOptions options, HardwareBuffer::Usage usage); 106 /// Get index type 107 static D3DFORMAT get(HardwareIndexBuffer::IndexType itype); 108 /// Get vertex data type 109 static D3DDECLTYPE get(VertexElementType vType); 110 /// Get vertex semantic 111 static D3DDECLUSAGE get(VertexElementSemantic sem); 112 // Convert matrix to D3D style 113 static D3DXMATRIX makeD3DXMatrix( const Matrix4& mat ); 114 // Convert matrix from D3D style 115 static Matrix4 convertD3DXMatrix( const D3DXMATRIX& mat ); 116 117 /// utility method, convert D3D9 pixel format to Ogre pixel format 118 static PixelFormat _getPF(D3DFORMAT d3dPF); 119 /// utility method, convert Ogre pixel format to D3D9 pixel format 120 static D3DFORMAT _getPF(PixelFormat ogrePF); 121 /// utility method, find closest Ogre pixel format that D3D9 can support 122 static PixelFormat _getClosestSupportedPF(PixelFormat ogrePF); 123 }; 124 } 125 #endif 126