本文整理汇总了C++中ShaderProgram::getGlProgram方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::getGlProgram方法的具体用法?C++ ShaderProgram::getGlProgram怎么用?C++ ShaderProgram::getGlProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::getGlProgram方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enable
void VertexLayout::enable(ShaderProgram& _program, size_t _byteOffset, void* _ptr) {
GLuint glProgram = _program.getGlProgram();
// Enable all attributes for this layout
for (auto& attrib : m_attribs) {
GLint location = _program.getAttribLocation(attrib.name);
if (location != -1) {
auto& loc = s_enabledAttribs[location];
// Track currently enabled attribs by the program to which they are bound
if (loc != glProgram) {
glEnableVertexAttribArray(location);
loc = glProgram;
}
void* data = _ptr ? _ptr : ((unsigned char*) attrib.offset) + _byteOffset;
glVertexAttribPointer(location, attrib.size, attrib.type, attrib.normalized, m_stride, data);
}
}
// Disable previously bound and now-unneeded attributes
for (auto& locationProgramPair : s_enabledAttribs) {
const GLint& location = locationProgramPair.first;
GLuint& boundProgram = locationProgramPair.second;
if (boundProgram != glProgram && boundProgram != 0) {
glDisableVertexAttribArray(location);
boundProgram = 0;
}
}
}
示例2: enable
void VertexLayout::enable(RenderState& rs, ShaderProgram& _program, size_t _byteOffset, void* _ptr) {
GLuint glProgram = _program.getGlProgram();
// Enable all attributes for this layout
for (auto& attrib : m_attribs) {
GLint location = _program.getAttribLocation(attrib.name);
if (location != -1) {
auto& loc = rs.attributeBindings[location];
// Track currently enabled attribs by the program to which they are bound
if (loc != glProgram) {
GL::enableVertexAttribArray(location);
loc = glProgram;
}
void* data = (unsigned char*)_ptr + attrib.offset + _byteOffset;
GL::vertexAttribPointer(location, attrib.size, attrib.type, attrib.normalized, m_stride, data);
}
}
// Disable previously bound and now-unneeded attributes
for (size_t i = 0; i < RenderState::MAX_ATTRIBUTES; ++i) {
GLuint& boundProgram = rs.attributeBindings[i];
if (boundProgram != glProgram && boundProgram != 0) {
GL::disableVertexAttribArray(i);
boundProgram = 0;
}
}
}