D3DTexture.h
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:3k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. // Copyright (C) 1998-1999 DXGuide.  All Rights Reserved.
  2. // File: D3DTexture.h
  3. #ifndef _D3DTEXTURE__H
  4. #define _D3DTEXTURE__H
  5. #if _MSC_VER >= 1000
  6. #pragma once
  7. #endif // _MSC_VER >= 1000
  8. #pragma warning(disable: 4201)
  9. #include <d3d.h>
  10. #pragma warning(default: 4201)
  11. class CD3DDevice;
  12. class CDDSurface;
  13. class CPackFileManager;
  14. class CDIB;
  15. class CDDPalette;
  16. class CD3DTexture
  17. {
  18. // friend class CDirectShow; // m_lpD3DTexture
  19. public:
  20. // Texture creation and deletion functions
  21. enum D3DTEXTURE_FLAGS
  22. {
  23. D3DTEXTURE_TRANSPARENTWHITE = 0x00000001L,
  24. D3DTEXTURE_TRANSPARENTBLACK = 0x00000002L,
  25. D3DTEXTURE_32BITSPERPIXEL = 0x00000004L,
  26. };
  27. enum BUMPMAPFORMAT
  28. {
  29. BUMPMAP_NONE,
  30. BUMPMAP_U5V5L6,
  31. BUMPMAP_U8V8L8,
  32. BUMPMAP_U8V8
  33. };
  34. public:
  35. CD3DTexture();
  36. virtual ~CD3DTexture();
  37. public:
  38. bool Create(CD3DDevice*  pD3DDevice,
  39. LPCTSTR  lpszFileName,
  40. CPackFileManager*  pPackFileManager/* = NULL*/,
  41. DWORD  dwStage = 0,
  42. DWORD  dwFlags = 0);
  43. bool CreateDDSTexture(CD3DDevice*  pD3DDevice,
  44. LPCTSTR  lpszFileName,
  45. CPackFileManager*  pPackFileManager/* = NULL*/);
  46. bool CreateTargaTexture(CD3DDevice*  pD3DDevice,
  47. LPCTSTR  lpszFileName,
  48. CPackFileManager*  pPackFileManager/* = NULL*/,
  49. DWORD  dwStage = 0,
  50. DWORD  dwFlags = 0);
  51. bool CreateDynamicTexture(CD3DDevice*  pD3DDevice,
  52. DWORD  dwWidth, DWORD  dwHeight, DWORD  dwBPP);
  53. bool CreateBumpMapTexture(CD3DDevice*  pD3DDevice,
  54. LPCTSTR  lpszFileName, CPackFileManager*  pPackFileManager,
  55. BUMPMAPFORMAT  format, DWORD  dwStage = 0);
  56. bool CreateInvAlphaTexFromTex(CD3DTexture*  pSrcTexture);
  57. bool SetAsCurrent(void);
  58. void SetStage(DWORD  dwStage);
  59. bool IsMipTexture(void) const; // does texture have mipmaps?
  60. bool IsPremultipliedAlpha(void) const;
  61. protected:
  62. bool GetD3DTextureInterface(void);
  63. bool CopyBitmapToSurface(DWORD  dwFlags);
  64. bool CopyRGBADataToSurface(DWORD  dwWidth,
  65. DWORD  dwHeight, DWORD*  pdwRGBAData);
  66. bool BltToUncompressedSurface(
  67. DDSURFACEDESC2*  pDDSD, const DDPIXELFORMAT*  pDDPF);
  68. bool SetupTexture(DWORD  dwWidth, DWORD  dwHeight,
  69. DWORD  dwBPP, DWORD  dwAlphaBit, bool  bDynamic,
  70. BUMPMAPFORMAT  format);
  71. bool CreateTempSurface(DDSURFACEDESC2&  ddsd,
  72. DWORD  dwWidth, DWORD  dwHeight,
  73. CDDSurface&  ddsTempSurface);
  74. public:
  75. CDDSurface* m_pSurface;
  76. protected:
  77. CDDPalette* m_pPalette;
  78. CDIB* m_pDIB;
  79. CD3DDevice* m_pD3DDevice;
  80. DWORD m_dwStage; // Texture stage (for multi-textures).
  81. DWORD m_dwMipmapCount;
  82. bool m_bPremultipliedAlpha;
  83. };
  84. #include "D3DTexture.inl"
  85. #endif // _D3DTEXTURE__H