1 |
bearsoft |
1.1 |
///////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
|
4 |
|
|
//
|
5 |
|
|
// File: d3dxcore.h
|
6 |
|
|
// Content: D3DX core types and functions
|
7 |
|
|
//
|
8 |
|
|
///////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
#ifndef __D3DXCORE_H__
|
11 |
|
|
#define __D3DXCORE_H__
|
12 |
|
|
|
13 |
|
|
#include <d3d.h>
|
14 |
|
|
#include <limits.h>
|
15 |
|
|
#include "d3dxerr.h"
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
typedef struct ID3DXContext *LPD3DXCONTEXT;
|
19 |
|
|
|
20 |
|
|
// {9B74ED7A-BBEF-11d2-9F8E-0000F8080835}
|
21 |
|
|
DEFINE_GUID(IID_ID3DXContext,
|
22 |
|
|
0x9b74ed7a, 0xbbef, 0x11d2, 0x9f, 0x8e, 0x0, 0x0, 0xf8, 0x8, 0x8, 0x35);
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
///////////////////////////////////////////////////////////////////////////
|
26 |
|
|
// Defines and Enumerators used below:
|
27 |
|
|
///////////////////////////////////////////////////////////////////////////
|
28 |
|
|
|
29 |
|
|
//-------------------------------------------------------------------------
|
30 |
|
|
// D3DX_DEFAULT:
|
31 |
|
|
// ---------
|
32 |
|
|
// A predefined value that could be used for any parameter in D3DX APIs or
|
33 |
|
|
// member functions that is an enumerant or a handle. The D3DX
|
34 |
|
|
// documentation indicates wherever D3DX_DEFAULT may be used,
|
35 |
|
|
// and how it will be interpreted in each situation.
|
36 |
|
|
//-------------------------------------------------------------------------
|
37 |
|
|
#define D3DX_DEFAULT ULONG_MAX
|
38 |
|
|
|
39 |
|
|
//-------------------------------------------------------------------------
|
40 |
|
|
// D3DX_DEFAULT_FLOAT:
|
41 |
|
|
// ------------------
|
42 |
|
|
// Similar to D3DX_DEFAULT, but used for floating point parameters.
|
43 |
|
|
// The D3DX documentation indicates wherever D3DX_DEFAULT_FLOAT may be used,
|
44 |
|
|
// and how it will be interpreted in each situation.
|
45 |
|
|
//-------------------------------------------------------------------------
|
46 |
|
|
#define D3DX_DEFAULT_FLOAT FLT_MAX
|
47 |
|
|
|
48 |
|
|
//-------------------------------------------------------------------------
|
49 |
|
|
// Hardware Acceleration Level:
|
50 |
|
|
// ---------------------------
|
51 |
|
|
// These constants represent pre-defined hardware acceleration levels,
|
52 |
|
|
// and may be used as a default anywhere a (DWORD) deviceIndex is required.
|
53 |
|
|
// Each pre-define indicates a different level of hardware acceleration.
|
54 |
|
|
// They are an alternative to using explicit deviceIndices retrieved by
|
55 |
|
|
// D3DXGetDeviceDescription().
|
56 |
|
|
//
|
57 |
|
|
// The only case these pre-defines should be used as device indices is if
|
58 |
|
|
// a particular level of acceleration is required, and given more than
|
59 |
|
|
// one capable device on the computer, it does not matter which one
|
60 |
|
|
// is used.
|
61 |
|
|
//
|
62 |
|
|
// The method of selection is as follows: If one of the D3DX devices on
|
63 |
|
|
// the primary DDraw device supports a requested hardware acceleration
|
64 |
|
|
// level, it will be used. Otherwise, the first matching device discovered
|
65 |
|
|
// by D3DX will be used.
|
66 |
|
|
//
|
67 |
|
|
// Of course, it is possible for no match to exist for any of the
|
68 |
|
|
// pre-defines on a particular computer. Passing such a value into the
|
69 |
|
|
// D3DX apis will simply cause them to fail, reporting that no match
|
70 |
|
|
// is available.
|
71 |
|
|
//
|
72 |
|
|
// D3DX_HWLEVEL_NULL: Null implementation (draws nothing)
|
73 |
|
|
// D3DX_HWLEVEL_REFERENCE: Reference implementation (slowest)
|
74 |
|
|
// D3DX_HWLEVEL_2D: 2D acceleration only (RGB rasterizer used)
|
75 |
|
|
// D3DX_HWLEVEL_RASTER: Rasterization acceleration (likely most useful)
|
76 |
|
|
// D3DX_HWLEVEL_TL: Transform and lighting acceleration
|
77 |
|
|
// D3DX_DEFAULT: The highest level of acceleration available
|
78 |
|
|
// on the primary DDraw device.
|
79 |
|
|
//-------------------------------------------------------------------------
|
80 |
|
|
#define D3DX_HWLEVEL_NULL (D3DX_DEFAULT - 1)
|
81 |
|
|
#define D3DX_HWLEVEL_REFERENCE (D3DX_DEFAULT - 2)
|
82 |
|
|
#define D3DX_HWLEVEL_2D (D3DX_DEFAULT - 3)
|
83 |
|
|
#define D3DX_HWLEVEL_RASTER (D3DX_DEFAULT - 4)
|
84 |
|
|
#define D3DX_HWLEVEL_TL (D3DX_DEFAULT - 5)
|
85 |
|
|
|
86 |
|
|
//-------------------------------------------------------------------------
|
87 |
|
|
// Surface Class:
|
88 |
|
|
// -------------
|
89 |
|
|
// These are the various types of 2D-surfaces classified according to their
|
90 |
|
|
// usage. Note that a number of them overlap. e.g. STENCILBUFFERS and
|
91 |
|
|
// DEPTHBUFFERS overlap (since in DX7 implementation the stencil and depth
|
92 |
|
|
// bits are part of the same pixel format).
|
93 |
|
|
//
|
94 |
|
|
// Mapping to the DX7 DDPIXELFORMAT concepts:
|
95 |
|
|
// -----------------------------------------
|
96 |
|
|
// D3DX_SC_DEPTHBUFFER: All ddpfs which have the DDPF_ZPIXELS or the
|
97 |
|
|
// DDPF_ZBUFFER flags set.
|
98 |
|
|
// D3DX_SC_STENCILBUFFER: All ddpfs which have the DDPF_STENCILBUFFER
|
99 |
|
|
// flag set.
|
100 |
|
|
// D3DX_SC_BUMPMAP: All ddpfs which have the DDPF_BUMPLUMINANCE
|
101 |
|
|
// or the DDPF_BUMPDUDV flags set.
|
102 |
|
|
// D3DX_SC_LUMINANCEMAP: All ddpfs which have the DDPF_BUMPLUMINANCE
|
103 |
|
|
// or the DDPF_LUMINANCE flags set.
|
104 |
|
|
// D3DX_SC_COLORTEXTURE: All the surfaces that have color information in
|
105 |
|
|
// them and can be used for texturing.
|
106 |
|
|
// D3DX_SC_COLORRENDERTGT: All the surfaces that contain color
|
107 |
|
|
// information and can be used as render targets.
|
108 |
|
|
//-------------------------------------------------------------------------
|
109 |
|
|
#define D3DX_SC_DEPTHBUFFER 0x01
|
110 |
|
|
#define D3DX_SC_STENCILBUFFER 0x02
|
111 |
|
|
#define D3DX_SC_COLORTEXTURE 0x04
|
112 |
|
|
#define D3DX_SC_BUMPMAP 0x08
|
113 |
|
|
#define D3DX_SC_LUMINANCEMAP 0x10
|
114 |
|
|
#define D3DX_SC_COLORRENDERTGT 0x20
|
115 |
|
|
|
116 |
|
|
//-------------------------------------------------------------------------
|
117 |
|
|
// Surface Formats:
|
118 |
|
|
// ---------------
|
119 |
|
|
// These are the various types of surface formats that can be enumerated,
|
120 |
|
|
// there is no DDPIXELFORMAT structure in D3DX, the enums carry the meaning
|
121 |
|
|
// (like FOURCCs).
|
122 |
|
|
//
|
123 |
|
|
// All the surface classes are represented here.
|
124 |
|
|
//
|
125 |
|
|
//-------------------------------------------------------------------------
|
126 |
|
|
typedef enum _D3DX_SURFACEFORMAT
|
127 |
|
|
{
|
128 |
|
|
D3DX_SF_UNKNOWN = 0,
|
129 |
|
|
D3DX_SF_R8G8B8 = 1,
|
130 |
|
|
D3DX_SF_A8R8G8B8 = 2,
|
131 |
|
|
D3DX_SF_X8R8G8B8 = 3,
|
132 |
|
|
D3DX_SF_R5G6B5 = 4,
|
133 |
|
|
D3DX_SF_R5G5B5 = 5,
|
134 |
|
|
D3DX_SF_PALETTE4 = 6,
|
135 |
|
|
D3DX_SF_PALETTE8 = 7,
|
136 |
|
|
D3DX_SF_A1R5G5B5 = 8,
|
137 |
|
|
D3DX_SF_X4R4G4B4 = 9,
|
138 |
|
|
D3DX_SF_A4R4G4B4 =10,
|
139 |
|
|
D3DX_SF_L8 =11, // 8 bit luminance-only
|
140 |
|
|
D3DX_SF_A8L8 =12, // 16 bit alpha-luminance
|
141 |
|
|
D3DX_SF_U8V8 =13, // 16 bit bump map format
|
142 |
|
|
D3DX_SF_U5V5L6 =14, // 16 bit bump map format with luminance
|
143 |
|
|
D3DX_SF_U8V8L8 =15, // 24 bit bump map format with luminance
|
144 |
|
|
D3DX_SF_UYVY =16, // UYVY format (PC98 compliance)
|
145 |
|
|
D3DX_SF_YUY2 =17, // YUY2 format (PC98 compliance)
|
146 |
|
|
D3DX_SF_DXT1 =18, // S3 texture compression technique 1
|
147 |
|
|
D3DX_SF_DXT3 =19, // S3 texture compression technique 3
|
148 |
|
|
D3DX_SF_DXT5 =20, // S3 texture compression technique 5
|
149 |
|
|
D3DX_SF_R3G3B2 =21, // 8 bit RGB texture format
|
150 |
|
|
D3DX_SF_A8 =22, // 8 bit alpha-only
|
151 |
|
|
D3DX_SF_TEXTUREMAX =23, // Last texture format
|
152 |
|
|
|
153 |
|
|
D3DX_SF_Z16S0 =256,
|
154 |
|
|
D3DX_SF_Z32S0 =257,
|
155 |
|
|
D3DX_SF_Z15S1 =258,
|
156 |
|
|
D3DX_SF_Z24S8 =259,
|
157 |
|
|
D3DX_SF_S1Z15 =260,
|
158 |
|
|
D3DX_SF_S8Z24 =261,
|
159 |
|
|
D3DX_SF_DEPTHMAX =262, // Last depth format
|
160 |
|
|
|
161 |
|
|
D3DX_SF_FORCEMAX = (DWORD)(-1)
|
162 |
|
|
} D3DX_SURFACEFORMAT;
|
163 |
|
|
|
164 |
|
|
//-------------------------------------------------------------------------
|
165 |
|
|
// Filtering types for Texture APIs
|
166 |
|
|
//
|
167 |
|
|
// -------------
|
168 |
|
|
// These are the various filter types for generation of mip-maps
|
169 |
|
|
//
|
170 |
|
|
// D3DX_FILTERTYPE
|
171 |
|
|
// -----------------------------------------
|
172 |
|
|
// D3DX_FT_POINT: Point sampling only - no filtering
|
173 |
|
|
// D3DX_FT_LINEAR: Bi-linear filtering
|
174 |
|
|
//
|
175 |
|
|
//-------------------------------------------------------------------------
|
176 |
|
|
typedef enum _D3DX_FILTERTYPE
|
177 |
|
|
{
|
178 |
|
|
D3DX_FT_POINT = 0x01,
|
179 |
|
|
D3DX_FT_LINEAR = 0x02,
|
180 |
|
|
D3DX_FT_DEFAULT = D3DX_DEFAULT
|
181 |
|
|
} D3DX_FILTERTYPE;
|
182 |
|
|
|
183 |
|
|
///////////////////////////////////////////////////////////////////////////
|
184 |
|
|
// Structures used below:
|
185 |
|
|
///////////////////////////////////////////////////////////////////////////
|
186 |
|
|
|
187 |
|
|
//-------------------------------------------------------------------------
|
188 |
|
|
// D3DX_VIDMODEDESC: Display mode description.
|
189 |
|
|
// ----------------
|
190 |
|
|
// width: Screen Width
|
191 |
|
|
// height: Screen Height
|
192 |
|
|
// bpp: Bits per pixel
|
193 |
|
|
// refreshRate: Refresh rate
|
194 |
|
|
//-------------------------------------------------------------------------
|
195 |
|
|
typedef struct _D3DX_VIDMODEDESC
|
196 |
|
|
{
|
197 |
|
|
DWORD width;
|
198 |
|
|
DWORD height;
|
199 |
|
|
DWORD bpp;
|
200 |
|
|
DWORD refreshRate;
|
201 |
|
|
} D3DX_VIDMODEDESC;
|
202 |
|
|
|
203 |
|
|
//-------------------------------------------------------------------------
|
204 |
|
|
// D3DX_DEVICEDESC: Description of a device that can do 3D
|
205 |
|
|
// ---------------
|
206 |
|
|
// deviceIndex: Unique (DWORD) number for the device.
|
207 |
|
|
// hwLevel: Level of acceleration afforded. This is one of the
|
208 |
|
|
// predefined Device Indices, and exists in this
|
209 |
|
|
// structure for informational purposes only. More than
|
210 |
|
|
// one device on the system may have the same hwLevel.
|
211 |
|
|
// To refer to a particular device with the D3DX apis,
|
212 |
|
|
// use the value in the deviceIndex member instead.
|
213 |
|
|
// ddGuid: The ddraw GUID
|
214 |
|
|
// d3dDeviceGuid: Direct3D Device GUID
|
215 |
|
|
// ddDeviceID: DDraw's GetDeviceIdentifier GUID. This GUID is unique to
|
216 |
|
|
// a particular driver revision on a particular video card.
|
217 |
|
|
// driverDesc: String describing the driver
|
218 |
|
|
// monitor: Handle to the video monitor used by this device (multimon
|
219 |
|
|
// specific). Devices that use different monitors on a
|
220 |
|
|
// multimon system report different values in this field.
|
221 |
|
|
// Therefore, to test for a multimon system, an application
|
222 |
|
|
// should look for more than one different monitor handle in
|
223 |
|
|
// the list of D3DX devices.
|
224 |
|
|
// onPrimary: Indicates if this device is on the primary monitor
|
225 |
|
|
// (multimon specific).
|
226 |
|
|
//-------------------------------------------------------------------------
|
227 |
|
|
#define D3DX_DRIVERDESC_LENGTH 256
|
228 |
|
|
|
229 |
|
|
typedef struct _D3DX_DEVICEDESC
|
230 |
|
|
{
|
231 |
|
|
DWORD deviceIndex;
|
232 |
|
|
DWORD hwLevel;
|
233 |
|
|
GUID ddGuid;
|
234 |
|
|
GUID d3dDeviceGuid;
|
235 |
|
|
GUID ddDeviceID;
|
236 |
|
|
char driverDesc[D3DX_DRIVERDESC_LENGTH];
|
237 |
|
|
HMONITOR monitor;
|
238 |
|
|
BOOL onPrimary;
|
239 |
|
|
} D3DX_DEVICEDESC;
|
240 |
|
|
|
241 |
|
|
///////////////////////////////////////////////////////////////////////////
|
242 |
|
|
// APIs:
|
243 |
|
|
///////////////////////////////////////////////////////////////////////////
|
244 |
|
|
#ifdef __cplusplus
|
245 |
|
|
extern "C" {
|
246 |
|
|
#endif //__cplusplus
|
247 |
|
|
|
248 |
|
|
//-------------------------------------------------------------------------
|
249 |
|
|
// D3DXInitialize: The very first call a D3DX app must make.
|
250 |
|
|
//-------------------------------------------------------------------------
|
251 |
|
|
HRESULT WINAPI
|
252 |
|
|
D3DXInitialize();
|
253 |
|
|
|
254 |
|
|
//-------------------------------------------------------------------------
|
255 |
|
|
// D3DXUninitialize: The very last call a D3DX app must make.
|
256 |
|
|
//-------------------------------------------------------------------------
|
257 |
|
|
HRESULT WINAPI
|
258 |
|
|
D3DXUninitialize();
|
259 |
|
|
|
260 |
|
|
//-------------------------------------------------------------------------
|
261 |
|
|
// D3DXGetDeviceCount: Returns the maximum number of D3DXdevices
|
262 |
|
|
// ------------------ available.
|
263 |
|
|
//
|
264 |
|
|
// D3DXGetDeviceDescription: Lists the 2D and 3D capabilities of the devices.
|
265 |
|
|
// ------------------------ Also, the various guids needed by ddraw and d3d.
|
266 |
|
|
//
|
267 |
|
|
// Params:
|
268 |
|
|
// [in] DWORD deviceIndex: Which device? Starts at 0.
|
269 |
|
|
// [in] D3DX_DEVICEDESC* pd3dxDevice: Pointer to the D3DX_DEVICEDESC
|
270 |
|
|
// structure to be filled in.
|
271 |
|
|
//-------------------------------------------------------------------------
|
272 |
|
|
DWORD WINAPI
|
273 |
|
|
D3DXGetDeviceCount();
|
274 |
|
|
|
275 |
|
|
HRESULT WINAPI
|
276 |
|
|
D3DXGetDeviceDescription(DWORD deviceIndex,
|
277 |
|
|
D3DX_DEVICEDESC* pd3dxDeviceDesc);
|
278 |
|
|
|
279 |
|
|
//-------------------------------------------------------------------------
|
280 |
|
|
// D3DXGetMaxNumVideoModes: Returns the maximum number of video-modes .
|
281 |
|
|
// -----------------------
|
282 |
|
|
//
|
283 |
|
|
// Params:
|
284 |
|
|
// [in] DWORD deviceIndex: The device being referred to.
|
285 |
|
|
// [in] DWORD flags: If D3DX_GVM_REFRESHRATE is set, then the refresh
|
286 |
|
|
// rates are not ignored.
|
287 |
|
|
//
|
288 |
|
|
// D3DXGetVideoMode: Describes a particular video mode for this device
|
289 |
|
|
// ----------------
|
290 |
|
|
//
|
291 |
|
|
// Note: These queries will simply give you a list of modes that the
|
292 |
|
|
// display adapter tells DirectX that it supports.
|
293 |
|
|
// There is no guarantee that D3DXCreateContext(Ex) will succeed
|
294 |
|
|
// with all listed video modes. This is a fundamental limitation
|
295 |
|
|
// of the current DirectX architecture which D3DX cannot hide in
|
296 |
|
|
// any clean way.
|
297 |
|
|
//
|
298 |
|
|
// Params:
|
299 |
|
|
// [in] DWORD deviceIndex: The device being referred to.
|
300 |
|
|
// [in] DWORD flags: If D3DX_GVM_REFRESHRATE is set, then the refresh
|
301 |
|
|
// rates are returned
|
302 |
|
|
// [in] DWORD which: Which VideoMode ? Starts at 0.
|
303 |
|
|
// [out] D3DX_VIDMODEDESC* pModeList: Pointer to the D3DX_VIDMODEDESC
|
304 |
|
|
// structure that will be filled in.
|
305 |
|
|
//-------------------------------------------------------------------------
|
306 |
|
|
DWORD WINAPI
|
307 |
|
|
D3DXGetMaxNumVideoModes(DWORD deviceIndex,
|
308 |
|
|
DWORD flags);
|
309 |
|
|
|
310 |
|
|
HRESULT WINAPI
|
311 |
|
|
D3DXGetVideoMode(DWORD deviceIndex,
|
312 |
|
|
DWORD flags,
|
313 |
|
|
DWORD modeIndex,
|
314 |
|
|
D3DX_VIDMODEDESC* pModeDesc);
|
315 |
|
|
|
316 |
|
|
#define D3DX_GVM_REFRESHRATE 0x00000001
|
317 |
|
|
//-------------------------------------------------------------------------
|
318 |
|
|
// D3DXGetMaxSurfaceFormats: Returns the maximum number of surface
|
319 |
|
|
// ------------------------ formats supported by the device at that
|
320 |
|
|
// video mode.
|
321 |
|
|
//
|
322 |
|
|
// D3DXGetSurfaceFormat: Describes one of the supported surface formats.
|
323 |
|
|
// ---------------------
|
324 |
|
|
//
|
325 |
|
|
// Params:
|
326 |
|
|
// [in] DWORD deviceIndex: The device being referred to.
|
327 |
|
|
// [in] D3DX_VIDMODEDESC* pDesc: The display mode at which the supported
|
328 |
|
|
// surface formats are requested. If it is
|
329 |
|
|
// NULL, the current display mode is
|
330 |
|
|
// assumed.
|
331 |
|
|
// [in] DWORD surfClassFlags: Required surface classes. Only surface
|
332 |
|
|
// formats which support all specified
|
333 |
|
|
// surface classes will be returned.
|
334 |
|
|
// (Multiple surface classes may be specified
|
335 |
|
|
// using bitwise OR.)
|
336 |
|
|
// [in] DWORD which: Which surface formats to retrieve. Starts at 0.
|
337 |
|
|
// [out] D3DX_SURFACEFORMAT* pFormat: The surface format
|
338 |
|
|
//-------------------------------------------------------------------------
|
339 |
|
|
DWORD WINAPI
|
340 |
|
|
D3DXGetMaxSurfaceFormats(DWORD deviceIndex,
|
341 |
|
|
D3DX_VIDMODEDESC* pDesc,
|
342 |
|
|
DWORD surfClassFlags);
|
343 |
|
|
HRESULT WINAPI
|
344 |
|
|
D3DXGetSurfaceFormat(DWORD deviceIndex,
|
345 |
|
|
D3DX_VIDMODEDESC* pDesc,
|
346 |
|
|
DWORD surfClassFlags,
|
347 |
|
|
DWORD surfaceIndex,
|
348 |
|
|
D3DX_SURFACEFORMAT* pFormat);
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
//-------------------------------------------------------------------------
|
352 |
|
|
// D3DXGetCurrentVideoMode: Retrieves the current video mode for this device.
|
353 |
|
|
// -------------------
|
354 |
|
|
//
|
355 |
|
|
// Params:
|
356 |
|
|
// [in] DWORD deviceIndex: The device being referred to.
|
357 |
|
|
// [out] D3DX_VIDMODEDESC* pVidMode: The current video mode
|
358 |
|
|
//-------------------------------------------------------------------------
|
359 |
|
|
HRESULT WINAPI
|
360 |
|
|
D3DXGetCurrentVideoMode(DWORD deviceIndex,
|
361 |
|
|
D3DX_VIDMODEDESC* pVidMode);
|
362 |
|
|
|
363 |
|
|
//-------------------------------------------------------------------------
|
364 |
|
|
// D3DXGetDeviceCaps: Lists all the capabilities of a device at a display
|
365 |
|
|
// mode.
|
366 |
|
|
// ----------------
|
367 |
|
|
//
|
368 |
|
|
// Params:
|
369 |
|
|
// [in] DWORD deviceIndex: The device being referred to.
|
370 |
|
|
// [in] D3DX_VIDMODEDESC* pDesc: If this is NULL, we will return the
|
371 |
|
|
// caps at the current display mode of
|
372 |
|
|
// the device.
|
373 |
|
|
// [out] D3DDEVICEDESC7* pD3DDeviceDesc7: D3D Caps ( NULL to ignore
|
374 |
|
|
// parameter)
|
375 |
|
|
// [out] DDCAPS7* pDDHalCaps: DDraw HAL Caps (NULL to ignore parameter)
|
376 |
|
|
// [out] DDCAPS7* pDDHelCaps: DDraw HEL Caps (NULL to ignore paramter)
|
377 |
|
|
//-------------------------------------------------------------------------
|
378 |
|
|
HRESULT WINAPI
|
379 |
|
|
D3DXGetDeviceCaps(DWORD deviceIndex,
|
380 |
|
|
D3DX_VIDMODEDESC* pVidMode,
|
381 |
|
|
D3DDEVICEDESC7* pD3DCaps,
|
382 |
|
|
DDCAPS* pDDHALCaps,
|
383 |
|
|
DDCAPS* pDDHELCaps);
|
384 |
|
|
|
385 |
|
|
//-------------------------------------------------------------------------
|
386 |
|
|
// D3DXCreateContext: Initializes the chosen device. It is the simplest init
|
387 |
|
|
// ----------------- function available. Parameters are treated the same
|
388 |
|
|
// as the matching subset of parameters in
|
389 |
|
|
// D3DXCreateContextEx, documented below.
|
390 |
|
|
// Remaining D3DXCreateContextEx parameters that are
|
391 |
|
|
// not present in D3DXCreateContext are treated as
|
392 |
|
|
// D3DX_DEFAULT. Note that multimon is not supported
|
393 |
|
|
// with D3DXCreateContext.
|
394 |
|
|
//
|
395 |
|
|
// D3DXCreateContextEx: A more advanced function to initialize the device.
|
396 |
|
|
// ------------------- Also accepts D3DX_DEFAULT for most of the parameters
|
397 |
|
|
// and then will do what D3DXCreateContext did.
|
398 |
|
|
//
|
399 |
|
|
// Note: Do not expect D3DXCreateContext(Ex) to be fail-safe (as with any
|
400 |
|
|
// API). Supported device capablilites should be used as a guide
|
401 |
|
|
// for choosing parameter values. Keep in mind that there will
|
402 |
|
|
// inevitably be some combinations of parameters that just do not work.
|
403 |
|
|
//
|
404 |
|
|
// Params:
|
405 |
|
|
// [in] DWORD deviceIndex: The device being referred to.
|
406 |
|
|
// [in] DWORD flags: The valid flags are D3DX_CONTEXT_FULLSCREEN, and
|
407 |
|
|
// D3DX_CONTEXT_OFFSCREEN. These flags cannot both
|
408 |
|
|
// be specified. If no flags are specified, the
|
409 |
|
|
// context defaults to windowed mode.
|
410 |
|
|
//
|
411 |
|
|
// [in] HWND hwnd: Device window. See note.
|
412 |
|
|
// [in] HWND hwndFocus: Window which receives keyboard messages from
|
413 |
|
|
// the device window. The device window should be
|
414 |
|
|
// a child of focus window. Useful for multimon
|
415 |
|
|
// applications. See note.
|
416 |
|
|
// NOTE:
|
417 |
|
|
// windowed:
|
418 |
|
|
// hwnd must be a valid window. hwndFocus must be NULL or
|
419 |
|
|
// D3DX_DEFAULT.
|
420 |
|
|
//
|
421 |
|
|
// fullscreen:
|
422 |
|
|
// Either hwnd or hwndFocus must be a valid window. (Both cannot
|
423 |
|
|
// be NULL or D3DX_DEFAULT). If hwnd is NULL or D3DX_DEFAULT,
|
424 |
|
|
// a default device window will be created as a child of hwndFocus.
|
425 |
|
|
//
|
426 |
|
|
// offscreen:
|
427 |
|
|
// Both hwnd and hwndFocus must be NULL or D3DX_DEFAULT
|
428 |
|
|
//
|
429 |
|
|
// [in] DWORD numColorBits: If D3DX_DEFAULT is passed for windowed mode,
|
430 |
|
|
// the current desktop's color depth is chosen.
|
431 |
|
|
// For full screen mode, D3DX_DEFAULT causes 16
|
432 |
|
|
// bit color to be used.
|
433 |
|
|
// [in] DWORD numAlphaBits: If D3DX_DEFAULT is passed, 0 is chosen.
|
434 |
|
|
// [in] DWORD numDepthbits: If D3DX_DEFAULT is passed,
|
435 |
|
|
// the highest available number of depth bits
|
436 |
|
|
// is chosen. See note.
|
437 |
|
|
// [in] DWORD numStencilBits: If D3DX_DEFAULT is passed, the highest
|
438 |
|
|
// available number of stencil bits is chosen.
|
439 |
|
|
// See note.
|
440 |
|
|
//
|
441 |
|
|
// NOTE: If both numDepthBits and numStencilBits are D3DX_DEFAULT,
|
442 |
|
|
// D3DX first picks the highest available number of stencil
|
443 |
|
|
// bits. Then, for the chosen number of stencil bits,
|
444 |
|
|
// the highest available number of depth bits is chosen.
|
445 |
|
|
// If only one of numStencilBits or numDepthBits
|
446 |
|
|
// is D3DX_DEFAULT, the highest number of bits available
|
447 |
|
|
// for this parameter is chosen out of only the formats
|
448 |
|
|
// that support the number of bits requested for the
|
449 |
|
|
// fixed parameter.
|
450 |
|
|
//
|
451 |
|
|
// [in] DWORD numBackBuffers: Number of back buffers, or D3DX_DEFAULT.
|
452 |
|
|
// See note.
|
453 |
|
|
//
|
454 |
|
|
// NOTE:
|
455 |
|
|
// windowed: D3DX_DEFAULT means 1. You must specify one back buffer.
|
456 |
|
|
//
|
457 |
|
|
// fullscreen: D3DX_DEFAULT means 1. Any number of back buffers can be
|
458 |
|
|
// specified.
|
459 |
|
|
//
|
460 |
|
|
// offscreen: D3DX_DEFAULT means 0. You cannot specify additional back
|
461 |
|
|
// buffers.
|
462 |
|
|
//
|
463 |
|
|
// [in] DWORD width: Width, in pixels, or D3DX_DEFAULT. See note.
|
464 |
|
|
// [in] DWORD height: Height, in pixels, or D3DX_DEFAULT. See note.
|
465 |
|
|
//
|
466 |
|
|
// NOTE:
|
467 |
|
|
// windowed: If either width or height is D3DX_DEFAULT, both values
|
468 |
|
|
// default to the dimensions of the client area of hwnd.
|
469 |
|
|
//
|
470 |
|
|
// fullscreen: If either width or height is D3DX_DEFAULT, width
|
471 |
|
|
// defaults to 640, and height defaults to 480.
|
472 |
|
|
//
|
473 |
|
|
// offscreen: An error is returned if either width or height is
|
474 |
|
|
// D3DX_DEFAULT.
|
475 |
|
|
//
|
476 |
|
|
// [in] DWORD refreshRate: D3DX_DEFAULT means we let ddraw choose for
|
477 |
|
|
// us. Ignored for windowed and offscreen modes.
|
478 |
|
|
// [out] LPD3DXCONTEXT* ppCtx: This is the Context object that is used for
|
479 |
|
|
// rendering on that device.
|
480 |
|
|
//
|
481 |
|
|
//-------------------------------------------------------------------------
|
482 |
|
|
HRESULT WINAPI
|
483 |
|
|
D3DXCreateContext(DWORD deviceIndex,
|
484 |
|
|
DWORD flags,
|
485 |
|
|
HWND hwnd,
|
486 |
|
|
DWORD width,
|
487 |
|
|
DWORD height,
|
488 |
|
|
LPD3DXCONTEXT* ppCtx);
|
489 |
|
|
|
490 |
|
|
HRESULT WINAPI
|
491 |
|
|
D3DXCreateContextEx(DWORD deviceIndex,
|
492 |
|
|
DWORD flags,
|
493 |
|
|
HWND hwnd,
|
494 |
|
|
HWND hwndFocus,
|
495 |
|
|
DWORD numColorBits,
|
496 |
|
|
DWORD numAlphaBits,
|
497 |
|
|
DWORD numDepthbits,
|
498 |
|
|
DWORD numStencilBits,
|
499 |
|
|
DWORD numBackBuffers,
|
500 |
|
|
DWORD width,
|
501 |
|
|
DWORD height,
|
502 |
|
|
DWORD refreshRate,
|
503 |
|
|
LPD3DXCONTEXT* ppCtx);
|
504 |
|
|
|
505 |
|
|
// The D3DXCreateContext(Ex) flags are:
|
506 |
|
|
#define D3DX_CONTEXT_FULLSCREEN 0x00000001
|
507 |
|
|
#define D3DX_CONTEXT_OFFSCREEN 0x00000002
|
508 |
|
|
|
509 |
|
|
//-------------------------------------------------------------------------
|
510 |
|
|
// D3DXGetErrorString: Prints out the error string given an hresult. Prints
|
511 |
|
|
// ------------------ Win32 as well as DX6 error messages besides the D3DX
|
512 |
|
|
// messages.
|
513 |
|
|
//
|
514 |
|
|
// Params:
|
515 |
|
|
// [in] HRESULT hr: The error code to be deciphered.
|
516 |
|
|
// [in] DWORD strLength: Length of the string passed in.
|
517 |
|
|
// [out] LPSTR pStr: The string output. This string of appropriate
|
518 |
|
|
// size needs to be passed in.
|
519 |
|
|
//-------------------------------------------------------------------------
|
520 |
|
|
void WINAPI
|
521 |
|
|
D3DXGetErrorString(HRESULT hr,
|
522 |
|
|
DWORD strLength,
|
523 |
|
|
LPSTR pStr);
|
524 |
|
|
|
525 |
|
|
//-------------------------------------------------------------------------
|
526 |
|
|
// D3DXMakeDDPixelFormat: Fills in a DDPIXELFORMAT structure based on the
|
527 |
|
|
// --------------------- D3DX surface format requested.
|
528 |
|
|
//
|
529 |
|
|
// Params:
|
530 |
|
|
// [in] D3DX_SURFACEFORMAT d3dxFormat: Surface format.
|
531 |
|
|
// [out] DDPIXELFORMAT* pddpf: Pixel format matching the given
|
532 |
|
|
// surface format.
|
533 |
|
|
//-------------------------------------------------------------------------
|
534 |
|
|
HRESULT WINAPI
|
535 |
|
|
D3DXMakeDDPixelFormat(D3DX_SURFACEFORMAT d3dxFormat,
|
536 |
|
|
DDPIXELFORMAT* pddpf);
|
537 |
|
|
|
538 |
|
|
//-------------------------------------------------------------------------
|
539 |
|
|
// D3DXMakeSurfaceFormat: Determines the surface format corresponding to
|
540 |
|
|
// --------------------- a given DDPIXELFORMAT.
|
541 |
|
|
//
|
542 |
|
|
// Params:
|
543 |
|
|
// [in] DDPIXELFORMAT* pddpf: Pixel format.
|
544 |
|
|
// Return Value:
|
545 |
|
|
// D3DX_SURFACEFORMAT: Surface format matching the given pixel format.
|
546 |
|
|
// D3DX_SF_UNKNOWN if the format is not supported
|
547 |
|
|
//-------------------------------------------------------------------------
|
548 |
|
|
D3DX_SURFACEFORMAT WINAPI
|
549 |
|
|
D3DXMakeSurfaceFormat(DDPIXELFORMAT* pddpf);
|
550 |
|
|
|
551 |
|
|
#ifdef __cplusplus
|
552 |
|
|
}
|
553 |
|
|
#endif //__cplusplus
|
554 |
|
|
|
555 |
|
|
///////////////////////////////////////////////////////////////////////////
|
556 |
|
|
// Interfaces:
|
557 |
|
|
///////////////////////////////////////////////////////////////////////////
|
558 |
|
|
|
559 |
|
|
//-------------------------------------------------------------------------
|
560 |
|
|
// ID3DXContext interface:
|
561 |
|
|
//
|
562 |
|
|
// This encapsulates all the stuff that the app might
|
563 |
|
|
// want to do at initialization time and any global control over d3d and
|
564 |
|
|
// ddraw.
|
565 |
|
|
//-------------------------------------------------------------------------
|
566 |
|
|
|
567 |
|
|
|
568 |
|
|
DECLARE_INTERFACE_(ID3DXContext, IUnknown)
|
569 |
|
|
{
|
570 |
|
|
//
|
571 |
|
|
// IUnknown methods
|
572 |
|
|
//
|
573 |
|
|
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID* ppvObj) PURE;
|
574 |
|
|
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
|
575 |
|
|
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
576 |
|
|
|
577 |
|
|
// Get the DDraw and Direct3D objects to call DirectDraw or
|
578 |
|
|
// Direct3D Immediate Mode functions.
|
579 |
|
|
// If the objects don't exist (because they have not
|
580 |
|
|
// been created for some reason) NULL is returned.
|
581 |
|
|
// All the objects returned in the following Get* functions
|
582 |
|
|
// are addref'ed. It is the application's responsibility to
|
583 |
|
|
// release them when no longer needed.
|
584 |
|
|
STDMETHOD_(LPDIRECTDRAW7,GetDD)(THIS) PURE;
|
585 |
|
|
STDMETHOD_(LPDIRECT3D7,GetD3D)(THIS) PURE;
|
586 |
|
|
STDMETHOD_(LPDIRECT3DDEVICE7,GetD3DDevice)(THIS) PURE;
|
587 |
|
|
|
588 |
|
|
// Get the various buffers that get created at the init time
|
589 |
|
|
// These are addref'ed as well. It is the application's responsibility
|
590 |
|
|
// to release them before the app quits or when it needs a resize.
|
591 |
|
|
STDMETHOD_(LPDIRECTDRAWSURFACE7,GetPrimary)(THIS) PURE;
|
592 |
|
|
STDMETHOD_(LPDIRECTDRAWSURFACE7,GetZBuffer)(THIS) PURE;
|
593 |
|
|
STDMETHOD_(LPDIRECTDRAWSURFACE7,GetBackBuffer)(THIS_ DWORD which) PURE;
|
594 |
|
|
|
595 |
|
|
// Get the associated window handles
|
596 |
|
|
STDMETHOD_(HWND,GetWindow)(THIS) PURE;
|
597 |
|
|
STDMETHOD_(HWND,GetFocusWindow)(THIS) PURE;
|
598 |
|
|
|
599 |
|
|
//
|
600 |
|
|
// Various Get methods, in case the user had specified default
|
601 |
|
|
// parameters
|
602 |
|
|
//
|
603 |
|
|
STDMETHOD(GetDeviceIndex)(THIS_
|
604 |
|
|
LPDWORD pDeviceIndex,
|
605 |
|
|
LPDWORD pHwLevel) PURE;
|
606 |
|
|
|
607 |
|
|
STDMETHOD_(DWORD, GetNumBackBuffers)(THIS) PURE;
|
608 |
|
|
|
609 |
|
|
STDMETHOD(GetNumBits)(THIS_
|
610 |
|
|
LPDWORD pColorBits,
|
611 |
|
|
LPDWORD pDepthBits,
|
612 |
|
|
LPDWORD pAlphaBits,
|
613 |
|
|
LPDWORD pStencilBits) PURE;
|
614 |
|
|
|
615 |
|
|
STDMETHOD(GetBufferSize)(THIS_
|
616 |
|
|
LPDWORD pWidth,
|
617 |
|
|
LPDWORD pHeight) PURE;
|
618 |
|
|
|
619 |
|
|
// Get the flags that were used to create this context
|
620 |
|
|
STDMETHOD_(DWORD, GetCreationFlags)(THIS) PURE;
|
621 |
|
|
STDMETHOD_(DWORD, GetRefreshRate)(THIS) PURE;
|
622 |
|
|
|
623 |
|
|
// Restoring surfaces in case stuff is lost
|
624 |
|
|
STDMETHOD(RestoreSurfaces)(THIS) PURE;
|
625 |
|
|
|
626 |
|
|
// Resize all the buffers to the new width and height
|
627 |
|
|
STDMETHOD(Resize)(THIS_ DWORD width, DWORD height) PURE;
|
628 |
|
|
|
629 |
|
|
// Update the frame using a flip or a blit,
|
630 |
|
|
// If the D3DX_UPDATE_NOVSYNC flag is set, blit is used if the
|
631 |
|
|
// driver cannot flip without waiting for vsync in full-screen mode.
|
632 |
|
|
STDMETHOD(UpdateFrame)(THIS_ DWORD flags) PURE;
|
633 |
|
|
|
634 |
|
|
// Render a string at the specified coordinates, with the specified
|
635 |
|
|
// colour. This is only provided as a convenience for
|
636 |
|
|
// debugging/information during development.
|
637 |
|
|
// topLeftX and topLeftY represent the location of the top left corner
|
638 |
|
|
// of the string, on the render target.
|
639 |
|
|
// The coordinate and color parameters each have a range of 0.0-1.0
|
640 |
|
|
STDMETHOD(DrawDebugText)(THIS_
|
641 |
|
|
float topLeftX,
|
642 |
|
|
float topLeftY,
|
643 |
|
|
D3DCOLOR color,
|
644 |
|
|
LPSTR pString) PURE;
|
645 |
|
|
|
646 |
|
|
// Clears to the current viewport
|
647 |
|
|
// The following are the valid flags:
|
648 |
|
|
// D3DCLEAR_TARGET (to clear the render target )
|
649 |
|
|
// D3DCLEAR_ZBUFFER (to clear the depth-buffer )
|
650 |
|
|
// D3DCLEAR_STENCIL (to clear the stencil-buffer )
|
651 |
|
|
STDMETHOD(Clear)(THIS_ DWORD ClearFlags) PURE;
|
652 |
|
|
|
653 |
|
|
STDMETHOD(SetClearColor)(THIS_ D3DCOLOR color ) PURE;
|
654 |
|
|
STDMETHOD(SetClearDepth)(THIS_ float z) PURE;
|
655 |
|
|
STDMETHOD(SetClearStencil)(THIS_ DWORD stencil) PURE;
|
656 |
|
|
};
|
657 |
|
|
|
658 |
|
|
|
659 |
|
|
//-------------------------------------------------------------------------
|
660 |
|
|
// Flags for Update member function:
|
661 |
|
|
//
|
662 |
|
|
|
663 |
|
|
// Flag to indicate that blit should be used instead of a flip
|
664 |
|
|
// for full-screen rendering.
|
665 |
|
|
#define D3DX_UPDATE_NOVSYNC (1<<0)
|
666 |
|
|
|
667 |
|
|
///////////////////////////////////////////////////////////////////////////
|
668 |
|
|
// Texturing APIs:
|
669 |
|
|
///////////////////////////////////////////////////////////////////////////
|
670 |
|
|
#ifdef __cplusplus
|
671 |
|
|
extern "C" {
|
672 |
|
|
#endif //__cplusplus
|
673 |
|
|
|
674 |
|
|
//-------------------------------------------------------------------------
|
675 |
|
|
// D3DXCheckTextureRequirements: Return information about texture creation
|
676 |
|
|
// ---------------------------- (used by CreateTexture, CreateTextureFromFile
|
677 |
|
|
// and CreateCubeMapTexture)
|
678 |
|
|
//
|
679 |
|
|
// Parameters:
|
680 |
|
|
//
|
681 |
|
|
// pd3dDevice
|
682 |
|
|
// The D3D device with which the texture is going to be used.
|
683 |
|
|
// pFlags
|
684 |
|
|
// allows specification of D3DX_TEXTURE_NOMIPMAP
|
685 |
|
|
// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation
|
686 |
|
|
// is not supported.
|
687 |
|
|
// pWidth
|
688 |
|
|
// width in pixels or NULL
|
689 |
|
|
// returns corrected width
|
690 |
|
|
// pHeight
|
691 |
|
|
// height in pixels or NULL
|
692 |
|
|
// returns corrected height
|
693 |
|
|
// pPixelFormat
|
694 |
|
|
// surface format
|
695 |
|
|
// returns best match to input format
|
696 |
|
|
//
|
697 |
|
|
// Notes: 1. Unless the flags is set to specifically prevent creating
|
698 |
|
|
// mipmaps, mipmaps are generated all the way till 1x1 surface.
|
699 |
|
|
// 2. width, height and pixelformat are altered based on available
|
700 |
|
|
// hardware. For example:
|
701 |
|
|
// a. Texture dimensions may be required to be powers of 2
|
702 |
|
|
// b. We may require width == height for some devices
|
703 |
|
|
// c. If PixelFormat is unavailable, a best fit is made
|
704 |
|
|
//-------------------------------------------------------------------------
|
705 |
|
|
HRESULT WINAPI
|
706 |
|
|
D3DXCheckTextureRequirements( LPDIRECT3DDEVICE7 pd3dDevice,
|
707 |
|
|
LPDWORD pFlags,
|
708 |
|
|
LPDWORD pWidth,
|
709 |
|
|
LPDWORD pHeight,
|
710 |
|
|
D3DX_SURFACEFORMAT* pPixelFormat);
|
711 |
|
|
|
712 |
|
|
//-------------------------------------------------------------------------
|
713 |
|
|
// D3DXCreateTexture: Create an empty texture object
|
714 |
|
|
// -----------------
|
715 |
|
|
//
|
716 |
|
|
// Parameters:
|
717 |
|
|
//
|
718 |
|
|
// pd3dDevice
|
719 |
|
|
// The D3D device with which the texture is going to be used.
|
720 |
|
|
// pFlags
|
721 |
|
|
// allows specification of D3DX_TEXTURE_NOMIPMAP
|
722 |
|
|
// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation
|
723 |
|
|
// is not supported. Additionally, D3DX_TEXTURE_STAGE<n> can be specified
|
724 |
|
|
// to indicate which texture stage the texture is for e.g.
|
725 |
|
|
// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture
|
726 |
|
|
// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are
|
727 |
|
|
// set.
|
728 |
|
|
// pWidth
|
729 |
|
|
// width in pixels; 0 or NULL is unacceptable
|
730 |
|
|
// returns corrected width
|
731 |
|
|
// pHeight
|
732 |
|
|
// height in pixels; 0 or NULL is unacceptable
|
733 |
|
|
// returns corrected height
|
734 |
|
|
// pPixelFormat
|
735 |
|
|
// surface format. D3DX_DEFAULT is unacceptable.
|
736 |
|
|
// returns actual format that was used
|
737 |
|
|
// pDDPal
|
738 |
|
|
// DDraw palette that is set (if present) on paletted surfaces.
|
739 |
|
|
// It is ignored even if it is set, for non-paletted surfaces.
|
740 |
|
|
// ppDDSurf
|
741 |
|
|
// The ddraw surface that will be created
|
742 |
|
|
// pNumMipMaps
|
743 |
|
|
// the number of mipmaps actually generated
|
744 |
|
|
//
|
745 |
|
|
// Notes: See notes for D3DXCheckTextureRequirements.
|
746 |
|
|
//-------------------------------------------------------------------------
|
747 |
|
|
HRESULT WINAPI
|
748 |
|
|
D3DXCreateTexture( LPDIRECT3DDEVICE7 pd3dDevice,
|
749 |
|
|
LPDWORD pFlags,
|
750 |
|
|
LPDWORD pWidth,
|
751 |
|
|
LPDWORD pHeight,
|
752 |
|
|
D3DX_SURFACEFORMAT* pPixelFormat,
|
753 |
|
|
LPDIRECTDRAWPALETTE pDDPal,
|
754 |
|
|
LPDIRECTDRAWSURFACE7* ppDDSurf,
|
755 |
|
|
LPDWORD pNumMipMaps);
|
756 |
|
|
|
757 |
|
|
//-------------------------------------------------------------------------
|
758 |
|
|
// D3DXCreateCubeMapTexture: Create blank cube-map texture
|
759 |
|
|
// ------------------------
|
760 |
|
|
//
|
761 |
|
|
// Parameters:
|
762 |
|
|
//
|
763 |
|
|
// pd3dDevice
|
764 |
|
|
// The D3D device with which the texture is going to be used.
|
765 |
|
|
// pFlags
|
766 |
|
|
// allows specification of D3DX_TEXTURE_NOMIPMAP
|
767 |
|
|
// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation
|
768 |
|
|
// is not supported. Additionally, D3DX_TEXTURE_STAGE<n> can be specified
|
769 |
|
|
// to indicate which texture stage the texture is for e.g.
|
770 |
|
|
// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture
|
771 |
|
|
// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are
|
772 |
|
|
// set.
|
773 |
|
|
// cubefaces
|
774 |
|
|
// allows specification of which faces of the cube-map to generate.
|
775 |
|
|
// D3DX_DEFAULT, 0, and DDSCAPS2_CUBEMAP_ALLFACES all mean
|
776 |
|
|
// "create all 6 faces of the cubemap". Any combination of
|
777 |
|
|
// DDSCAPS2_CUBEMAP_POSITIVEX, DDSCAPS2_CUBEMAP_NEGATIVEX,
|
778 |
|
|
// DDSCAPS2_CUBEMAP_POSITIVEY, DDSCAPS2_CUBEMAP_NEGATIVEY,
|
779 |
|
|
// DDSCAPS2_CUBEMAP_POSITIVEZ, or DDSCAPS2_CUBEMAP_NEGATIVEZ, is
|
780 |
|
|
// valid.
|
781 |
|
|
// colorEmptyFaces
|
782 |
|
|
// allows specification of the color to use for the faces that were not
|
783 |
|
|
// specified in the cubefaces parameter.
|
784 |
|
|
// pWidth
|
785 |
|
|
// width in pixels; 0 or NULL is unacceptable
|
786 |
|
|
// returns corrected width
|
787 |
|
|
// pHeight
|
788 |
|
|
// height in pixels; 0 or NULL is unacceptable
|
789 |
|
|
// returns corrected height
|
790 |
|
|
// pPixelFormat
|
791 |
|
|
// surface format. D3DX_DEFAULT is unacceptable.
|
792 |
|
|
// returns actual format that was used
|
793 |
|
|
// pDDPal
|
794 |
|
|
// DDraw palette that is set (if present) on paletted surfaces.
|
795 |
|
|
// It is ignored even if it is set, for non-paletted surfaces.
|
796 |
|
|
// ppDDSurf
|
797 |
|
|
// the ddraw surface that will be created
|
798 |
|
|
// pNumMipMaps
|
799 |
|
|
// the number of mipmaps generated for a particular face of the
|
800 |
|
|
// cubemap.
|
801 |
|
|
//
|
802 |
|
|
// Notes: See notes for D3DXCheckTextureRequirements.
|
803 |
|
|
//-------------------------------------------------------------------------
|
804 |
|
|
HRESULT WINAPI
|
805 |
|
|
D3DXCreateCubeMapTexture( LPDIRECT3DDEVICE7 pd3dDevice,
|
806 |
|
|
LPDWORD pFlags,
|
807 |
|
|
DWORD cubefaces,
|
808 |
|
|
D3DCOLOR colorEmptyFaces,
|
809 |
|
|
LPDWORD pWidth,
|
810 |
|
|
LPDWORD pHeight,
|
811 |
|
|
D3DX_SURFACEFORMAT *pPixelFormat,
|
812 |
|
|
LPDIRECTDRAWPALETTE pDDPal,
|
813 |
|
|
LPDIRECTDRAWSURFACE7* ppDDSurf,
|
814 |
|
|
LPDWORD pNumMipMaps);
|
815 |
|
|
|
816 |
|
|
|
817 |
|
|
//-------------------------------------------------------------------------
|
818 |
|
|
// D3DXCreateTextureFromFile: Create a texture object from a file or from the
|
819 |
|
|
// ------------------------- resource. Only BMP and DIB are supported from the
|
820 |
|
|
// resource portion of the executable.
|
821 |
|
|
//
|
822 |
|
|
// Parameters:
|
823 |
|
|
//
|
824 |
|
|
// pd3dDevice
|
825 |
|
|
// The D3D device with which the texture is going to be used.
|
826 |
|
|
// pFlags
|
827 |
|
|
// allows specification of D3DX_TEXTURE_NOMIPMAP
|
828 |
|
|
// D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation
|
829 |
|
|
// is not supported. Additionally, D3DX_TEXTURE_STAGE<n> can be specified
|
830 |
|
|
// to indicate which texture stage the texture is for e.g.
|
831 |
|
|
// D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture
|
832 |
|
|
// stage one. Stage Zero is the default if no TEXTURE_STAGE flags are
|
833 |
|
|
// set.
|
834 |
|
|
// pWidth
|
835 |
|
|
// Width in pixels. If 0 or D3DX_DEFAULT, the width will be taken
|
836 |
|
|
// from the file
|
837 |
|
|
// returns corrected width
|
838 |
|
|
// pHeight
|
839 |
|
|
// Height in pixels. If 0 or D3DX_DEFAULT, the height will be taken
|
840 |
|
|
// from the file
|
841 |
|
|
// returns corrected height
|
842 |
|
|
// pPixelFormat
|
843 |
|
|
// If D3DX_SF_UNKNOWN is passed in, pixel format closest to the bitmap
|
844 |
|
|
// will be chosen
|
845 |
|
|
// returns actual format that was used
|
846 |
|
|
// pDDPal
|
847 |
|
|
// DDraw palette that is set (if present) on paletted surfaces.
|
848 |
|
|
// It is ignored even if it is set, for non-paletted surfaces.
|
849 |
|
|
// ppDDSurf
|
850 |
|
|
// The ddraw surface that will be created.
|
851 |
|
|
// pNumMipMaps
|
852 |
|
|
// The number of mipmaps generated.
|
853 |
|
|
// pSrcName
|
854 |
|
|
// File name. BMP, DIB, DDS, are supported.
|
855 |
|
|
//
|
856 |
|
|
// TGA is supported for the following cases: 16, 24, 32bpp direct color and 8bpp palettized.
|
857 |
|
|
// Also, 8, 16bpp grayscale is supported. RLE versions of the above
|
858 |
|
|
// TGA formats are also supported. ColorKey and Premultiplied Alpha
|
859 |
|
|
// are not currently supported for TGA files.
|
860 |
|
|
// returns created format
|
861 |
|
|
//
|
862 |
|
|
// Notes: See notes for D3DXCheckTextureRequirements.
|
863 |
|
|
//-------------------------------------------------------------------------
|
864 |
|
|
HRESULT WINAPI
|
865 |
|
|
D3DXCreateTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice,
|
866 |
|
|
LPDWORD pFlags,
|
867 |
|
|
LPDWORD pWidth,
|
868 |
|
|
LPDWORD pHeight,
|
869 |
|
|
D3DX_SURFACEFORMAT* pPixelFormat,
|
870 |
|
|
LPDIRECTDRAWPALETTE pDDPal,
|
871 |
|
|
LPDIRECTDRAWSURFACE7* ppDDSurf,
|
872 |
|
|
LPDWORD pNumMipMaps,
|
873 |
|
|
LPSTR pSrcName,
|
874 |
|
|
D3DX_FILTERTYPE filterType);
|
875 |
|
|
|
876 |
|
|
//-------------------------------------------------------------------------
|
877 |
|
|
// D3DXLoadTextureFromFile: Load from a file into a mipmap level. Doing the
|
878 |
|
|
// ----------------------- necessary color conversion and rescaling. File
|
879 |
|
|
// format support is identical to
|
880 |
|
|
// D3DXCreateTextureFromFile's.
|
881 |
|
|
//
|
882 |
|
|
// pd3dDevice
|
883 |
|
|
// The D3D device with which the texture is going to be used.
|
884 |
|
|
// pTexture
|
885 |
|
|
// a pointer to a DD7Surface which was created with either
|
886 |
|
|
// CreateTextureFromFile or CreateTexture.
|
887 |
|
|
// mipMapLevel
|
888 |
|
|
// indicates mipmap level
|
889 |
|
|
// Note:
|
890 |
|
|
// 1. Error if mipmap level doesn't exist
|
891 |
|
|
// 2. If D3DX_DEFAULT and equal number of mipmap levels exist
|
892 |
|
|
// then all the source mip-levels are loaded
|
893 |
|
|
// 3. If the source has mipmaps and the dest doesn't, use the top one
|
894 |
|
|
// 4. If the dest has miplevels and source doesn't, we expand
|
895 |
|
|
// 5. If there are unequal numbers of miplevels, we expand
|
896 |
|
|
// pSrcName
|
897 |
|
|
// File name. BMP, DIB, DDS, are supported.
|
898 |
|
|
// For details on TGA support, refer to the comments for
|
899 |
|
|
// D3DXCreateTextureFromFile
|
900 |
|
|
// pSrcRect
|
901 |
|
|
// the source rectangle or null (whole surface)
|
902 |
|
|
// pDestRect
|
903 |
|
|
// the destination rectangle or null (whole surface)
|
904 |
|
|
// filterType
|
905 |
|
|
// filter used for mipmap generation
|
906 |
|
|
//-------------------------------------------------------------------------
|
907 |
|
|
HRESULT WINAPI
|
908 |
|
|
D3DXLoadTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice,
|
909 |
|
|
LPDIRECTDRAWSURFACE7 pTexture,
|
910 |
|
|
DWORD mipMapLevel,
|
911 |
|
|
LPSTR pSrcName,
|
912 |
|
|
RECT* pSrcRect,
|
913 |
|
|
RECT* pDestRect,
|
914 |
|
|
D3DX_FILTERTYPE filterType);
|
915 |
|
|
|
916 |
|
|
//-------------------------------------------------------------------------
|
917 |
|
|
// D3DXLoadTextureFromSurface: Load from a DDraw Surface into a mipmap level.
|
918 |
|
|
// -------------------------- Doing the necessary color conversion.
|
919 |
|
|
//
|
920 |
|
|
// pd3dDevice
|
921 |
|
|
// The D3D device with which the texture is going to be used.
|
922 |
|
|
// pTexture
|
923 |
|
|
// a pointer to a DD7Surface which was created with either
|
924 |
|
|
// CreateTextureFromFile or CreateTexture.
|
925 |
|
|
// mipMapLevel
|
926 |
|
|
// indicates mipmap level
|
927 |
|
|
// Note:
|
928 |
|
|
// 1. Error if mipmap level doesn't exist
|
929 |
|
|
// 2. If D3DX_DEFAULT and equal number of mipmap levels exist
|
930 |
|
|
// then all the source mip-levels are loaded
|
931 |
|
|
// 3. If the source has mipmaps and the dest doesn't, use the top one
|
932 |
|
|
// 4. If the dest has miplevels and source doesn't, we expand
|
933 |
|
|
// 5. If there are unequal numbers of miplevels, we expand
|
934 |
|
|
// pSurfaceSrc
|
935 |
|
|
// the source surface
|
936 |
|
|
// pSrcRect
|
937 |
|
|
// the source rectangle or null (whole surface)
|
938 |
|
|
// pDestRect
|
939 |
|
|
// the destination rectangle or null (whole surface)
|
940 |
|
|
// filterType
|
941 |
|
|
// filter used for mipmap generation
|
942 |
|
|
//-------------------------------------------------------------------------
|
943 |
|
|
HRESULT WINAPI
|
944 |
|
|
D3DXLoadTextureFromSurface( LPDIRECT3DDEVICE7 pd3dDevice,
|
945 |
|
|
LPDIRECTDRAWSURFACE7 pTexture,
|
946 |
|
|
DWORD mipMapLevel,
|
947 |
|
|
LPDIRECTDRAWSURFACE7 pSurfaceSrc,
|
948 |
|
|
RECT* pSrcRect,
|
949 |
|
|
RECT* pDestRect,
|
950 |
|
|
D3DX_FILTERTYPE filterType);
|
951 |
|
|
|
952 |
|
|
//-------------------------------------------------------------------------
|
953 |
|
|
// D3DXLoadTextureFromMemory: Load a mip level from memory. Doing the necessary
|
954 |
|
|
// ------------------------- color conversion.
|
955 |
|
|
//
|
956 |
|
|
// pd3dDevice
|
957 |
|
|
// The D3D device with which the texture is going to be used.
|
958 |
|
|
// pTexture
|
959 |
|
|
// a pointer to a DD7Surface which was created with either
|
960 |
|
|
// CreateTextureFromFile or CreateTexture.
|
961 |
|
|
// mipMapLevel
|
962 |
|
|
// indicates mipmap level
|
963 |
|
|
// Note:
|
964 |
|
|
// 1. Error if mipmap level doesn't exist
|
965 |
|
|
// 2. If D3DX_DEFAULT and equal number of mipmap levels exist
|
966 |
|
|
// then all the source mip-levels are loaded
|
967 |
|
|
// 3. If the source has mipmaps and the dest doesn't, use the top one
|
968 |
|
|
// 4. If the dest has miplevels and source doesn't, we expand
|
969 |
|
|
// 5. If there are unequal numbers of miplevels, we expand
|
970 |
|
|
// pMemory
|
971 |
|
|
// pointer to source memory from which the texture will be loaded
|
972 |
|
|
// pDDPal
|
973 |
|
|
// DirectDraw Palette, that the app passes in optionally if the memory is
|
974 |
|
|
// supposed to be paletteized.
|
975 |
|
|
// srcPixelFormat
|
976 |
|
|
// PixelFormat of the source.
|
977 |
|
|
// srcPitch
|
978 |
|
|
// The pitch of the memory or D3DX_DEFAULT (based on srcPixelFormat)
|
979 |
|
|
// pDestRect
|
980 |
|
|
// The destination rectangle or null (whole surface)
|
981 |
|
|
// filterType
|
982 |
|
|
// filter used for mipmap generation
|
983 |
|
|
//
|
984 |
|
|
// Assumptions: The source (memory) is loaded in full
|
985 |
|
|
//-------------------------------------------------------------------------
|
986 |
|
|
HRESULT WINAPI
|
987 |
|
|
D3DXLoadTextureFromMemory( LPDIRECT3DDEVICE7 pd3dDevice,
|
988 |
|
|
LPDIRECTDRAWSURFACE7 pTexture,
|
989 |
|
|
DWORD mipMapLevel,
|
990 |
|
|
LPVOID pMemory,
|
991 |
|
|
LPDIRECTDRAWPALETTE pDDPal,
|
992 |
|
|
D3DX_SURFACEFORMAT srcPixelFormat,
|
993 |
|
|
DWORD srcPitch,
|
994 |
|
|
RECT* pDestRect,
|
995 |
|
|
D3DX_FILTERTYPE filterType);
|
996 |
|
|
|
997 |
|
|
#ifdef __cplusplus
|
998 |
|
|
}
|
999 |
|
|
#endif //__cplusplus
|
1000 |
|
|
|
1001 |
|
|
//-------------------------------------------------------------------------
|
1002 |
|
|
// Flags for texture create functions; applies to
|
1003 |
|
|
// D3DXCreateTexture, D3DXCreateCubeMapTexture and D3DXCreateTextureFromFile.
|
1004 |
|
|
//
|
1005 |
|
|
|
1006 |
|
|
// Flag to indicate that mipmap generation is not desired.
|
1007 |
|
|
#define D3DX_TEXTURE_NOMIPMAP (1 << 8)
|
1008 |
|
|
|
1009 |
|
|
// Flags to indicate which texture stage the texture is
|
1010 |
|
|
// intended for use with. Specifying the stage is necessary at
|
1011 |
|
|
// texture creation time for HW devices that expose the
|
1012 |
|
|
// D3DDEVCAPS_SEPARATETEXTUREMEMORIES bit in their D3DDEVICEDESC
|
1013 |
|
|
// structure.
|
1014 |
|
|
#define D3DX_TEXTURE_STAGE0 (0)
|
1015 |
|
|
#define D3DX_TEXTURE_STAGE1 (1)
|
1016 |
|
|
#define D3DX_TEXTURE_STAGE2 (2)
|
1017 |
|
|
#define D3DX_TEXTURE_STAGE3 (3)
|
1018 |
|
|
#define D3DX_TEXTURE_STAGE4 (4)
|
1019 |
|
|
#define D3DX_TEXTURE_STAGE5 (5)
|
1020 |
|
|
#define D3DX_TEXTURE_STAGE6 (6)
|
1021 |
|
|
#define D3DX_TEXTURE_STAGE7 (7)
|
1022 |
|
|
|
1023 |
|
|
// Mask to extract the texture stage value out of the flags to
|
1024 |
|
|
// the texture create functions.
|
1025 |
|
|
#define D3DX_TEXTURE_STAGE_MASK (0x7)
|
1026 |
|
|
|
1027 |
|
|
#endif //__D3DXCORE_H__
|