本文整理汇总了C++中ProgramFactory::PopFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramFactory::PopFlags方法的具体用法?C++ ProgramFactory::PopFlags怎么用?C++ ProgramFactory::PopFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgramFactory
的用法示例。
在下文中一共展示了ProgramFactory::PopFlags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mPVWMatrix
SimpleBumpMapEffect::SimpleBumpMapEffect(ProgramFactory& factory,
Environment const& environment, bool& created)
:
mPVWMatrix(nullptr)
{
created = false;
// Load and compile the shaders.
std::string path = environment.GetPath("SimpleBumpMap.hlsl");
#if !defined(GTE_DEV_OPENGL)
// The flags are chosen to allow you to debug the shaders through MSVS.
// The menu path is "Debug | Graphics | Start Diagnostics" (ALT+F5).
factory.PushFlags();
factory.flags =
D3DCOMPILE_ENABLE_STRICTNESS |
D3DCOMPILE_IEEE_STRICTNESS |
D3DCOMPILE_DEBUG |
D3DCOMPILE_SKIP_OPTIMIZATION;
#endif
mProgram = factory.CreateFromFiles(path, path, "");
#if !defined(GTE_DEV_OPENGL)
factory.PopFlags();
#endif
if (!mProgram)
{
// The program factory will generate Log* messages.
return;
}
// Load the textures.
path = environment.GetPath("Bricks.png");
mBaseTexture.reset(WICFileIO::Load(path, true));
mBaseTexture->AutogenerateMipmaps();
path = environment.GetPath("BricksNormal.png");
mNormalTexture.reset(WICFileIO::Load(path, true));
mNormalTexture->AutogenerateMipmaps();
// Create the shader constants.
mPVWMatrixConstant =
std::make_shared<ConstantBuffer>(sizeof(Matrix4x4<float>), true);
mPVWMatrix = mPVWMatrixConstant->Get<Matrix4x4<float>>();
*mPVWMatrix = Matrix4x4<float>::Identity();
// Create the texture sampler for mipmapping.
mCommonSampler = std::make_shared<SamplerState>();
mCommonSampler->filter = SamplerState::MIN_L_MAG_L_MIP_L;
mCommonSampler->mode[0] = SamplerState::WRAP;
mCommonSampler->mode[1] = SamplerState::WRAP;
// Set the resources for the shaders.
std::shared_ptr<VertexShader> vshader = mProgram->GetVShader();
std::shared_ptr<PixelShader> pshader = mProgram->GetPShader();
vshader->Set("PVWMatrix", mPVWMatrixConstant);
pshader->Set("baseTexture", mBaseTexture);
pshader->Set("normalTexture", mNormalTexture);
pshader->Set("commonSampler", mCommonSampler);
created = true;
}
示例2: mPVWMatrix
BlendedTerrainEffect::BlendedTerrainEffect(ProgramFactory& factory,
Environment const& environment, bool& created)
:
mPVWMatrix(nullptr),
mFlowDirection(nullptr),
mPowerFactor(nullptr)
{
created = false;
// Load and compile the shaders.
std::string path = environment.GetPath("BlendedTerrain.hlsl");
#if !defined(GTE_DEV_OPENGL)
// The flags are chosen to allow you to debug the shaders through MSVS.
// The menu path is "Debug | Graphics | Start Diagnostics" (ALT+F5).
factory.PushFlags();
factory.flags =
D3DCOMPILE_ENABLE_STRICTNESS |
D3DCOMPILE_IEEE_STRICTNESS |
D3DCOMPILE_DEBUG |
D3DCOMPILE_SKIP_OPTIMIZATION;
#endif
mProgram = factory.CreateFromFiles(path, path, "");
#if !defined(GTE_DEV_OPENGL)
factory.PopFlags();
#endif
if (!mProgram)
{
// The program factory will generate Log* messages.
return;
}
// Load the textures.
path = environment.GetPath("BTGrass.png");
mGrassTexture.reset(WICFileIO::Load(path, true));
mGrassTexture->AutogenerateMipmaps();
path = environment.GetPath("BTStone.png");
mStoneTexture.reset(WICFileIO::Load(path, true));
mStoneTexture->AutogenerateMipmaps();
path = environment.GetPath("BTCloud.png");
mCloudTexture.reset(WICFileIO::Load(path, true));
mCloudTexture->AutogenerateMipmaps();
// Create the shader constants.
mPVWMatrixConstant = std::make_shared<ConstantBuffer>(sizeof(Matrix4x4<float>), true);
mPVWMatrix = mPVWMatrixConstant->Get<Matrix4x4<float>>();
*mPVWMatrix = Matrix4x4<float>::Identity();
mFlowDirectionConstant = std::make_shared<ConstantBuffer>(sizeof(Vector2<float>), true);
mFlowDirection = mFlowDirectionConstant->Get<Vector2<float>>();
*mFlowDirection = { 0.0f, 0.0f };
mPowerFactorConstant = std::make_shared<ConstantBuffer>(sizeof(float), true);
mPowerFactor = mPowerFactorConstant->Get<float>();
*mPowerFactor = 1.0f;
// Create a 1-dimensional texture whose intensities are proportional to
// height.
unsigned int const numTexels = 256;
mBlendTexture = std::make_shared<Texture1>(DF_R8_UNORM, numTexels);
unsigned char* texels = mBlendTexture->Get<unsigned char>();
for (unsigned int i = 0; i < numTexels; ++i, ++texels)
{
*texels = static_cast<unsigned char>(i);
}
// Create the texture samplers. The common sampler uses trilinear
// interpolation (mipmapping). The blend sample uses bilinear
// interpolation (no mipmapping).
mCommonSampler = std::make_shared<SamplerState>();
mCommonSampler->filter = SamplerState::MIN_L_MAG_L_MIP_L;
mCommonSampler->mode[0] = SamplerState::WRAP;
mCommonSampler->mode[1] = SamplerState::WRAP;
mBlendSampler = std::make_shared<SamplerState>();
mBlendSampler->filter = SamplerState::MIN_L_MAG_L_MIP_P;
mBlendSampler->mode[0] = SamplerState::WRAP;
// Set the resources for the shaders.
std::shared_ptr<VertexShader> vshader = mProgram->GetVShader();
std::shared_ptr<PixelShader> pshader = mProgram->GetPShader();
vshader->Set("PVWMatrix", mPVWMatrixConstant);
vshader->Set("FlowDirection", mFlowDirectionConstant);
pshader->Set("PowerFactor", mPowerFactorConstant);
pshader->Set("grassTexture", mGrassTexture);
pshader->Set("stoneTexture", mStoneTexture);
pshader->Set("blendTexture", mBlendTexture);
pshader->Set("cloudTexture", mCloudTexture);
pshader->Set("commonSampler", mCommonSampler);
pshader->Set("blendSampler", mBlendSampler);
created = true;
}