本文整理汇总了C++中FileLoader::GetDataPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ FileLoader::GetDataPtr方法的具体用法?C++ FileLoader::GetDataPtr怎么用?C++ FileLoader::GetDataPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileLoader
的用法示例。
在下文中一共展示了FileLoader::GetDataPtr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadSDFBuffer
void SDFShadowDemo::LoadSDFBuffer()
{
const std::wstring sdfFile = L"testScene.sdf";
FileLoader loader;
loader.Open(FileSystem::getSingleton().GetModelsFolder() + sdfFile);
auto ptr = loader.GetDataPtr();
std::string sdfText(ptr);
std::vector<std::string> lines;
pystring::splitlines(sdfText, lines);
std::string line0 = lines[0];
std::vector<std::string> line0Split;
pystring::split(line0, line0Split, " ");
m_sdfParams.x = strtof(line0Split[0].c_str(), 0);
m_sdfParams.y = strtof(line0Split[1].c_str(), 0);
m_sdfParams.z = strtof(line0Split[2].c_str(), 0);
m_sdfParams.w = strtof(lines[2].c_str(), 0);
std::string line1 = lines[1];
std::vector<std::string> line1Split;
pystring::split(line1, line1Split, " ");
m_sdfOrigin.x = strtof(line1Split[0].c_str(), 0);
m_sdfOrigin.y = strtof(line1Split[1].c_str(), 0);
m_sdfOrigin.z = strtof(line1Split[2].c_str(), 0);
const auto SDFCount = m_sdfParams.x * m_sdfParams.y * m_sdfParams.z;
for (auto i = 0; i < SDFCount; ++i)
{
f32 value = strtof(lines[3 + i].c_str(), 0);
m_sdf.push_back(value);
}
Texture3dConfigDX11 texConfig;
texConfig.SetDefaults();
texConfig.SetWidth(static_cast<u32>(m_sdfParams.x));
texConfig.SetHeight(static_cast<u32>(m_sdfParams.y));
texConfig.SetDepth(static_cast<u32>(m_sdfParams.z));
texConfig.SetFormat(DXGI_FORMAT_R32_FLOAT);
D3D11_SUBRESOURCE_DATA data;
data.pSysMem = &m_sdf[0];
data.SysMemPitch = static_cast<u32>(sizeof(f32) * m_sdfParams.x);
data.SysMemSlicePitch = static_cast<u32>(sizeof(f32) * m_sdfParams.x * m_sdfParams.y);
ShaderResourceViewConfigDX11 srvConfig;
srvConfig.SetFormat(DXGI_FORMAT_R32_FLOAT);
srvConfig.SetViewDimensions(D3D11_SRV_DIMENSION_TEXTURE3D);
D3D11_TEX3D_SRV srv;
srv.MostDetailedMip = 0;
srv.MipLevels = 1;
srvConfig.SetTexture3D(srv);
m_SDFTex3D = m_pRender->CreateTexture3D(&texConfig, &data, &srvConfig);
}