本文整理汇总了C++中ShaderProgram::getVertexAttributeLoc方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::getVertexAttributeLoc方法的具体用法?C++ ShaderProgram::getVertexAttributeLoc怎么用?C++ ShaderProgram::getVertexAttributeLoc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::getVertexAttributeLoc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void BatchSpriteRenderer::render(F32 x, F32 y, F32 width, F32 height, F32 angleRads) {
F32 top = height/2;
F32 right = width/2;
F32 bottom = -height/2;
F32 left = -width/2;
F32 verts[] = {
left, top, 0, right, top, 0, right, bottom, 0, left, bottom, 0
};
F32 uvs[] = {
0, 0, 1, 0, 1, 1, 0, 1
};
if (context->gConfig->useShaders) {
ShaderProgram *shaderProgram = context->glResourceManager->getShaderProgram("quad");
Matrix4f myMvMatrix = context->renderContext->mvMatrix;
myMvMatrix.translate(x, y, 0);
myMvMatrix.rotate(angleRads * (180 / PI), 0, 0, -1.0f);
glVertexAttribPointer(shaderProgram->getVertexAttributeLoc("vPosition"), 3, GL_FLOAT, GL_FALSE, 0, verts);
glVertexAttribPointer(shaderProgram->getVertexAttributeLoc("uvMap"), 2, GL_FLOAT, GL_FALSE, 0, uvs);
glUniformMatrix4fv(shaderProgram->getUniformLoc("projection_matrix"), 1, GL_FALSE, (GLfloat*) context->renderContext->projMatrix.data);
glUniformMatrix4fv(shaderProgram->getUniformLoc("modelview_matrix"), 1, GL_FALSE, (GLfloat*) myMvMatrix.data);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} else {
// GL1 rendering branch
Vector4f colorFilter = context->renderContext->colorFilter;
glColor4f(colorFilter.x,colorFilter.y,colorFilter.z,colorFilter.a);
glPushMatrix();
glTranslatef(x, y, 0);
glRotatef(angleRads * (180 / PI), 0, 0, 1.0f);
glVertexPointer(3, GL_FLOAT, 0, &verts);
glTexCoordPointer(2, GL_FLOAT, 0, &uvs);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glPopMatrix();
}
}