本文整理汇总了C++中ProgramObject::programId方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramObject::programId方法的具体用法?C++ ProgramObject::programId怎么用?C++ ProgramObject::programId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgramObject
的用法示例。
在下文中一共展示了ProgramObject::programId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadLightProgram
void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limited, ProgramObject& program, LightLocations& locations) {
program.addShaderFromSourceCode(QGLShader::Vertex, (limited ? deferred_light_limited_vert : deferred_light_vert));
program.addShaderFromSourceCode(QGLShader::Fragment, fragSource);
program.link();
program.bind();
program.setUniformValue("diffuseMap", 0);
program.setUniformValue("normalMap", 1);
program.setUniformValue("specularMap", 2);
program.setUniformValue("depthMap", 3);
program.setUniformValue("shadowMap", 4);
program.setUniformValue("skyboxMap", 5);
locations.shadowDistances = program.uniformLocation("shadowDistances");
locations.shadowScale = program.uniformLocation("shadowScale");
locations.nearLocation = program.uniformLocation("near");
locations.depthScale = program.uniformLocation("depthScale");
locations.depthTexCoordOffset = program.uniformLocation("depthTexCoordOffset");
locations.depthTexCoordScale = program.uniformLocation("depthTexCoordScale");
locations.radius = program.uniformLocation("radius");
locations.ambientSphere = program.uniformLocation("ambientSphere.L00");
locations.invViewMat = program.uniformLocation("invViewMat");
GLint loc = -1;
#if (GPU_FEATURE_PROFILE == GPU_CORE)
const GLint LIGHT_GPU_SLOT = 3;
loc = glGetUniformBlockIndex(program.programId(), "lightBuffer");
if (loc >= 0) {
glUniformBlockBinding(program.programId(), loc, LIGHT_GPU_SLOT);
locations.lightBufferUnit = LIGHT_GPU_SLOT;
} else {
locations.lightBufferUnit = -1;
}
#else
loc = program.uniformLocation("lightBuffer");
if (loc >= 0) {
locations.lightBufferUnit = loc;
} else {
locations.lightBufferUnit = -1;
}
#endif
#if (GPU_FEATURE_PROFILE == GPU_CORE)
const GLint ATMOSPHERE_GPU_SLOT = 4;
loc = glGetUniformBlockIndex(program.programId(), "atmosphereBufferUnit");
if (loc >= 0) {
glUniformBlockBinding(program.programId(), loc, ATMOSPHERE_GPU_SLOT);
locations.atmosphereBufferUnit = ATMOSPHERE_GPU_SLOT;
} else {
locations.atmosphereBufferUnit = -1;
}
#else
loc = program.uniformLocation("atmosphereBufferUnit");
if (loc >= 0) {
locations.atmosphereBufferUnit = loc;
} else {
locations.atmosphereBufferUnit = -1;
}
#endif
program.release();
}