本文整理汇总了C++中LPDIRECT3DDEVICE8::CreatePixelShader方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE8::CreatePixelShader方法的具体用法?C++ LPDIRECT3DDEVICE8::CreatePixelShader怎么用?C++ LPDIRECT3DDEVICE8::CreatePixelShader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE8
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE8::CreatePixelShader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateShaders
void CreateShaders()
{
DWORD dwDecl[] =
{
D3DVSD_STREAM(0),
D3DVSD_REG(D3DVSDE_POSITION, D3DVSDT_FLOAT3),
// D3DVSD_REG( D3DVSDE_NORMAL, D3DVSDT_FLOAT3 ),
D3DVSD_END()
};
LPD3DXBUFFER pCode;
D3DXAssembleShaderFromFile("basic shader.txt"/*basic,strlen(basic)*/,0,NULL,&pCode,NULL);
d3ddevice->CreateVertexShader( dwDecl, (DWORD*)pCode->GetBufferPointer(), &basic_shader, D3DUSAGE_SOFTWAREPROCESSING );
DWORD dwDeclp[] =
{
D3DVSD_STREAM(0),
D3DVSD_REG(0, D3DVSDT_FLOAT3),
D3DVSD_REG( 1, D3DVSDT_FLOAT3 ),
D3DVSD_REG( 2, D3DVSDT_FLOAT2 ),
D3DVSD_REG( 3, D3DVSDT_FLOAT3 ),
D3DVSD_REG( 4, D3DVSDT_FLOAT3 ),
D3DVSD_END()
};
LPD3DXBUFFER pCode2;
D3DXAssembleShaderFromFile("diffuse specular bump map.txt"/*phong,strlen(phong)*/,0,NULL,&pCode2,NULL);
d3ddevice->CreateVertexShader( dwDeclp, (DWORD*)pCode2->GetBufferPointer(), &phong_shader, D3DUSAGE_SOFTWAREPROCESSING );
LPD3DXBUFFER pCode3;
D3DXAssembleShaderFromFile("basic pixel.txt",0,NULL,&pCode3,NULL);
d3ddevice->CreatePixelShader( (DWORD*)pCode3->GetBufferPointer(), &basic_pixel);
LPD3DXBUFFER pCode4;
D3DXAssembleShaderFromFile("diffuse specular bump pixel.txt",0,NULL,&pCode4,NULL);
d3ddevice->CreatePixelShader( (DWORD*)pCode4->GetBufferPointer(), &spec_pixel);
};
示例2: XBUtil_CreatePixelShader
//-----------------------------------------------------------------------------
// Name: XBUtil_CreatePixelShader()
// Desc: Creates a file-based pixel shader
//-----------------------------------------------------------------------------
HRESULT XBUtil_CreatePixelShader( LPDIRECT3DDEVICE8 pd3dDevice,
const CHAR* strFilename, DWORD* pdwPixelShader )
{
HRESULT hr;
// Find the media file
CHAR strShaderPath[512];
if( FAILED( hr = XBUtil_FindMediaFile( strShaderPath, strFilename ) ) )
return hr;
// Open the pixel shader file
HANDLE hFile;
DWORD dwNumBytesRead;
hFile = CreateFile(strShaderPath, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
if(hFile == INVALID_HANDLE_VALUE)
return E_FAIL;
// Load the pre-compiled pixel shader microcode
D3DPIXELSHADERDEF_FILE psdf;
ReadFile( hFile, &psdf, sizeof(D3DPIXELSHADERDEF_FILE), &dwNumBytesRead, NULL );
// Make sure the pixel shader is valid
if( psdf.FileID != D3DPIXELSHADERDEF_FILE_ID )
{
OUTPUT_DEBUG_STRING( "XBUtil_CreatePixelShader(): Invalid pixel shader file\n" );
return E_FAIL;
}
// Create the pixel shader
if( FAILED( hr = pd3dDevice->CreatePixelShader( &(psdf.Psd), pdwPixelShader ) ) )
{
OUTPUT_DEBUG_STRING( "XBUtil_CreatePixelShader(): Could not create pixel shader\n" );
return hr;
}
// cleanup
CloseHandle( hFile );
return S_OK;
}