本文整理汇总了C++中TriangleMesh::VertexCount方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleMesh::VertexCount方法的具体用法?C++ TriangleMesh::VertexCount怎么用?C++ TriangleMesh::VertexCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleMesh
的用法示例。
在下文中一共展示了TriangleMesh::VertexCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup_vertex_position_buffer_object
void setup_vertex_position_buffer_object(void) {
glGenBuffers(1, &vertex_position_buffer);
glBindBuffer(GL_ARRAY_BUFFER, vertex_position_buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * trig.VertexCount(),
&trig.Vertices()[0], GL_STATIC_DRAW);
}
示例2: display_handler
void display_handler(void) {
// clear scene
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);
shader.Bind();
// pass uniform variables to shader
GLint projectionMatrix_location = glGetUniformLocation(shader.ID(), "projectionMatrix");
GLint viewMatrix_location = glGetUniformLocation(shader.ID(), "viewMatrix");
GLint modelMatrix_location = glGetUniformLocation(shader.ID(), "modelMatrix");
GLint normalMatrix_location = glGetUniformLocation(shader.ID(), "normalMatrix");
GLint materialAmbient_location = glGetUniformLocation(shader.ID(), "materialAmbient");
GLint materialDiffuse_location = glGetUniformLocation(shader.ID(), "materialDiffuse");
GLint materialSpecular_location = glGetUniformLocation(shader.ID(), "materialSpecular");
GLint lightPosition_location = glGetUniformLocation(shader.ID(), "lightPosition");
GLint lightAmbient_location = glGetUniformLocation(shader.ID(), "lightAmbient");
GLint lightDiffuse_location = glGetUniformLocation(shader.ID(), "lightDiffuse");
GLint lightSpecular_location = glGetUniformLocation(shader.ID(), "lightSpecular");
GLint lightGlobal_location = glGetUniformLocation(shader.ID(), "lightGlobal");
GLint materialShininess_location = glGetUniformLocation(shader.ID(), "materialShininess");
GLint constantAttenuation_location = glGetUniformLocation(shader.ID(), "constantAttenuation");
GLint linearAttenuation_location = glGetUniformLocation(shader.ID(), "linearAttenuation");
GLint useTexture_location = glGetUniformLocation(shader.ID(), "useTexture");
glUniformMatrix4fv( projectionMatrix_location, 1, GL_FALSE, &projectionMatrix[0][0]);
glUniformMatrix4fv( viewMatrix_location, 1, GL_FALSE, &viewMatrix[0][0]);
glUniformMatrix4fv( modelMatrix_location, 1, GL_FALSE, &modelMatrix[0][0]);
glUniformMatrix3fv( normalMatrix_location, 1, GL_FALSE, &normalMatrix[0][0]);
glUniform3fv( materialAmbient_location, 1, materialAmbient);
glUniform3fv( materialDiffuse_location, 1, materialDiffuse);
glUniform3fv( materialSpecular_location, 1, materialSpecular);
glUniform3fv( lightPosition_location, 1, lightPosition);
glUniform3fv( lightAmbient_location, 1, lightAmbient);
glUniform3fv( lightDiffuse_location, 1, lightDiffuse);
glUniform3fv( lightSpecular_location, 1, lightSpecular);
glUniform3fv( lightGlobal_location, 1, lightGlobal);
glUniform1f( materialShininess_location, materialShininess);
glUniform1f( constantAttenuation_location, constantAttenuation);
glUniform1f( linearAttenuation_location, linearAttenuation);
glUniform1i( useTexture_location, useTexture);
// bind texture to shader
GLint texture0_location = glGetAttribLocation(shader.ID(), "texture0");
if (texture0_location != -1) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureID);
glUniform1i(texture0_location, 0);
}
// bind vertex uv coordinates to shader
GLint uv_location = glGetAttribLocation(shader.ID(), "vertex_uv");
if (uv_location != -1) {
glEnableVertexAttribArray(uv_location);
glBindBuffer(GL_ARRAY_BUFFER, vertex_uv_buffer);
glVertexAttribPointer(uv_location, 2, GL_FLOAT, GL_FALSE, 0, 0);
}
// bind vertex positions to shader
GLint position_location = glGetAttribLocation(shader.ID(), "vertex_position");
if (position_location != -1) {
glEnableVertexAttribArray(position_location);
glBindBuffer(GL_ARRAY_BUFFER, vertex_position_buffer);
glVertexAttribPointer(position_location, 3, GL_FLOAT, GL_FALSE, 0, 0);
}
// bind vertex normals to shader
GLint normal_location = glGetAttribLocation(shader.ID(), "vertex_normal");
if (normal_location != -1) {
glEnableVertexAttribArray(normal_location);
glBindBuffer(GL_ARRAY_BUFFER, vertex_normal_buffer);
glVertexAttribPointer(normal_location, 3, GL_FLOAT, GL_FALSE, 0, 0);
}
// draw the scene
glDrawArrays(GL_TRIANGLES, 0, trig.VertexCount());
glDisableVertexAttribArray(position_location);
glDisableVertexAttribArray(uv_location);
glDisableVertexAttribArray(normal_location);
shader.Unbind();
glFlush();
}