D3D9GraphicsImpl.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // Copyright (c) 2008-2015 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../../Math/Color.h"
  24. #include <d3d9.h>
  25. #include <SDL/include/SDL.h>
  26. namespace Atomic
  27. {
  28. /// %Graphics implementation. Holds API-specific objects.
  29. class ATOMIC_API GraphicsImpl
  30. {
  31. friend class Graphics;
  32. public:
  33. /// Construct.
  34. GraphicsImpl();
  35. /// Return Direct3D device.
  36. IDirect3DDevice9* GetDevice() const { return device_; }
  37. /// Return device capabilities.
  38. const D3DCAPS9& GetDeviceCaps() const { return deviceCaps_; }
  39. /// Return window.
  40. SDL_Window* GetWindow() const { return window_; }
  41. /// Return adapter identifier.
  42. const D3DADAPTER_IDENTIFIER9& GetAdapterIdentifier() const { return adapterIdentifier_; }
  43. /// Return whether a texture format and usage is supported.
  44. bool CheckFormatSupport(D3DFORMAT format, DWORD usage, D3DRESOURCETYPE type);
  45. private:
  46. /// SDL window.
  47. SDL_Window* window_;
  48. /// Direct3D interface.
  49. IDirect3D9* interface_;
  50. /// Direct3D device.
  51. IDirect3DDevice9* device_;
  52. /// Default color surface.
  53. IDirect3DSurface9* defaultColorSurface_;
  54. /// Default depth-stencil surface.
  55. IDirect3DSurface9* defaultDepthStencilSurface_;
  56. /// Frame query for flushing the GPU command queue.
  57. IDirect3DQuery9* frameQuery_;
  58. /// Adapter number.
  59. DWORD adapter_;
  60. /// Device type.
  61. D3DDEVTYPE deviceType_;
  62. /// Device capabilities.
  63. D3DCAPS9 deviceCaps_;
  64. /// Adapter identifier.
  65. D3DADAPTER_IDENTIFIER9 adapterIdentifier_;
  66. /// Direct3D presentation parameters.
  67. D3DPRESENT_PARAMETERS presentParams_;
  68. /// Texture min/mag filter modes in use.
  69. D3DTEXTUREFILTERTYPE minMagFilters_[MAX_TEXTURE_UNITS];
  70. /// Texture mip filter modes in use.
  71. D3DTEXTUREFILTERTYPE mipFilters_[MAX_TEXTURE_UNITS];
  72. /// Texture U coordinate addressing modes in use.
  73. D3DTEXTUREADDRESS uAddressModes_[MAX_TEXTURE_UNITS];
  74. /// Texture V coordinate addressing modes in use.
  75. D3DTEXTUREADDRESS vAddressModes_[MAX_TEXTURE_UNITS];
  76. /// Texture W coordinate addressing modes in use.
  77. D3DTEXTUREADDRESS wAddressModes_[MAX_TEXTURE_UNITS];
  78. /// Texture border colors in use.
  79. Color borderColors_[MAX_TEXTURE_UNITS];
  80. /// sRGB mode in use.
  81. bool sRGBModes_[MAX_TEXTURE_UNITS];
  82. /// sRGB write flag.
  83. bool sRGBWrite_;
  84. /// Color surfaces in use.
  85. IDirect3DSurface9* colorSurfaces_[MAX_RENDERTARGETS];
  86. /// Depth-stencil surface in use.
  87. IDirect3DSurface9* depthStencilSurface_;
  88. /// Blending enabled flag.
  89. DWORD blendEnable_;
  90. /// Source blend mode.
  91. D3DBLEND srcBlend_;
  92. /// Destination blend mode.
  93. D3DBLEND destBlend_;
  94. /// Blend operation.
  95. D3DBLENDOP blendOp_;
  96. };
  97. }