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-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __D3D9MAPPINGS_H__
|
---|
26 | #define __D3D9MAPPINGS_H__
|
---|
27 |
|
---|
28 | #include "OgreD3D9Prerequisites.h"
|
---|
29 | #include "OgreCommon.h"
|
---|
30 | #include "OgreLight.h"
|
---|
31 | #include "OgreMaterial.h"
|
---|
32 | #include "OgreRenderSystem.h"
|
---|
33 | #include "OgreHardwareBuffer.h"
|
---|
34 | #include "OgreHardwareIndexBuffer.h"
|
---|
35 |
|
---|
36 | #include "OgreNoMemoryMacros.h"
|
---|
37 | #include <d3d9.h>
|
---|
38 | #include <d3dx9.h>
|
---|
39 | #include <dxerr9.h>
|
---|
40 | #include "OgreMemoryMacros.h"
|
---|
41 |
|
---|
42 | namespace Ogre
|
---|
43 | {
|
---|
44 | class D3D9Mappings
|
---|
45 | {
|
---|
46 | public:
|
---|
47 | /// enum identifying D3D9 tex. types
|
---|
48 | enum eD3DTexType
|
---|
49 | {
|
---|
50 | /// standard texture
|
---|
51 | D3D_TEX_TYPE_NORMAL,
|
---|
52 | /// cube texture
|
---|
53 | D3D_TEX_TYPE_CUBE,
|
---|
54 | /// volume texture
|
---|
55 | D3D_TEX_TYPE_VOLUME,
|
---|
56 | /// just to have it...
|
---|
57 | D3D_TEX_TYPE_NONE
|
---|
58 | };
|
---|
59 |
|
---|
60 | /// enum identifying D3D9 filter usage type
|
---|
61 | enum eD3DFilterUsage
|
---|
62 | {
|
---|
63 | /// min filter
|
---|
64 | D3D_FUSAGE_MIN,
|
---|
65 | /// mag filter
|
---|
66 | D3D_FUSAGE_MAG,
|
---|
67 | /// mip filter
|
---|
68 | D3D_FUSAGE_MIP
|
---|
69 | };
|
---|
70 |
|
---|
71 | /// return a D3D9 equivalent for a Ogre ShadeOptions value
|
---|
72 | static DWORD get(ShadeOptions so);
|
---|
73 | /// return a D3D9 equivalent for a Ogre LightTypes value
|
---|
74 | static D3DLIGHTTYPE get(Ogre::Light::LightTypes lightType);
|
---|
75 | /// return a D3D9 equivalent for a Ogre TexCoordCalsMethod value
|
---|
76 | static DWORD get(TexCoordCalcMethod m, const D3DCAPS9& caps);
|
---|
77 | /// return a D3D9 equivalent for a Ogre TextureAddressingMode value
|
---|
78 | static D3DTEXTUREADDRESS get(TextureUnitState::TextureAddressingMode tam);
|
---|
79 | /// return a D3D9 equivalent for a Ogre LayerBlendType value
|
---|
80 | static D3DTEXTURESTAGESTATETYPE get(LayerBlendType lbt);
|
---|
81 | /// return a D3D9 equivalent for a Ogre LayerBlendOperationEx value
|
---|
82 | static DWORD get(LayerBlendOperationEx lbo, const D3DCAPS9& devCaps);
|
---|
83 | /// return a D3D9 equivalent for a Ogre LayerBlendSource value
|
---|
84 | static DWORD get(LayerBlendSource lbs);
|
---|
85 | /// return a D3D9 equivalent for a Ogre SceneBlendFactor value
|
---|
86 | static D3DBLEND get(SceneBlendFactor sbf);
|
---|
87 | #ifdef GAMETOOLS_ILLUMINATION_MODULE
|
---|
88 | static D3DBLENDOP get(SceneBlendOperation op)
|
---|
89 | {
|
---|
90 | switch( op )
|
---|
91 | {
|
---|
92 | case SBOP_ADD:
|
---|
93 | return D3DBLENDOP_ADD;
|
---|
94 | case SBOP_SUBTRACT:
|
---|
95 | return D3DBLENDOP_SUBTRACT;
|
---|
96 | case SBOP_REVSUBTRACT:
|
---|
97 | return D3DBLENDOP_REVSUBTRACT;
|
---|
98 | case SBOP_MIN:
|
---|
99 | return D3DBLENDOP_MIN;
|
---|
100 | case SBOP_MAX:
|
---|
101 | return D3DBLENDOP_MAX;
|
---|
102 | }
|
---|
103 | }
|
---|
104 | #endif
|
---|
105 | /// return a D3D9 equivalent for a Ogre CompareFunction value
|
---|
106 | static DWORD get(CompareFunction cf);
|
---|
107 | /// return a D3D9 equivalent for a Ogre CillingMode value
|
---|
108 | static DWORD get(CullingMode cm, bool flip);
|
---|
109 | /// return a D3D9 equivalent for a Ogre FogMode value
|
---|
110 | static D3DFOGMODE get(FogMode fm);
|
---|
111 | /// return a D3D9 equivalent for a Ogre PolygonMode value
|
---|
112 | static D3DFILLMODE get(PolygonMode level);
|
---|
113 | /// return a D3D9 equivalent for a Ogre StencilOperation value
|
---|
114 | static DWORD get(StencilOperation op, bool invert = false);
|
---|
115 | /// return a D3D9 state type for Ogre FilterType value
|
---|
116 | static D3DSAMPLERSTATETYPE get(FilterType ft);
|
---|
117 | /// return a D3D9 filter option for Ogre FilterType & FilterOption value
|
---|
118 | static DWORD get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, eD3DTexType texType);
|
---|
119 | /// return the D3DtexType equivalent of a Ogre tex. type
|
---|
120 | static eD3DTexType get(TextureType ogreTexType);
|
---|
121 | /// return the combination of D3DUSAGE values for Ogre buffer usage
|
---|
122 | static DWORD get(HardwareBuffer::Usage usage);
|
---|
123 | /// Get lock options
|
---|
124 | static DWORD get(HardwareBuffer::LockOptions options, HardwareBuffer::Usage usage);
|
---|
125 | /// Get index type
|
---|
126 | static D3DFORMAT get(HardwareIndexBuffer::IndexType itype);
|
---|
127 | /// Get vertex data type
|
---|
128 | static D3DDECLTYPE get(VertexElementType vType);
|
---|
129 | /// Get vertex semantic
|
---|
130 | static D3DDECLUSAGE get(VertexElementSemantic sem);
|
---|
131 | // Convert matrix to D3D style
|
---|
132 | static D3DXMATRIX makeD3DXMatrix( const Matrix4& mat );
|
---|
133 | // Convert matrix from D3D style
|
---|
134 | static Matrix4 D3D9Mappings::convertD3DXMatrix( const D3DXMATRIX& mat );
|
---|
135 |
|
---|
136 | /// utility method, convert D3D9 pixel format to Ogre pixel format
|
---|
137 | static PixelFormat _getPF(D3DFORMAT d3dPF);
|
---|
138 | /// utility method, convert Ogre pixel format to D3D9 pixel format
|
---|
139 | static D3DFORMAT _getPF(PixelFormat ogrePF);
|
---|
140 | /// utility method, find closest Ogre pixel format that D3D9 can support
|
---|
141 | static PixelFormat _getClosestSupportedPF(PixelFormat ogrePF);
|
---|
142 | };
|
---|
143 | }
|
---|
144 | #endif
|
---|