TextureLoader.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //--------------------------------------------------------------------------------------
  2. // File: WICTextureLoader.h
  3. //
  4. // Function for loading a WIC image and creating a Direct3D 11 runtime texture for it
  5. // (auto-generating mipmaps if possible)
  6. //
  7. // Note: Assumes application has already called CoInitializeEx
  8. //
  9. // Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for
  10. // auto-gen mipmap support.
  11. //
  12. // Note these functions are useful for images created as simple 2D textures. For
  13. // more complex resources, DDSTextureLoader is an excellent light-weight runtime loader.
  14. // For a full-featured DDS file reader, writer, and texture processing pipeline see
  15. // the 'Texconv' sample and the 'DirectXTex' library.
  16. //
  17. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  18. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  19. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  20. // PARTICULAR PURPOSE.
  21. //
  22. // Copyright (c) Microsoft Corporation. All rights reserved.
  23. //
  24. // http://go.microsoft.com/fwlink/?LinkId=248926
  25. // http://go.microsoft.com/fwlink/?LinkId=248929
  26. //--------------------------------------------------------------------------------------
  27. #ifdef _MSC_VER
  28. #pragma once
  29. #endif
  30. #include <d3d11.h>
  31. #ifdef _MSC_VER
  32. #pragma warning(push)
  33. #pragma warning(disable : 4005)
  34. #endif // _MSC_VER
  35. #include <stdint.h>
  36. #ifdef _MSC_VER
  37. #pragma warning(pop)
  38. #endif // _MSC_VER
  39. HRESULT CreateWICTextureFromMemory(_In_ ID3D11Device* d3dDevice,
  40. _In_opt_ ID3D11DeviceContext* d3dContext,
  41. _In_bytecount_(wicDataSize) const uint8_t* wicData,
  42. _In_ size_t wicDataSize,
  43. _Out_opt_ ID3D11Resource** texture,
  44. _Out_opt_ ID3D11ShaderResourceView** textureView,
  45. _In_ size_t maxsize = 0
  46. );
  47. HRESULT CreateWICTextureFromFile(_In_ ID3D11Device* d3dDevice,
  48. _In_opt_ ID3D11DeviceContext* d3dContext,
  49. _In_z_ const wchar_t* szFileName,
  50. _Out_opt_ ID3D11Resource** texture,
  51. _Out_opt_ ID3D11ShaderResourceView** textureView,
  52. _In_ size_t maxsize = 0
  53. );