📄 d3dtypes.h
字号:
/*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: d3dtypes.h
* Content: Direct3D types include file
*
***************************************************************************/
#ifndef _D3DTYPES_H_
#define _D3DTYPES_H_
#ifndef DIRECT3D_VERSION
#define DIRECT3D_VERSION 0x0700
#endif
#if (DIRECT3D_VERSION >= 0x0800)
#pragma message("should not include d3dtypes.h when compiling for DX8 or newer interfaces")
#endif
#include <windows.h>
#include <float.h>
#include "ddraw.h"
#pragma warning(disable:4201) // anonymous unions warning
#pragma pack(4)
/* D3DVALUE is the fundamental Direct3D fractional data type */
#define D3DVALP(val, prec) ((float)(val))
#define D3DVAL(val) ((float)(val))
#ifndef DX_SHARED_DEFINES
/*
* This definition is shared with other DirectX components whose header files
* might already have defined it. Therefore, we don't define this type if
* someone else already has (as indicated by the definition of
* DX_SHARED_DEFINES). We don't set DX_SHARED_DEFINES here as there are
* other types in this header that are also shared. The last of these
* shared defines in this file will set DX_SHARED_DEFINES.
*/
typedef float D3DVALUE, *LPD3DVALUE;
#endif /* DX_SHARED_DEFINES */
#define D3DDivide(a, b) (float)((double) (a) / (double) (b))
#define D3DMultiply(a, b) ((a) * (b))
typedef LONG D3DFIXED;
#ifndef RGB_MAKE
/*
* Format of CI colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | alpha | color index | fraction |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define CI_GETALPHA(ci) ((ci) >> 24)
#define CI_GETINDEX(ci) (((ci) >> 8) & 0xffff)
#define CI_GETFRACTION(ci) ((ci) & 0xff)
#define CI_ROUNDINDEX(ci) CI_GETINDEX((ci) + 0x80)
#define CI_MASKALPHA(ci) ((ci) & 0xffffff)
#define CI_MAKE(a, i, f) (((a) << 24) | ((i) << 8) | (f))
/*
* Format of RGBA colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | alpha | red | green | blue |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define RGBA_GETALPHA(rgb) ((rgb) >> 24)
#define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff)
#define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
#define RGBA_GETBLUE(rgb) ((rgb) & 0xff)
#define RGBA_MAKE(r, g, b, a) ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
/* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
* The float values must be in the range 0..1
*/
#define D3DRGB(r, g, b) \
(0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
#define D3DRGBA(r, g, b, a) \
( (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
| (((long)((g) * 255)) << 8) | (long)((b) * 255) \
)
/*
* Format of RGB colors is
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | ignored | red | green | blue |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
#define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff)
#define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
#define RGB_GETBLUE(rgb) ((rgb) & 0xff)
#define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
#define RGB_MAKE(r, g, b) ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
#define RGBA_TORGB(rgba) ((D3DCOLOR) ((rgba) & 0xffffff))
#define RGB_TORGBA(rgb) ((D3DCOLOR) ((rgb) | 0xff000000))
#endif
/*
* Flags for Enumerate functions
*/
/*
* Stop the enumeration
*/
#define D3DENUMRET_CANCEL DDENUMRET_CANCEL
/*
* Continue the enumeration
*/
#define D3DENUMRET_OK DDENUMRET_OK
typedef HRESULT (CALLBACK* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
typedef HRESULT (CALLBACK* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
typedef HRESULT (CALLBACK* LPD3DENUMPIXELFORMATSCALLBACK)(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext);
#ifndef DX_SHARED_DEFINES
/*
* This definition is shared with other DirectX components whose header files
* might already have defined it. Therefore, we don't define this type if
* someone else already has (as indicated by the definition of
* DX_SHARED_DEFINES). We don't set DX_SHARED_DEFINES here as there are
* other types in this header that are also shared. The last of these
* shared defines in this file will set DX_SHARED_DEFINES.
*/
#ifndef D3DCOLOR_DEFINED
typedef DWORD D3DCOLOR;
#define D3DCOLOR_DEFINED
#endif
typedef DWORD *LPD3DCOLOR;
#endif /* DX_SHARED_DEFINES */
typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
#ifndef D3DCOLORVALUE_DEFINED
typedef struct _D3DCOLORVALUE {
union {
D3DVALUE r;
D3DVALUE dvR;
};
union {
D3DVALUE g;
D3DVALUE dvG;
};
union {
D3DVALUE b;
D3DVALUE dvB;
};
union {
D3DVALUE a;
D3DVALUE dvA;
};
} D3DCOLORVALUE;
#define D3DCOLORVALUE_DEFINED
#endif
typedef struct _D3DCOLORVALUE *LPD3DCOLORVALUE;
#ifndef D3DRECT_DEFINED
typedef struct _D3DRECT {
union {
LONG x1;
LONG lX1;
};
union {
LONG y1;
LONG lY1;
};
union {
LONG x2;
LONG lX2;
};
union {
LONG y2;
LONG lY2;
};
} D3DRECT;
#define D3DRECT_DEFINED
#endif
typedef struct _D3DRECT *LPD3DRECT;
#ifndef DX_SHARED_DEFINES
/*
* This definition is shared with other DirectX components whose header files
* might already have defined it. Therefore, we don't define this type if
* someone else already has (as indicated by the definition of
* DX_SHARED_DEFINES).
*/
#ifndef D3DVECTOR_DEFINED
typedef struct _D3DVECTOR {
union {
D3DVALUE x;
D3DVALUE dvX;
};
union {
D3DVALUE y;
D3DVALUE dvY;
};
union {
D3DVALUE z;
D3DVALUE dvZ;
};
#if(DIRECT3D_VERSION >= 0x0500)
#if (defined __cplusplus) && (defined D3D_OVERLOADS)
public:
// =====================================
// Constructors
// =====================================
_D3DVECTOR() { }
_D3DVECTOR(D3DVALUE f);
_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
_D3DVECTOR(const D3DVALUE f[3]);
// =====================================
// Access grants
// =====================================
const D3DVALUE&operator[](int i) const;
D3DVALUE&operator[](int i);
// =====================================
// Assignment operators
// =====================================
_D3DVECTOR& operator += (const _D3DVECTOR& v);
_D3DVECTOR& operator -= (const _D3DVECTOR& v);
_D3DVECTOR& operator *= (const _D3DVECTOR& v);
_D3DVECTOR& operator /= (const _D3DVECTOR& v);
_D3DVECTOR& operator *= (D3DVALUE s);
_D3DVECTOR& operator /= (D3DVALUE s);
// =====================================
// Unary operators
// =====================================
friend _D3DVECTOR operator + (const _D3DVECTOR& v);
friend _D3DVECTOR operator - (const _D3DVECTOR& v);
// =====================================
// Binary operators
// =====================================
// Addition and subtraction
friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Scalar multiplication and division
friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
// Memberwise multiplication and division
friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Vector dominance
friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Bitwise equality
friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Length-related functions
friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v);
friend D3DVALUE Magnitude (const _D3DVECTOR& v);
// Returns vector with same direction and unit length
friend _D3DVECTOR Normalize (const _D3DVECTOR& v);
// Return min/max component of the input vector
friend D3DVALUE Min (const _D3DVECTOR& v);
friend D3DVALUE Max (const _D3DVECTOR& v);
// Return memberwise min/max of input vectors
friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
// Dot and cross product
friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
#endif
#endif /* DIRECT3D_VERSION >= 0x0500 */
} D3DVECTOR;
#define D3DVECTOR_DEFINED
#endif
typedef struct _D3DVECTOR *LPD3DVECTOR;
/*
* As this is the last of the shared defines to be defined we now set
* D3D_SHARED_DEFINES to flag that fact that this header has defined these
* types.
*/
#define DX_SHARED_DEFINES
#endif /* DX_SHARED_DEFINES */
/*
* Vertex data types supported in an ExecuteBuffer.
*/
/*
* Homogeneous vertices
*/
typedef struct _D3DHVERTEX {
DWORD dwFlags; /* Homogeneous clipping flags */
union {
D3DVALUE hx;
D3DVALUE dvHX;
};
union {
D3DVALUE hy;
D3DVALUE dvHY;
};
union {
D3DVALUE hz;
D3DVALUE dvHZ;
};
} D3DHVERTEX, *LPD3DHVERTEX;
/*
* Transformed/lit vertices
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -