本文整理汇总了C++中LPDIRECT3DDEVICE8::CreateVertexShader方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE8::CreateVertexShader方法的具体用法?C++ LPDIRECT3DDEVICE8::CreateVertexShader怎么用?C++ LPDIRECT3DDEVICE8::CreateVertexShader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE8
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE8::CreateVertexShader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_CreateVertexShader
//-----------------------------------------------------------------------------
// Name: XBUtil_CreateVertexShader()
// Desc: Creates a file-based vertex shader
//-----------------------------------------------------------------------------
HRESULT XBUtil_CreateVertexShader( LPDIRECT3DDEVICE8 pd3dDevice,
const CHAR* strFilename,
const DWORD* pdwVertexDecl,
DWORD* pdwVertexShader )
{
HRESULT hr;
// Find the media file
CHAR strShaderPath[512];
if( FAILED( hr = XBUtil_FindMediaFile( strShaderPath, strFilename ) ) )
return hr;
// Open the vertex 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;
// Allocate memory to read the vertex shader file
DWORD dwSize = GetFileSize(hFile, NULL);
BYTE* pData = new BYTE[dwSize+4];
if( NULL == pData )
return E_FAIL;
ZeroMemory( pData, dwSize+4 );
// Read the pre-compiled vertex shader microcode
ReadFile(hFile, pData, dwSize, &dwNumBytesRead, 0);
// Create the vertex shader
hr = pd3dDevice->CreateVertexShader( pdwVertexDecl, (const DWORD*)pData,
pdwVertexShader, 0 );
// Cleanup and return
CloseHandle(hFile);
delete [] pData;
return hr;
}
示例3: InitValid
HRESULT SampleShaderPluginVertexShader::InitValid(Mesh *mesh, INode *node)
{
HRESULT hr = S_OK;
m_pINode = node;
// Create a vertex shader for doing the effect
LPD3DXBUFFER *ppCode = &pCode;
LPD3DXBUFFER pBuffer = NULL;
//! VertexShader Declarations
//! VertexShader Constants
Constants.SetCount(20);
//! set up the material vertex color ...
D3DMATERIAL8 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
mtrl.Diffuse.r = mtrl.Ambient.r = m_MtlColor.r;
mtrl.Diffuse.g = mtrl.Ambient.g = m_MtlColor.g;
mtrl.Diffuse.b = mtrl.Ambient.b = m_MtlColor.b;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
pd3dDevice->SetMaterial( &mtrl );
pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );
/*!
* D3DXAssembleShader
* Assembles an ASCII description of a shader into binary form, where the shader source is in memory.
*
* @param pSrcData : [in] Pointer to the source code.
* @param SrcDataLen : [in] Size of the source code, in bytes.
* @param Flags : [in] A combination of the following flags, specifying assembly options.
* D3DXASM_DEBUG Inserts debugging information as comments in the assembled shader.
* D3DXASM_SKIPVALIDATION Do not validate the generated code against known capabilities and constraints. This option is recommended only when assembling a shader you know will function (that is, the shader has been assembled before without this option.)
* @param ppConstants : [out] Returns a pointer to an ID3DXBuffer interface, representing the returned constant declarations. These constants are returned as a vertex shader declaration fragment. It is up to the application to insert the contents of this buffer into their declaration. For pixel shaders this parameter is meaningless because constant declarations are included in the assembled shader. This parameter is ignored if it is NULL.
* @param ppCompiledShader : [out] Returns a pointer to an ID3DXBuffer interface, representing the returned compiled object code. This parameter is ignored if it is NULL.
* @param ppCompilationErrors : [out] Returns a pointer to an ID3DXBuffer interface, representing the returned ASCII error messages. This parameter is ignored if it is NULL.
*
* @return HRESULT :
HRESULT D3DXAssembleShader(
LPCVOID pSrcData,
UINT SrcDataLen,
DWORD Flags,
LPD3DXBUFFER* ppConstants,
LPD3DXBUFFER* ppCompiledShader,
LPD3DXBUFFER* ppCompilationErrors
);
*/
//! Specify the vertex format that the vertex shader will be using for doing the effect
DWORD dwVertexFormatDefinition[] =
{
D3DVSD_STREAM( 0 ), D3DVSD_REG( 0, D3DVSDT_FLOAT3 ), // v0 = Position
D3DVSD_REG( 1, D3DVSDT_FLOAT3 ), // v1 = Normal
D3DVSD_END()
};
#if 0
TCHAR *vertexShaderPath = FindMapFile("ambient.njv");
hr = D3DXAssembleShaderFromFile(vertexShaderPath , 0, NULL, &pCode, NULL);
#else
hr = D3DXAssembleShader( SurfaceShader , sizeof(SurfaceShader)-1 , 0 , NULL , &pCode , NULL );
#endif
hr = pd3dDevice->CreateVertexShader(dwVertexFormatDefinition,(LPDWORD)pCode->GetBufferPointer(), &dwVertexShader, 0);
initDone = true;
return hr;
}