|
一个简单例子表示fixed functional VS/Assemble VS/HLSI VS的例子(3) D3DVERTEXELEMENT9 decl[] = { //for Position { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,D3DDECLUSAGE_POSITION, 0 }, // for color { 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT,D3DDECLUSAGE_COLOR, 0 }, D3DDECL_END() }; #if VS_TYPE == 1
// shader declaration const char* strVertexShader = "vs_3_0 // version instruction\n" // input register declaration "dcl_position v0 // define position data in register v0\n" "dcl_color v1 // define color\n" // output register declaration "dcl_position0 o7 // \n" "dcl_color o3 // output color\n" // ALU(Shader function/function declaration) "m4x4 o7, v0, c0 // transform vertices by world/view/projection matrix\n" "mov o3, v1 //\n" ";//\n" ""; LPDIRECT3DVERTEXSHADER9 g_pVS = NULL; #endif #if VS_TYPE == 2 const char* strVertexShader = // vertex shader declaration "float4x4 WorldViewProj : WORLDVIEWPROJ;\n" "struct VS_OUTPUT\n" "{\n" "float4 Pos : POSITION;\n" "float4 Diff : COLOR0;\n" "};\n" "\n" "VS_OUTPUT VS_Matrices(float4 inPos : POSITION,float4 inDiff : COLOR0)\n" "{\n" "VS_OUTPUT Out = (VS_OUTPUT)0;\n" "\n" " Out.Pos = mul(inPos, WorldViewProj);\n" " Out.Diff = inDiff;\n" " return Out;\n" "}\n" ""; LPDIRECT3DVERTEXSHADER9 g_pVS = NULL; #endif //----------------------------------------------------------------------------- // Name: InitD3D() // Desc: Initializes Direct3D //----------------------------------------------------------------------------- HRESULT InitD3D( HWND hWnd ) { // Create the D3D object. if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return E_FAIL; // Set up the structure used to create the D3DDevice D3DPRESENT_PARAMETERS d3dpp;
|