当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECT3DDEVICE8::CreatePixelShader方法代码示例

本文整理汇总了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);

};
开发者ID:duhone,项目名称:Old3DWork,代码行数:37,代码来源:diffuse+specular+bump+map.cpp

示例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;
}
开发者ID:dpaladin,项目名称:openbor,代码行数:47,代码来源:xbutil.cpp


注:本文中的LPDIRECT3DDEVICE8::CreatePixelShader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。