本文整理汇总了C++中ProgramOptions::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramOptions::Append方法的具体用法?C++ ProgramOptions::Append怎么用?C++ ProgramOptions::Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgramOptions
的用法示例。
在下文中一共展示了ProgramOptions::Append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//--------------------------------------------------------------------------
GBuffer::GBuffer( unsigned int _width,
unsigned int _height)
{
// Initialize G-Buffer textures
positionTex.Allocate(GL_RGBA32F,_width,_height);
normalTex.Allocate(GL_RGBA16F,_width,_height);
diffuseTex.Allocate(GL_RGBA16F,_width,_height);
depthTex.Allocate(GL_DEPTH32F_STENCIL8,_width,_height);
positionTex.SetWrapping(GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE);
normalTex.SetWrapping(GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE);
diffuseTex.SetWrapping(GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE);
depthTex.SetWrapping(GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE);
// Initialize framebuffer
int outPosition = 0;
int outDiffuseSpecular = 1;
int outNormalRoughness = 2;
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER,framebuffer);
// Attach output textures
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0 + outPosition, positionTex.target, positionTex.id, 0);
glf::CheckFramebuffer(framebuffer);
glBindTexture(diffuseTex.target,diffuseTex.id);
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0 + outDiffuseSpecular, diffuseTex.target, diffuseTex.id, 0);
glf::CheckFramebuffer(framebuffer);
glBindTexture(normalTex.target,normalTex.id);
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0 + outNormalRoughness, normalTex.target, normalTex.id, 0);
glf::CheckFramebuffer(framebuffer);
glBindTexture(depthTex.target,depthTex.id);
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT, depthTex.target, depthTex.id, 0);
glf::CheckFramebuffer(framebuffer);
GLenum drawBuffers[3] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2};
glDrawBuffers(3,drawBuffers);
assert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Program regular mesh
ProgramOptions regularOptions = ProgramOptions::CreateVSOptions();
regularOptions.AddDefine<int>("GBUFFER", 1);
regularOptions.AddDefine<int>("OUT_POSITION", outPosition);
regularOptions.AddDefine<int>("OUT_DIFFUSE_SPECULAR", outDiffuseSpecular);
regularOptions.AddDefine<int>("OUT_NORMAL_ROUGHNESS", outNormalRoughness);
regularRenderer.program.Compile(regularOptions.Append(LoadFile(directory::ShaderDirectory + "meshregular.vs")),
regularOptions.Append(LoadFile(directory::ShaderDirectory + "meshregular.fs")));
regularRenderer.transformVar = regularRenderer.program["Transform"].location;
regularRenderer.modelVar = regularRenderer.program["Model"].location;
regularRenderer.diffuseTexUnit = regularRenderer.program["DiffuseTex"].unit;
regularRenderer.normalTexUnit = regularRenderer.program["NormalTex"].unit;
regularRenderer.roughnessVar = regularRenderer.program["Roughness"].location;
regularRenderer.specularityVar = regularRenderer.program["Specularity"].location;
glProgramUniform1i(regularRenderer.program.id, regularRenderer.program["DiffuseTex"].location, regularRenderer.diffuseTexUnit);
glProgramUniform1i(regularRenderer.program.id, regularRenderer.program["NormalTex"].location, regularRenderer.normalTexUnit);
// Program terrain mesh
ProgramOptions terrainOptions = ProgramOptions::CreateVSOptions();
terrainOptions.AddDefine<int>("GBUFFER", 1);
terrainOptions.AddDefine<int>("OUT_POSITION", outPosition);
terrainOptions.AddDefine<int>("OUT_DIFFUSE_SPECULAR", outDiffuseSpecular);
terrainOptions.AddDefine<int>("OUT_NORMAL_ROUGHNESS", outNormalRoughness);
terrainRenderer.program.Compile(terrainOptions.Append(LoadFile(directory::ShaderDirectory + "meshterrain.vs")),
terrainOptions.Append(LoadFile(directory::ShaderDirectory + "meshterrain.cs")),
terrainOptions.Append(LoadFile(directory::ShaderDirectory + "meshterrain.es")),
terrainOptions.Append(LoadFile(directory::ShaderDirectory + "meshterrain.fs")));
terrainRenderer.transformVar = terrainRenderer.program["Transform"].location;
terrainRenderer.diffuseTexUnit = terrainRenderer.program["DiffuseTex"].unit;
terrainRenderer.normalTexUnit = terrainRenderer.program["NormalTex"].unit;
terrainRenderer.heightTexUnit = terrainRenderer.program["HeightTex"].unit;
terrainRenderer.roughnessVar = terrainRenderer.program["Roughness"].location;
terrainRenderer.specularityVar = terrainRenderer.program["Specularity"].location;
terrainRenderer.tileSizeVar = terrainRenderer.program["TileSize"].location;
terrainRenderer.tileCountVar = terrainRenderer.program["TileCount"].location;
terrainRenderer.tileOffsetVar = terrainRenderer.program["TileOffset"].location;
terrainRenderer.projFactorVar = terrainRenderer.program["ProjFactor"].location;
terrainRenderer.tessFactorVar = terrainRenderer.program["TessFactor"].location;
terrainRenderer.heightFactorVar = terrainRenderer.program["HeightFactor"].location;
terrainRenderer.tileFactorVar = terrainRenderer.program["TileFactor"].location;
glProgramUniform1i(terrainRenderer.program.id, terrainRenderer.program["DiffuseTex"].location, terrainRenderer.diffuseTexUnit);
glProgramUniform1i(terrainRenderer.program.id, terrainRenderer.program["NormalTex"].location, terrainRenderer.normalTexUnit);
glProgramUniform1i(terrainRenderer.program.id, terrainRenderer.program["HeightTex"].location, terrainRenderer.heightTexUnit);
glf::CheckError("GBuffer::GBuffer");
}