Microsoft DirectX 8.1 (vertex shader versions 1.0, 1.1) |
Provides a method to specify the type and version of the shader code.
vs.mainVer.subVer
This instruction is required to be at the beginning of all vertex shaders.
This example illustrates an example shader file. // shader file vs.1.0 ; declare version number m4x4 oPos, v0, c0 ; transform vertices by view/projection matrix mov oD0, c4 ; output constant colorThe output vertex color is green and is shown below.
// Additional code is required to initialize the constant registers // as shown below. D3DXMATRIX mat, matView, matProj; D3DXMatrixMultiply(&mat, &matView, &matProj); D3DXMatrixTranspose(&mat, &mat); // set C0 with the view and projection matrix m_pd3dDevice->SetVertexShaderConstant(0, &mat, 4); // set register c4 float colorGreen[4] = {0, 1, 0, 0}; m_pd3dDevice->SetVertexShaderConstant(4, &colorGreen, 1); // The first SetVertexShaderConstant method binds the C0 register with the first // row of the view/projection matrix (rows 2, 3 and 4 are bound to registers C2, C3 and // c4 also). The m4x4 instruction (in the shader file) loads the data. // The second SetVertexShaderConstant method binds the C4 register with // the color green.