BsD3D9Mappings.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsD3D9Prerequisites.h"
  5. #include "BsRenderAPI.h"
  6. #include "BsHardwareBuffer.h"
  7. #include "BsIndexBuffer.h"
  8. namespace BansheeEngine
  9. {
  10. /** @addtogroup D3D9
  11. * @{
  12. */
  13. /** Provides helper methods for mapping between engine and DirectX 9 types. */
  14. class BS_D3D9_EXPORT D3D9Mappings
  15. {
  16. public:
  17. /** DirectX 9 texture types. */
  18. enum D3DTexType
  19. {
  20. D3D_TEX_TYPE_NORMAL,
  21. D3D_TEX_TYPE_CUBE,
  22. D3D_TEX_TYPE_VOLUME,
  23. D3D_TEX_TYPE_NONE
  24. };
  25. /** Returns DirectX 9 texture addressing mode. Returns exact mode if supported, or nearest available if not. */
  26. static D3DTEXTUREADDRESS get(TextureAddressingMode tam, const D3DCAPS9& devCaps);
  27. /** Returns DirectX 9 blend factor. */
  28. static D3DBLEND get(BlendFactor sbf);
  29. /** Returns DirectX 9 blend operation. */
  30. static D3DBLENDOP get(BlendOperation sbo);
  31. /** Return DirectX 9 compare function. */
  32. static DWORD get(CompareFunction cf);
  33. /** Returns DirectX 9 culling mode. Optionally flip the mode so that engine CCW is DX9 CW and reverse. */
  34. static DWORD get(CullingMode cm, bool flip);
  35. /** Return DirectX 9 fill mode depending on provided polygon mode. */
  36. static D3DFILLMODE get(PolygonMode level);
  37. /** Return DirectX 9 stencil operation and optionally invert it (greater than becomes less than, etc.). */
  38. static DWORD get(StencilOperation op, bool invert = false);
  39. /** Returns DirectX 9 sampler state based on provided filter type. */
  40. static D3DSAMPLERSTATETYPE get(FilterType ft);
  41. /**
  42. * Returns a DirectX 9 texture filter type based on provided filter type, options and texture type. If wanted
  43. * filter type is not available closest type will be returned.
  44. */
  45. static DWORD get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, D3DTexType texType);
  46. /** Returns DirectX 9 texture type. */
  47. static D3DTexType get(TextureType textype);
  48. /** Return DirectX 9 buffer usage. */
  49. static DWORD get(GpuBufferUsage usage);
  50. /** Returns DirectX 9 lock options, constrained by the provided usage. */
  51. static DWORD get(GpuLockOptions options, GpuBufferUsage usage);
  52. /** Returns DirectX 9 index buffer type. */
  53. static D3DFORMAT get(IndexType itype);
  54. /** Returns DirectX 9 vertex element type. */
  55. static D3DDECLTYPE get(VertexElementType vType);
  56. /** Returns DirectX9 vertex element semantic. */
  57. static D3DDECLUSAGE get(VertexElementSemantic sem);
  58. /** Converts DirectX9 vertex element semantic to engine vertex element semantic. */
  59. static VertexElementSemantic get(D3DDECLUSAGE sem);
  60. /** Converts a matrix to one usable by DirectX 9 API. */
  61. static D3DXMATRIX makeD3DXMatrix(const Matrix4& mat);
  62. /** Converts matrix returned by DirectX 9 API to engine matrix. */
  63. static Matrix4 convertD3DXMatrix(const D3DXMATRIX& mat);
  64. /** Converts DirectX 9 pixel format to engine pixel format. */
  65. static PixelFormat _getPF(D3DFORMAT d3dPF);
  66. /** Converts engine pixel format to DirectX 9 pixel format. */
  67. static D3DFORMAT _getPF(PixelFormat pf);
  68. /** Returns closest pixel format supported by DirectX 9. */
  69. static PixelFormat _getClosestSupportedPF(PixelFormat pf);
  70. /** Returns closest color render target pixel format supported by DirectX 9. */
  71. static PixelFormat _getClosestSupportedRenderTargetPF(PixelFormat pf);
  72. /** Returns closest depth/stencil format supported by DirectX 9. */
  73. static PixelFormat _getClosestSupportedDepthStencilPF(PixelFormat pf);
  74. };
  75. /** @} */
  76. }