User Defined Type Syntax
Microsoft DirectX 9.0 SDK Update (October 2004)

User Defined Type Syntax


In addition to the built-in intrinsic data types, high-level shader language (HLSL) supports user-defined or custom types which follow this syntax:

Syntax

typedef [const] type id [array_suffix];

where:

typedefDeclares a name for a type.
constThis keyword explicitly marks the type as a constant.
typeIdentifies the data type, it must be one of the HLSL intrinsic data types.
idIdentifies the variable name.
array_suffixOptional array brackets identify whether the variable contains a single value, or contains an array of values.

Remarks

For compatibility with Microsoft DirectX 8.0 effects, the following types are automatically defined at super-global scope:

typedef int DWORD;
typedef float FLOAT; 
typedef vector <float, 4> VECTOR;
typedef matrix <float, 4, 4> MATRIX;
typedef string STRING;
typedef texture TEXTURE;
typedef pixelshader PIXELSHADER;
typedef vertexshader VERTEXSHADER;

These types are not case-insensitive.

For convenience, the following types are automatically defined at super-global scope. Note that the pound sign (#) represents an integer digit between 1 and 4.

typedef vector <bool, #> bool#;
typedef vector <int, #> int#;
typedef vector <half, #> half#;
typedef vector <float, #> float#;
typedef vector <double, #> double#;

typedef matrix <bool, #, #> bool#x#;
typedef matrix <int, #, #> int#x#;
typedef matrix <half, #, #> half#x#;
typedef matrix <float, #, #> float#x#;
typedef matrix <double, #, #> double#x#;


© 2004 Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center.