Microsoft DirectX 8.1 (C++)

Constants and Parameters

Parameter declarations have the following syntax. If a const value is provided as an initial value for the parameter, its type must match type.

type id;
type id = const;

The following table lists the valid parameter types that are used for effect file parameter declarations.

Type Example id
DWORD
DWORD minVertices;
FLOAT
FLOAT fRotationAdvances;
VECTOR
VECTOR vecPoint;
MATRIX
MATRIX matIndentity;
TEXTURE
TEXTURE tex1;
VERTEXSHADER
VERTEXSHADER v1;
PIXELSHADER
PIXELSHADER p1;

Here is an example from exercise 2.

vector lhtR;	// Light Direction from app.
vector matD; 	// Object Diffuse Material Color

matrix mWld;	// World
matrix mTot;	// Total

// Load model
string XFile = "f40.x";

// Background Color
DWORD  BCLR = 0xff000000;

// No pixel shader
pixelshader pNIL; 

// Technique names for display in viewer window:
string tec0 = "Exercise 2: Vertex Shader Diffuse Lighting";

This table lists all the possible data formats for each data type.

Type Syntax Example
DWORD
* 
0x*
54573153
0xff12a1fa
FLOAT
*f 
*.f .*f *.*f
5f 
5.f .4f 4.5f
VECTOR
float
float, float
float, float, float
float, float, float, float
 4.5f 
 4.5f, 1.0f 
 4.5f, 1.0f, 2.0f 
 4.5f, 1.0f, 2.0f, 3.4f 
MATRIX
float, float, float, float,
float, float, float, float,
float, float, float, float,
float, float, float, float 
1.0f, 0.0f, 0.0f, 0.0f,
 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f 
VERTEXSHADER
DECL { ... } DECL { ... }, ASM { ... }
decl
{
   stream 0;
   float v0[3];
   float v3[3];
   ubyte v5[4];
   float v7[2];
}

decl
{
   stream 1;
   float v1[1];
   float v2[2];
   ubyte v6[3];
   float v8[4];
}
asm
{
    ps.1.0
    tex t0
    mov r0, t0
}
PIXELSHADER
ASM { ... }
asm
{
    ps.1.0
    tex t0
    mov r0, t0
}