D3D9GraphicsImpl.h 3.7 KB

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