DXUT 加载纹理Load the texture for the screen quad

1.定义纹理资源

ID3D10ShaderResourceView*           g_pScreenRV[2] = { NULL };

ID3D10EffectShaderResourceVariable* g_ptxToonVariable = NULL;

 2.定义加载文件名 并加载

// Load the texture for the screen quad

WCHAR str[MAX_PATH];

    WCHAR* szScreenTextures[] =
    {
        L"misc\\MarbleClouds.dds",
        L"misc\\NormTest.dds"
    };


    for( int i = 0; i < 2; i++ )
    {
        V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, szScreenTextures[i] ) );
        V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pScreenRV[i], NULL ) );

    }

3.设置纹理资源

    g_ptxToonVariable ->SetResource( g_pScreenRV[0] );

4.在Dsetory处安全释放资源

   for( int i = 0; i < 2; i++ )
    {
        SAFE_RELEASE( g_pScreenRV[i] );
    }

发布了9 篇原创文章 · 获赞 2 · 访问量 6630

猜你喜欢

转载自blog.csdn.net/kz2313456/article/details/78349979