1 //////////////////////////////////////////////////////////////////////////////
3 // Copyright (C) Microsoft Corporation. All Rights Reserved.
6 // Content: D3DX texturing APIs
8 //////////////////////////////////////////////////////////////////////////////
12 #ifndef __D3DX9TEX_H__
13 #define __D3DX9TEX_H__
16 //----------------------------------------------------------------------------
20 // A valid filter must contain one of these values:
23 // No scaling or filtering will take place. Pixels outside the bounds
24 // of the source image are assumed to be transparent black.
26 // Each destination pixel is computed by sampling the nearest pixel
27 // from the source image.
29 // Each destination pixel is computed by linearly interpolating between
30 // the nearest pixels in the source image. This filter works best
31 // when the scale on each axis is less than 2.
32 // D3DX_FILTER_TRIANGLE
33 // Every pixel in the source image contributes equally to the
34 // destination image. This is the slowest of all the filters.
36 // Each pixel is computed by averaging a 2x2(x2) box pixels from
37 // the source image. Only works when the dimensions of the
38 // destination are half those of the source. (as with mip maps)
40 // And can be OR'd with any of these optional flags:
42 // D3DX_FILTER_MIRROR_U
43 // Indicates that pixels off the edge of the texture on the U-axis
44 // should be mirrored, not wraped.
45 // D3DX_FILTER_MIRROR_V
46 // Indicates that pixels off the edge of the texture on the V-axis
47 // should be mirrored, not wraped.
48 // D3DX_FILTER_MIRROR_W
49 // Indicates that pixels off the edge of the texture on the W-axis
50 // should be mirrored, not wraped.
52 // Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V |
53 // D3DX_FILTER_MIRROR_V
55 // Dithers the resulting image using a 4x4 order dither pattern.
56 // D3DX_FILTER_SRGB_IN
57 // Denotes that the input data is in sRGB (gamma 2.2) colorspace.
58 // D3DX_FILTER_SRGB_OUT
59 // Denotes that the output data is in sRGB (gamma 2.2) colorspace.
61 // Same as specifying D3DX_FILTER_SRGB_IN | D3DX_FILTER_SRGB_OUT
63 //----------------------------------------------------------------------------
65 #define D3DX_FILTER_NONE (1 << 0)
66 #define D3DX_FILTER_POINT (2 << 0)
67 #define D3DX_FILTER_LINEAR (3 << 0)
68 #define D3DX_FILTER_TRIANGLE (4 << 0)
69 #define D3DX_FILTER_BOX (5 << 0)
71 #define D3DX_FILTER_MIRROR_U (1 << 16)
72 #define D3DX_FILTER_MIRROR_V (2 << 16)
73 #define D3DX_FILTER_MIRROR_W (4 << 16)
74 #define D3DX_FILTER_MIRROR (7 << 16)
76 #define D3DX_FILTER_DITHER (1 << 19)
77 #define D3DX_FILTER_DITHER_DIFFUSION (2 << 19)
79 #define D3DX_FILTER_SRGB_IN (1 << 21)
80 #define D3DX_FILTER_SRGB_OUT (2 << 21)
81 #define D3DX_FILTER_SRGB (3 << 21)
84 //----------------------------------------------------------------------------
85 // D3DX_NORMALMAP flags:
86 // ---------------------
87 // These flags are used to control how D3DXComputeNormalMap generates normal
88 // maps. Any number of these flags may be OR'd together in any combination.
90 // D3DX_NORMALMAP_MIRROR_U
91 // Indicates that pixels off the edge of the texture on the U-axis
92 // should be mirrored, not wraped.
93 // D3DX_NORMALMAP_MIRROR_V
94 // Indicates that pixels off the edge of the texture on the V-axis
95 // should be mirrored, not wraped.
96 // D3DX_NORMALMAP_MIRROR
97 // Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V
98 // D3DX_NORMALMAP_INVERTSIGN
99 // Inverts the direction of each normal
100 // D3DX_NORMALMAP_COMPUTE_OCCLUSION
101 // Compute the per pixel Occlusion term and encodes it into the alpha.
102 // An Alpha of 1 means that the pixel is not obscured in anyway, and
103 // an alpha of 0 would mean that the pixel is completly obscured.
105 //----------------------------------------------------------------------------
107 //----------------------------------------------------------------------------
109 #define D3DX_NORMALMAP_MIRROR_U (1 << 16)
110 #define D3DX_NORMALMAP_MIRROR_V (2 << 16)
111 #define D3DX_NORMALMAP_MIRROR (3 << 16)
112 #define D3DX_NORMALMAP_INVERTSIGN (8 << 16)
113 #define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16)
118 //----------------------------------------------------------------------------
119 // D3DX_CHANNEL flags:
120 // -------------------
121 // These flags are used by functions which operate on or more channels
125 // Indicates the red channel should be used
127 // Indicates the blue channel should be used
128 // D3DX_CHANNEL_GREEN
129 // Indicates the green channel should be used
130 // D3DX_CHANNEL_ALPHA
131 // Indicates the alpha channel should be used
132 // D3DX_CHANNEL_LUMINANCE
133 // Indicates the luminaces of the red green and blue channels should be
136 //----------------------------------------------------------------------------
138 #define D3DX_CHANNEL_RED (1 << 0)
139 #define D3DX_CHANNEL_BLUE (1 << 1)
140 #define D3DX_CHANNEL_GREEN (1 << 2)
141 #define D3DX_CHANNEL_ALPHA (1 << 3)
142 #define D3DX_CHANNEL_LUMINANCE (1 << 4)
147 //----------------------------------------------------------------------------
148 // D3DXIMAGE_FILEFORMAT:
149 // ---------------------
150 // This enum is used to describe supported image file formats.
152 //----------------------------------------------------------------------------
154 typedef enum _D3DXIMAGE_FILEFORMAT
163 D3DXIFF_HDR
= 7, //high dynamic range formats
165 D3DXIFF_FORCE_DWORD
= 0x7fffffff
167 } D3DXIMAGE_FILEFORMAT
;
170 //----------------------------------------------------------------------------
171 // LPD3DXFILL2D and LPD3DXFILL3D:
172 // ------------------------------
173 // Function types used by the texture fill functions.
177 // Pointer to a vector which the function uses to return its result.
178 // X,Y,Z,W will be mapped to R,G,B,A respectivly.
180 // Pointer to a vector containing the coordinates of the texel currently
181 // being evaluated. Textures and VolumeTexture texcoord components
182 // range from 0 to 1. CubeTexture texcoord component range from -1 to 1.
184 // Pointer to a vector containing the dimensions of the current texel.
186 // Pointer to user data.
188 //----------------------------------------------------------------------------
190 typedef VOID (WINAPI
*LPD3DXFILL2D
)(D3DXVECTOR4
*pOut
,
191 CONST D3DXVECTOR2
*pTexCoord
, CONST D3DXVECTOR2
*pTexelSize
, LPVOID pData
);
193 typedef VOID (WINAPI
*LPD3DXFILL3D
)(D3DXVECTOR4
*pOut
,
194 CONST D3DXVECTOR3
*pTexCoord
, CONST D3DXVECTOR3
*pTexelSize
, LPVOID pData
);
198 //----------------------------------------------------------------------------
201 // This structure is used to return a rough description of what the
202 // the original contents of an image file looked like.
205 // Width of original image in pixels
207 // Height of original image in pixels
209 // Depth of original image in pixels
211 // Number of mip levels in original image
213 // D3D format which most closely describes the data in original image
215 // D3DRESOURCETYPE representing the type of texture stored in the file.
216 // D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE.
218 // D3DXIMAGE_FILEFORMAT representing the format of the image file.
220 //----------------------------------------------------------------------------
222 typedef struct _D3DXIMAGE_INFO
229 D3DRESOURCETYPE ResourceType
;
230 D3DXIMAGE_FILEFORMAT ImageFileFormat
;
244 //////////////////////////////////////////////////////////////////////////////
245 // Image File APIs ///////////////////////////////////////////////////////////
246 //////////////////////////////////////////////////////////////////////////////
248 //----------------------------------------------------------------------------
249 // GetImageInfoFromFile/Resource:
250 // ------------------------------
251 // Fills in a D3DXIMAGE_INFO struct with information about an image file.
255 // File name of the source image.
257 // Module where resource is located, or NULL for module associated
258 // with image the os used to create the current process.
262 // Pointer to file in memory.
264 // Size in bytes of file in memory.
266 // Pointer to a D3DXIMAGE_INFO structure to be filled in with the
267 // description of the data in the source image file.
269 //----------------------------------------------------------------------------
272 D3DXGetImageInfoFromFileA(
274 D3DXIMAGE_INFO
* pSrcInfo
);
277 D3DXGetImageInfoFromFileW(
279 D3DXIMAGE_INFO
* pSrcInfo
);
282 #define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW
284 #define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA
289 D3DXGetImageInfoFromResourceA(
292 D3DXIMAGE_INFO
* pSrcInfo
);
295 D3DXGetImageInfoFromResourceW(
297 LPCWSTR pSrcResource
,
298 D3DXIMAGE_INFO
* pSrcInfo
);
301 #define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW
303 #define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA
308 D3DXGetImageInfoFromFileInMemory(
311 D3DXIMAGE_INFO
* pSrcInfo
);
316 //////////////////////////////////////////////////////////////////////////////
317 // Load/Save Surface APIs ////////////////////////////////////////////////////
318 //////////////////////////////////////////////////////////////////////////////
320 //----------------------------------------------------------------------------
321 // D3DXLoadSurfaceFromFile/Resource:
322 // ---------------------------------
323 // Load surface from a file or resource
327 // Destination surface, which will receive the image.
329 // Destination palette of 256 colors, or NULL
331 // Destination rectangle, or NULL for entire surface
333 // File name of the source image.
335 // Module where resource is located, or NULL for module associated
336 // with image the os used to create the current process.
340 // Pointer to file in memory.
342 // Size in bytes of file in memory.
344 // Source rectangle, or NULL for entire image
346 // D3DX_FILTER flags controlling how the image is filtered.
347 // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
349 // Color to replace with transparent black, or 0 to disable colorkey.
350 // This is always a 32-bit ARGB color, independent of the source image
351 // format. Alpha is significant, and should usually be set to FF for
352 // opaque colorkeys. (ex. Opaque black == 0xff000000)
354 // Pointer to a D3DXIMAGE_INFO structure to be filled in with the
355 // description of the data in the source image file, or NULL.
357 //----------------------------------------------------------------------------
360 D3DXLoadSurfaceFromFileA(
361 LPDIRECT3DSURFACE9 pDestSurface
,
362 CONST PALETTEENTRY
* pDestPalette
,
363 CONST RECT
* pDestRect
,
365 CONST RECT
* pSrcRect
,
368 D3DXIMAGE_INFO
* pSrcInfo
);
371 D3DXLoadSurfaceFromFileW(
372 LPDIRECT3DSURFACE9 pDestSurface
,
373 CONST PALETTEENTRY
* pDestPalette
,
374 CONST RECT
* pDestRect
,
376 CONST RECT
* pSrcRect
,
379 D3DXIMAGE_INFO
* pSrcInfo
);
382 #define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW
384 #define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA
390 D3DXLoadSurfaceFromResourceA(
391 LPDIRECT3DSURFACE9 pDestSurface
,
392 CONST PALETTEENTRY
* pDestPalette
,
393 CONST RECT
* pDestRect
,
396 CONST RECT
* pSrcRect
,
399 D3DXIMAGE_INFO
* pSrcInfo
);
402 D3DXLoadSurfaceFromResourceW(
403 LPDIRECT3DSURFACE9 pDestSurface
,
404 CONST PALETTEENTRY
* pDestPalette
,
405 CONST RECT
* pDestRect
,
407 LPCWSTR pSrcResource
,
408 CONST RECT
* pSrcRect
,
411 D3DXIMAGE_INFO
* pSrcInfo
);
415 #define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW
417 #define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA
423 D3DXLoadSurfaceFromFileInMemory(
424 LPDIRECT3DSURFACE9 pDestSurface
,
425 CONST PALETTEENTRY
* pDestPalette
,
426 CONST RECT
* pDestRect
,
429 CONST RECT
* pSrcRect
,
432 D3DXIMAGE_INFO
* pSrcInfo
);
436 //----------------------------------------------------------------------------
437 // D3DXLoadSurfaceFromSurface:
438 // ---------------------------
439 // Load surface from another surface (with color conversion)
443 // Destination surface, which will receive the image.
445 // Destination palette of 256 colors, or NULL
447 // Destination rectangle, or NULL for entire surface
451 // Source palette of 256 colors, or NULL
453 // Source rectangle, or NULL for entire surface
455 // D3DX_FILTER flags controlling how the image is filtered.
456 // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
458 // Color to replace with transparent black, or 0 to disable colorkey.
459 // This is always a 32-bit ARGB color, independent of the source image
460 // format. Alpha is significant, and should usually be set to FF for
461 // opaque colorkeys. (ex. Opaque black == 0xff000000)
463 //----------------------------------------------------------------------------
466 D3DXLoadSurfaceFromSurface(
467 LPDIRECT3DSURFACE9 pDestSurface
,
468 CONST PALETTEENTRY
* pDestPalette
,
469 CONST RECT
* pDestRect
,
470 LPDIRECT3DSURFACE9 pSrcSurface
,
471 CONST PALETTEENTRY
* pSrcPalette
,
472 CONST RECT
* pSrcRect
,
477 //----------------------------------------------------------------------------
478 // D3DXLoadSurfaceFromMemory:
479 // --------------------------
480 // Load surface from memory.
484 // Destination surface, which will receive the image.
486 // Destination palette of 256 colors, or NULL
488 // Destination rectangle, or NULL for entire surface
490 // Pointer to the top-left corner of the source image in memory
492 // Pixel format of the source image.
494 // Pitch of source image, in bytes. For DXT formats, this number
495 // should represent the width of one row of cells, in bytes.
497 // Source palette of 256 colors, or NULL
501 // D3DX_FILTER flags controlling how the image is filtered.
502 // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
504 // Color to replace with transparent black, or 0 to disable colorkey.
505 // This is always a 32-bit ARGB color, independent of the source image
506 // format. Alpha is significant, and should usually be set to FF for
507 // opaque colorkeys. (ex. Opaque black == 0xff000000)
509 //----------------------------------------------------------------------------
512 D3DXLoadSurfaceFromMemory(
513 LPDIRECT3DSURFACE9 pDestSurface
,
514 CONST PALETTEENTRY
* pDestPalette
,
515 CONST RECT
* pDestRect
,
519 CONST PALETTEENTRY
* pSrcPalette
,
520 CONST RECT
* pSrcRect
,
525 //----------------------------------------------------------------------------
526 // D3DXSaveSurfaceToFile:
527 // ----------------------
528 // Save a surface to a image file.
532 // File name of the destination file
534 // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
536 // Source surface, containing the image to be saved
538 // Source palette of 256 colors, or NULL
540 // Source rectangle, or NULL for the entire image
542 //----------------------------------------------------------------------------
545 D3DXSaveSurfaceToFileA(
547 D3DXIMAGE_FILEFORMAT DestFormat
,
548 LPDIRECT3DSURFACE9 pSrcSurface
,
549 CONST PALETTEENTRY
* pSrcPalette
,
550 CONST RECT
* pSrcRect
);
553 D3DXSaveSurfaceToFileW(
555 D3DXIMAGE_FILEFORMAT DestFormat
,
556 LPDIRECT3DSURFACE9 pSrcSurface
,
557 CONST PALETTEENTRY
* pSrcPalette
,
558 CONST RECT
* pSrcRect
);
561 #define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW
563 #define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA
566 //----------------------------------------------------------------------------
567 // D3DXSaveSurfaceToFileInMemory:
568 // ----------------------
569 // Save a surface to a image file.
573 // address of pointer to d3dxbuffer for returning data bits
575 // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
577 // Source surface, containing the image to be saved
579 // Source palette of 256 colors, or NULL
581 // Source rectangle, or NULL for the entire image
583 //----------------------------------------------------------------------------
586 D3DXSaveSurfaceToFileInMemory(
587 LPD3DXBUFFER
* ppDestBuf
,
588 D3DXIMAGE_FILEFORMAT DestFormat
,
589 LPDIRECT3DSURFACE9 pSrcSurface
,
590 CONST PALETTEENTRY
* pSrcPalette
,
591 CONST RECT
* pSrcRect
);
594 //////////////////////////////////////////////////////////////////////////////
595 // Load/Save Volume APIs /////////////////////////////////////////////////////
596 //////////////////////////////////////////////////////////////////////////////
598 //----------------------------------------------------------------------------
599 // D3DXLoadVolumeFromFile/Resource:
600 // --------------------------------
601 // Load volume from a file or resource
605 // Destination volume, which will receive the image.
607 // Destination palette of 256 colors, or NULL
609 // Destination box, or NULL for entire volume
611 // File name of the source image.
613 // Module where resource is located, or NULL for module associated
614 // with image the os used to create the current process.
618 // Pointer to file in memory.
620 // Size in bytes of file in memory.
622 // Source box, or NULL for entire image
624 // D3DX_FILTER flags controlling how the image is filtered.
625 // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
627 // Color to replace with transparent black, or 0 to disable colorkey.
628 // This is always a 32-bit ARGB color, independent of the source image
629 // format. Alpha is significant, and should usually be set to FF for
630 // opaque colorkeys. (ex. Opaque black == 0xff000000)
632 // Pointer to a D3DXIMAGE_INFO structure to be filled in with the
633 // description of the data in the source image file, or NULL.
635 //----------------------------------------------------------------------------
638 D3DXLoadVolumeFromFileA(
639 LPDIRECT3DVOLUME9 pDestVolume
,
640 CONST PALETTEENTRY
* pDestPalette
,
641 CONST D3DBOX
* pDestBox
,
643 CONST D3DBOX
* pSrcBox
,
646 D3DXIMAGE_INFO
* pSrcInfo
);
649 D3DXLoadVolumeFromFileW(
650 LPDIRECT3DVOLUME9 pDestVolume
,
651 CONST PALETTEENTRY
* pDestPalette
,
652 CONST D3DBOX
* pDestBox
,
654 CONST D3DBOX
* pSrcBox
,
657 D3DXIMAGE_INFO
* pSrcInfo
);
660 #define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW
662 #define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA
667 D3DXLoadVolumeFromResourceA(
668 LPDIRECT3DVOLUME9 pDestVolume
,
669 CONST PALETTEENTRY
* pDestPalette
,
670 CONST D3DBOX
* pDestBox
,
673 CONST D3DBOX
* pSrcBox
,
676 D3DXIMAGE_INFO
* pSrcInfo
);
679 D3DXLoadVolumeFromResourceW(
680 LPDIRECT3DVOLUME9 pDestVolume
,
681 CONST PALETTEENTRY
* pDestPalette
,
682 CONST D3DBOX
* pDestBox
,
684 LPCWSTR pSrcResource
,
685 CONST D3DBOX
* pSrcBox
,
688 D3DXIMAGE_INFO
* pSrcInfo
);
691 #define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW
693 #define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA
699 D3DXLoadVolumeFromFileInMemory(
700 LPDIRECT3DVOLUME9 pDestVolume
,
701 CONST PALETTEENTRY
* pDestPalette
,
702 CONST D3DBOX
* pDestBox
,
705 CONST D3DBOX
* pSrcBox
,
708 D3DXIMAGE_INFO
* pSrcInfo
);
712 //----------------------------------------------------------------------------
713 // D3DXLoadVolumeFromVolume:
714 // -------------------------
715 // Load volume from another volume (with color conversion)
719 // Destination volume, which will receive the image.
721 // Destination palette of 256 colors, or NULL
723 // Destination box, or NULL for entire volume
727 // Source palette of 256 colors, or NULL
729 // Source box, or NULL for entire volume
731 // D3DX_FILTER flags controlling how the image is filtered.
732 // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
734 // Color to replace with transparent black, or 0 to disable colorkey.
735 // This is always a 32-bit ARGB color, independent of the source image
736 // format. Alpha is significant, and should usually be set to FF for
737 // opaque colorkeys. (ex. Opaque black == 0xff000000)
739 //----------------------------------------------------------------------------
742 D3DXLoadVolumeFromVolume(
743 LPDIRECT3DVOLUME9 pDestVolume
,
744 CONST PALETTEENTRY
* pDestPalette
,
745 CONST D3DBOX
* pDestBox
,
746 LPDIRECT3DVOLUME9 pSrcVolume
,
747 CONST PALETTEENTRY
* pSrcPalette
,
748 CONST D3DBOX
* pSrcBox
,
754 //----------------------------------------------------------------------------
755 // D3DXLoadVolumeFromMemory:
756 // -------------------------
757 // Load volume from memory.
761 // Destination volume, which will receive the image.
763 // Destination palette of 256 colors, or NULL
765 // Destination box, or NULL for entire volume
767 // Pointer to the top-left corner of the source volume in memory
769 // Pixel format of the source volume.
771 // Pitch of source image, in bytes. For DXT formats, this number
772 // should represent the size of one row of cells, in bytes.
774 // Pitch of source image, in bytes. For DXT formats, this number
775 // should represent the size of one slice of cells, in bytes.
777 // Source palette of 256 colors, or NULL
781 // D3DX_FILTER flags controlling how the image is filtered.
782 // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
784 // Color to replace with transparent black, or 0 to disable colorkey.
785 // This is always a 32-bit ARGB color, independent of the source image
786 // format. Alpha is significant, and should usually be set to FF for
787 // opaque colorkeys. (ex. Opaque black == 0xff000000)
789 //----------------------------------------------------------------------------
792 D3DXLoadVolumeFromMemory(
793 LPDIRECT3DVOLUME9 pDestVolume
,
794 CONST PALETTEENTRY
* pDestPalette
,
795 CONST D3DBOX
* pDestBox
,
800 CONST PALETTEENTRY
* pSrcPalette
,
801 CONST D3DBOX
* pSrcBox
,
807 //----------------------------------------------------------------------------
808 // D3DXSaveVolumeToFile:
809 // ---------------------
810 // Save a volume to a image file.
814 // File name of the destination file
816 // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
818 // Source volume, containing the image to be saved
820 // Source palette of 256 colors, or NULL
822 // Source box, or NULL for the entire volume
824 //----------------------------------------------------------------------------
827 D3DXSaveVolumeToFileA(
829 D3DXIMAGE_FILEFORMAT DestFormat
,
830 LPDIRECT3DVOLUME9 pSrcVolume
,
831 CONST PALETTEENTRY
* pSrcPalette
,
832 CONST D3DBOX
* pSrcBox
);
835 D3DXSaveVolumeToFileW(
837 D3DXIMAGE_FILEFORMAT DestFormat
,
838 LPDIRECT3DVOLUME9 pSrcVolume
,
839 CONST PALETTEENTRY
* pSrcPalette
,
840 CONST D3DBOX
* pSrcBox
);
843 #define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW
845 #define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA
849 //----------------------------------------------------------------------------
850 // D3DXSaveVolumeToFileInMemory:
851 // ---------------------
852 // Save a volume to a image file.
856 // File name of the destination file
858 // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
860 // Source volume, containing the image to be saved
862 // Source palette of 256 colors, or NULL
864 // Source box, or NULL for the entire volume
866 //----------------------------------------------------------------------------
869 D3DXSaveVolumeToFileInMemory(
870 LPD3DXBUFFER
* ppDestBuf
,
871 D3DXIMAGE_FILEFORMAT DestFormat
,
872 LPDIRECT3DVOLUME9 pSrcVolume
,
873 CONST PALETTEENTRY
* pSrcPalette
,
874 CONST D3DBOX
* pSrcBox
);
876 //////////////////////////////////////////////////////////////////////////////
877 // Create/Save Texture APIs //////////////////////////////////////////////////
878 //////////////////////////////////////////////////////////////////////////////
880 //----------------------------------------------------------------------------
881 // D3DXCheckTextureRequirements:
882 // -----------------------------
883 // Checks texture creation parameters. If parameters are invalid, this
884 // function returns corrected parameters.
889 // The D3D device to be used
890 // pWidth, pHeight, pDepth, pSize
891 // Desired size in pixels, or NULL. Returns corrected size.
893 // Number of desired mipmap levels, or NULL. Returns corrected number.
895 // Texture usage flags
897 // Desired pixel format, or NULL. Returns corrected format.
899 // Memory pool to be used to create texture
901 //----------------------------------------------------------------------------
904 D3DXCheckTextureRequirements(
905 LPDIRECT3DDEVICE9 pDevice
,
914 D3DXCheckCubeTextureRequirements(
915 LPDIRECT3DDEVICE9 pDevice
,
923 D3DXCheckVolumeTextureRequirements(
924 LPDIRECT3DDEVICE9 pDevice
,
934 //----------------------------------------------------------------------------
935 // D3DXCreateTexture:
936 // ------------------
937 // Create an empty texture
942 // The D3D device with which the texture is going to be used.
943 // Width, Height, Depth, Size
944 // size in pixels. these must be non-zero
946 // number of mip levels desired. if zero or D3DX_DEFAULT, a complete
947 // mipmap chain will be created.
949 // Texture usage flags
953 // Memory pool to be used to create texture
954 // ppTexture, ppCubeTexture, ppVolumeTexture
955 // The texture object that will be created
957 //----------------------------------------------------------------------------
961 LPDIRECT3DDEVICE9 pDevice
,
968 LPDIRECT3DTEXTURE9
* ppTexture
);
971 D3DXCreateCubeTexture(
972 LPDIRECT3DDEVICE9 pDevice
,
978 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
981 D3DXCreateVolumeTexture(
982 LPDIRECT3DDEVICE9 pDevice
,
990 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
994 //----------------------------------------------------------------------------
995 // D3DXCreateTextureFromFile/Resource:
996 // -----------------------------------
997 // Create a texture object from a file or resource.
1002 // The D3D device with which the texture is going to be used.
1006 // Module handle. if NULL, current module will be used.
1008 // Resource name in module
1010 // Pointer to file in memory.
1012 // Size in bytes of file in memory.
1013 // Width, Height, Depth, Size
1014 // Size in pixels. If zero or D3DX_DEFAULT, the size will be taken from
1015 // the file and rounded up to a power of two. If D3DX_DEFAULT_NONPOW2,
1016 // and the device supports NONPOW2 textures, the size will not be rounded.
1017 // If D3DX_FROM_FILE, the size will be taken exactly as it is in the file,
1018 // and the call will fail if this violates device capabilities.
1020 // Number of mip levels. If zero or D3DX_DEFAULT, a complete mipmap
1021 // chain will be created. If D3DX_FROM_FILE, the size will be taken
1022 // exactly as it is in the file, and the call will fail if this violates
1023 // device capabilities.
1025 // Texture usage flags
1027 // Desired pixel format. If D3DFMT_UNKNOWN, the format will be
1028 // taken from the file. If D3DFMT_FROM_FILE, the format will be taken
1029 // exactly as it is in the file, and the call will fail if the device does
1030 // not support the given format.
1032 // Memory pool to be used to create texture
1034 // D3DX_FILTER flags controlling how the image is filtered.
1035 // Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
1037 // D3DX_FILTER flags controlling how each miplevel is filtered.
1038 // Or D3DX_DEFAULT for D3DX_FILTER_BOX,
1040 // Color to replace with transparent black, or 0 to disable colorkey.
1041 // This is always a 32-bit ARGB color, independent of the source image
1042 // format. Alpha is significant, and should usually be set to FF for
1043 // opaque colorkeys. (ex. Opaque black == 0xff000000)
1045 // Pointer to a D3DXIMAGE_INFO structure to be filled in with the
1046 // description of the data in the source image file, or NULL.
1048 // 256 color palette to be filled in, or NULL
1049 // ppTexture, ppCubeTexture, ppVolumeTexture
1050 // The texture object that will be created
1052 //----------------------------------------------------------------------------
1058 D3DXCreateTextureFromFileA(
1059 LPDIRECT3DDEVICE9 pDevice
,
1061 LPDIRECT3DTEXTURE9
* ppTexture
);
1064 D3DXCreateTextureFromFileW(
1065 LPDIRECT3DDEVICE9 pDevice
,
1067 LPDIRECT3DTEXTURE9
* ppTexture
);
1070 #define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW
1072 #define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA
1077 D3DXCreateCubeTextureFromFileA(
1078 LPDIRECT3DDEVICE9 pDevice
,
1080 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1083 D3DXCreateCubeTextureFromFileW(
1084 LPDIRECT3DDEVICE9 pDevice
,
1086 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1089 #define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW
1091 #define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA
1096 D3DXCreateVolumeTextureFromFileA(
1097 LPDIRECT3DDEVICE9 pDevice
,
1099 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1102 D3DXCreateVolumeTextureFromFileW(
1103 LPDIRECT3DDEVICE9 pDevice
,
1105 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1108 #define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW
1110 #define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA
1117 D3DXCreateTextureFromResourceA(
1118 LPDIRECT3DDEVICE9 pDevice
,
1120 LPCSTR pSrcResource
,
1121 LPDIRECT3DTEXTURE9
* ppTexture
);
1124 D3DXCreateTextureFromResourceW(
1125 LPDIRECT3DDEVICE9 pDevice
,
1127 LPCWSTR pSrcResource
,
1128 LPDIRECT3DTEXTURE9
* ppTexture
);
1131 #define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW
1133 #define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA
1138 D3DXCreateCubeTextureFromResourceA(
1139 LPDIRECT3DDEVICE9 pDevice
,
1141 LPCSTR pSrcResource
,
1142 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1145 D3DXCreateCubeTextureFromResourceW(
1146 LPDIRECT3DDEVICE9 pDevice
,
1148 LPCWSTR pSrcResource
,
1149 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1152 #define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW
1154 #define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA
1159 D3DXCreateVolumeTextureFromResourceA(
1160 LPDIRECT3DDEVICE9 pDevice
,
1162 LPCSTR pSrcResource
,
1163 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1166 D3DXCreateVolumeTextureFromResourceW(
1167 LPDIRECT3DDEVICE9 pDevice
,
1169 LPCWSTR pSrcResource
,
1170 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1173 #define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW
1175 #define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA
1182 D3DXCreateTextureFromFileExA(
1183 LPDIRECT3DDEVICE9 pDevice
,
1194 D3DXIMAGE_INFO
* pSrcInfo
,
1195 PALETTEENTRY
* pPalette
,
1196 LPDIRECT3DTEXTURE9
* ppTexture
);
1199 D3DXCreateTextureFromFileExW(
1200 LPDIRECT3DDEVICE9 pDevice
,
1211 D3DXIMAGE_INFO
* pSrcInfo
,
1212 PALETTEENTRY
* pPalette
,
1213 LPDIRECT3DTEXTURE9
* ppTexture
);
1216 #define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW
1218 #define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA
1223 D3DXCreateCubeTextureFromFileExA(
1224 LPDIRECT3DDEVICE9 pDevice
,
1234 D3DXIMAGE_INFO
* pSrcInfo
,
1235 PALETTEENTRY
* pPalette
,
1236 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1239 D3DXCreateCubeTextureFromFileExW(
1240 LPDIRECT3DDEVICE9 pDevice
,
1250 D3DXIMAGE_INFO
* pSrcInfo
,
1251 PALETTEENTRY
* pPalette
,
1252 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1255 #define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW
1257 #define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA
1262 D3DXCreateVolumeTextureFromFileExA(
1263 LPDIRECT3DDEVICE9 pDevice
,
1275 D3DXIMAGE_INFO
* pSrcInfo
,
1276 PALETTEENTRY
* pPalette
,
1277 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1280 D3DXCreateVolumeTextureFromFileExW(
1281 LPDIRECT3DDEVICE9 pDevice
,
1293 D3DXIMAGE_INFO
* pSrcInfo
,
1294 PALETTEENTRY
* pPalette
,
1295 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1298 #define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW
1300 #define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA
1307 D3DXCreateTextureFromResourceExA(
1308 LPDIRECT3DDEVICE9 pDevice
,
1310 LPCSTR pSrcResource
,
1320 D3DXIMAGE_INFO
* pSrcInfo
,
1321 PALETTEENTRY
* pPalette
,
1322 LPDIRECT3DTEXTURE9
* ppTexture
);
1325 D3DXCreateTextureFromResourceExW(
1326 LPDIRECT3DDEVICE9 pDevice
,
1328 LPCWSTR pSrcResource
,
1338 D3DXIMAGE_INFO
* pSrcInfo
,
1339 PALETTEENTRY
* pPalette
,
1340 LPDIRECT3DTEXTURE9
* ppTexture
);
1343 #define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW
1345 #define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA
1350 D3DXCreateCubeTextureFromResourceExA(
1351 LPDIRECT3DDEVICE9 pDevice
,
1353 LPCSTR pSrcResource
,
1362 D3DXIMAGE_INFO
* pSrcInfo
,
1363 PALETTEENTRY
* pPalette
,
1364 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1367 D3DXCreateCubeTextureFromResourceExW(
1368 LPDIRECT3DDEVICE9 pDevice
,
1370 LPCWSTR pSrcResource
,
1379 D3DXIMAGE_INFO
* pSrcInfo
,
1380 PALETTEENTRY
* pPalette
,
1381 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1384 #define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW
1386 #define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA
1391 D3DXCreateVolumeTextureFromResourceExA(
1392 LPDIRECT3DDEVICE9 pDevice
,
1394 LPCSTR pSrcResource
,
1405 D3DXIMAGE_INFO
* pSrcInfo
,
1406 PALETTEENTRY
* pPalette
,
1407 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1410 D3DXCreateVolumeTextureFromResourceExW(
1411 LPDIRECT3DDEVICE9 pDevice
,
1413 LPCWSTR pSrcResource
,
1424 D3DXIMAGE_INFO
* pSrcInfo
,
1425 PALETTEENTRY
* pPalette
,
1426 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1429 #define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW
1431 #define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA
1438 D3DXCreateTextureFromFileInMemory(
1439 LPDIRECT3DDEVICE9 pDevice
,
1442 LPDIRECT3DTEXTURE9
* ppTexture
);
1445 D3DXCreateCubeTextureFromFileInMemory(
1446 LPDIRECT3DDEVICE9 pDevice
,
1449 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1452 D3DXCreateVolumeTextureFromFileInMemory(
1453 LPDIRECT3DDEVICE9 pDevice
,
1456 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1459 // FromFileInMemoryEx
1462 D3DXCreateTextureFromFileInMemoryEx(
1463 LPDIRECT3DDEVICE9 pDevice
,
1475 D3DXIMAGE_INFO
* pSrcInfo
,
1476 PALETTEENTRY
* pPalette
,
1477 LPDIRECT3DTEXTURE9
* ppTexture
);
1480 D3DXCreateCubeTextureFromFileInMemoryEx(
1481 LPDIRECT3DDEVICE9 pDevice
,
1492 D3DXIMAGE_INFO
* pSrcInfo
,
1493 PALETTEENTRY
* pPalette
,
1494 LPDIRECT3DCUBETEXTURE9
* ppCubeTexture
);
1497 D3DXCreateVolumeTextureFromFileInMemoryEx(
1498 LPDIRECT3DDEVICE9 pDevice
,
1511 D3DXIMAGE_INFO
* pSrcInfo
,
1512 PALETTEENTRY
* pPalette
,
1513 LPDIRECT3DVOLUMETEXTURE9
* ppVolumeTexture
);
1517 //----------------------------------------------------------------------------
1518 // D3DXSaveTextureToFile:
1519 // ----------------------
1520 // Save a texture to a file.
1524 // File name of the destination file
1526 // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
1528 // Source texture, containing the image to be saved
1530 // Source palette of 256 colors, or NULL
1532 //----------------------------------------------------------------------------
1536 D3DXSaveTextureToFileA(
1538 D3DXIMAGE_FILEFORMAT DestFormat
,
1539 LPDIRECT3DBASETEXTURE9 pSrcTexture
,
1540 CONST PALETTEENTRY
* pSrcPalette
);
1543 D3DXSaveTextureToFileW(
1545 D3DXIMAGE_FILEFORMAT DestFormat
,
1546 LPDIRECT3DBASETEXTURE9 pSrcTexture
,
1547 CONST PALETTEENTRY
* pSrcPalette
);
1550 #define D3DXSaveTextureToFile D3DXSaveTextureToFileW
1552 #define D3DXSaveTextureToFile D3DXSaveTextureToFileA
1556 //----------------------------------------------------------------------------
1557 // D3DXSaveTextureToFileInMemory:
1558 // ----------------------
1559 // Save a texture to a file.
1563 // address of a d3dxbuffer pointer to return the image data
1565 // D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
1567 // Source texture, containing the image to be saved
1569 // Source palette of 256 colors, or NULL
1571 //----------------------------------------------------------------------------
1574 D3DXSaveTextureToFileInMemory(
1575 LPD3DXBUFFER
* ppDestBuf
,
1576 D3DXIMAGE_FILEFORMAT DestFormat
,
1577 LPDIRECT3DBASETEXTURE9 pSrcTexture
,
1578 CONST PALETTEENTRY
* pSrcPalette
);
1583 //////////////////////////////////////////////////////////////////////////////
1584 // Misc Texture APIs /////////////////////////////////////////////////////////
1585 //////////////////////////////////////////////////////////////////////////////
1587 //----------------------------------------------------------------------------
1588 // D3DXFilterTexture:
1589 // ------------------
1590 // Filters mipmaps levels of a texture.
1594 // The texture object to be filtered
1596 // 256 color palette to be used, or NULL for non-palettized formats
1598 // The level whose image is used to generate the subsequent levels.
1600 // D3DX_FILTER flags controlling how each miplevel is filtered.
1601 // Or D3DX_DEFAULT for D3DX_FILTER_BOX,
1603 //----------------------------------------------------------------------------
1607 LPDIRECT3DBASETEXTURE9 pBaseTexture
,
1608 CONST PALETTEENTRY
* pPalette
,
1612 #define D3DXFilterCubeTexture D3DXFilterTexture
1613 #define D3DXFilterVolumeTexture D3DXFilterTexture
1617 //----------------------------------------------------------------------------
1620 // Uses a user provided function to fill each texel of each mip level of a
1624 // pTexture, pCubeTexture, pVolumeTexture
1625 // Pointer to the texture to be filled.
1627 // Pointer to user provided evalutor function which will be used to
1628 // compute the value of each texel.
1630 // Pointer to an arbitrary block of user defined data. This pointer
1631 // will be passed to the function provided in pFunction
1632 //-----------------------------------------------------------------------------
1636 LPDIRECT3DTEXTURE9 pTexture
,
1637 LPD3DXFILL2D pFunction
,
1641 D3DXFillCubeTexture(
1642 LPDIRECT3DCUBETEXTURE9 pCubeTexture
,
1643 LPD3DXFILL3D pFunction
,
1647 D3DXFillVolumeTexture(
1648 LPDIRECT3DVOLUMETEXTURE9 pVolumeTexture
,
1649 LPD3DXFILL3D pFunction
,
1652 //---------------------------------------------------------------------------
1653 // D3DXFillTextureTX:
1654 // ------------------
1655 // Uses a TX Shader target to function to fill each texel of each mip level
1656 // of a given texture. The TX Shader target should be a compiled function
1657 // taking 2 paramters and returning a float4 color.
1660 // pTexture, pCubeTexture, pVolumeTexture
1661 // Pointer to the texture to be filled.
1663 // Pointer to the texture shader to be used to fill in the texture
1664 //----------------------------------------------------------------------------
1668 LPDIRECT3DTEXTURE9 pTexture
,
1669 LPD3DXTEXTURESHADER pTextureShader
);
1673 D3DXFillCubeTextureTX(
1674 LPDIRECT3DCUBETEXTURE9 pCubeTexture
,
1675 LPD3DXTEXTURESHADER pTextureShader
);
1679 D3DXFillVolumeTextureTX(
1680 LPDIRECT3DVOLUMETEXTURE9 pVolumeTexture
,
1681 LPD3DXTEXTURESHADER pTextureShader
);
1685 //----------------------------------------------------------------------------
1686 // D3DXComputeNormalMap:
1687 // ---------------------
1688 // Converts a height map into a normal map. The (x,y,z) components of each
1689 // normal are mapped to the (r,g,b) channels of the output texture.
1693 // Pointer to the destination texture
1695 // Pointer to the source heightmap texture
1697 // Source palette of 256 colors, or NULL
1699 // D3DX_NORMALMAP flags
1701 // D3DX_CHANNEL specifying source of height information
1703 // The constant value which the height information is multiplied by.
1704 //---------------------------------------------------------------------------
1707 D3DXComputeNormalMap(
1708 LPDIRECT3DTEXTURE9 pTexture
,
1709 LPDIRECT3DTEXTURE9 pSrcTexture
,
1710 CONST PALETTEENTRY
* pSrcPalette
,
1720 #endif //__cplusplus
1722 #endif //__D3DX9TEX_H__