dxtlib.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef __DXTLIB_H__
  2. #define __DXTLIB_H__
  3. /*********************************************************************NVMH2****
  4. Path: C:\Dev\devrel\Nv_sdk_4\Dx8_private\PhotoShop\dxtlib
  5. File: dxtlib.h
  6. Copyright (C) 1999, 2000 NVIDIA Corporation
  7. This file is provided without support, instruction, or implied warranty of any
  8. kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is
  9. not liable under any circumstances for any damages or loss whatsoever arising
  10. from the use or inability to use this file or items derived from it.
  11. Comments:
  12. ******************************************************************************/
  13. typedef HRESULT(*MIPcallback) (void *data, int miplevel, DWORD size);
  14. // call back
  15. // pointer to data
  16. // mip level
  17. // size of chunk
  18. /*
  19. Compresses an image with a user supplied callback with the data for each MIP level created
  20. Only supports input of RGB 24 or ARGB 32 bpp
  21. */
  22. HRESULT nvDXTcompress(unsigned char *raw_data, // pointer to data (24 or 32 bit)
  23. unsigned long w, // width in texels
  24. unsigned long h, // height in texels
  25. DWORD pitch, DWORD TextureFormat, // list below
  26. bool bGenMipMaps, // auto gen MIP maps
  27. bool bDither, DWORD depth, // 3 or 4
  28. MIPcallback callback = 0); // callback for generated levels
  29. // if callback is == 0 (or not specified), then WriteDTXnFile is called with all file info
  30. //
  31. // You must write the routines (or provide stubs)
  32. // void WriteDTXnFile(count, buffer);
  33. // void ReadDTXnFile(count, buffer);
  34. //
  35. //
  36. void WriteDTXnFile(DWORD count, void *buffer);
  37. void ReadDTXnFile(DWORD count, void *buffer);
  38. // TextureFormat
  39. #define TF_DXT1 10
  40. #define TF_DXT1_1BitAlpha 11
  41. #define TF_DXT3 12
  42. #define TF_DXT5 13
  43. #define TF_RGB4444 14
  44. #define TF_RGB1555 15
  45. #define TF_RGB565 16
  46. #define TF_RGB8888 17
  47. #define DXTERR_INPUT_POINTER_ZERO -1
  48. #define DXTERR_DEPTH_IS_NOT_3_OR_4 -2
  49. #define DXTERR_NON_POWER_2 -3
  50. /* example
  51. LPDIRECT3DTEXTURE8 pCurrentTexture = 0;
  52. HRESULT LoadAllMipSurfaces(void * data, int iLevel)
  53. {
  54. HRESULT hr;
  55. LPDIRECT3DSURFACE8 psurf;
  56. D3DSURFACE_DESC sd;
  57. D3DLOCKED_RECT lr;
  58. hr = pCurrentTexture->GetSurfaceLevel(iLevel, &psurf);
  59. if (FAILED(hr))
  60. return hr;
  61. psurf->GetDesc(&sd);
  62. hr = pCurrentTexture->LockRect(iLevel, &lr, NULL, 0);
  63. if (FAILED(hr))
  64. return hr;
  65. memcpy(lr.pBits, data, sd.Size);
  66. hr = pCurrentTexture->UnlockRect(iLevel);
  67. ReleasePpo(&psurf);
  68. return 0;
  69. }
  70. hr = D3DXCreateTexture(m_pd3dDevice, Width, Height, nMips, 0, D3DFMT_DXT3, D3DPOOL_MANAGED, &pCurrentTexture);
  71. nvDXTcompress(raw_data, Width, Height, DXT3, true, 4, LoadAllMipSurfaces);
  72. */
  73. unsigned char *nvDXTdecompress(int &w, int &h, int &depth, int &total_width,
  74. int &rowBytes);
  75. enum ColorFormat
  76. {
  77. COLOR_RGB,
  78. COLOR_ARGB,
  79. COLOR_BGR,
  80. COLOR_BGRA,
  81. COLOR_RGBA,
  82. COLOR_ABGR,
  83. };
  84. #endif