Advertisement
Guest User

Untitled

a guest
Feb 25th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. void GeometryEngine::drawCubeGeometry(QOpenGLShaderProgram *program) {
  2. // Bind array buffer
  3. arrayBuf.bind();
  4.  
  5. // Set position of vertices
  6. int posLocation = program->attributeLocation("a_position");
  7. program->enableAttributeArray(posLocation);
  8. program->setAttributeBuffer(posLocation, GL_FLOAT, 0, 3, sizeof(VertexData));
  9.  
  10. // Set color of vertices
  11. int colorLocation = program->attributeLocation("a_color");
  12. program->enableAttributeArray(colorLocation);
  13. program->setAttributeBuffer(colorLocation, GL_FLOAT, sizeof(QVector3D), 3, sizeof(VertexData));
  14.  
  15. // Bind index buffer
  16. indexBuf.bind();
  17.  
  18. // Draw triangles
  19. glDrawElements(GL_TRIANGLES, indices, GL_UNSIGNED_INT, 0);
  20.  
  21. // Release index buffer
  22. indexBuf.release();
  23.  
  24.  
  25. // Now I want to draw the contours of the same triangles, but this time as black lines ... ?
  26.  
  27. // An attempt:
  28. QColor color;
  29. color.setRgb(0,0,0);
  30. program->setAttributeValue(colorLocation, color);
  31.  
  32. indexBuf.bind();
  33. glDrawElements(GL_LINES, indices, GL_UNSIGNED_INT, 0);
  34. indexBuf.release();
  35.  
  36. arrayBuf.release();
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement