Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. [Пересланное сообщение]
  2. Даша Кошель, 6 ноября в 16:31
  3. #include <iostream>
  4. #include <vector>
  5. #include <glut.h>
  6. GLUnurbsObj* nobj;
  7. // массив точек определяющего многоугольника
  8. GLfloat ctlarray[][4] = { { -0.6, -0.2, 0,1 },
  9. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { -0.6, -0.2, 1,1 },
  10. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { -0.4, 0.2, 0,1 },
  11. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { -0.4, 0.2, 1,1 },
  12. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { -0.2, -0.2, 0,1 },
  13. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { -0.2, -0.2, 1,1 },
  14. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { 0.0, 0.2, 0,1 },
  15. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { 0.0, 0.2, 1,1 },
  16. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { 0.2, -0.2, 0,1 },
  17. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { 0.2, -0.2, 1,1 },
  18. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { 0.4, 0.2, 0,1 },
  19. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { 0.4, 0.2, 1,1 },
  20. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { 0.6, -0.2, 0,1 },
  21. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ { 0.6, -0.2, 1,1 } };
  22. void init(void)
  23. {
  24. ​ glClearColor(1.0, 1.0, 1.0, 1.0);
  25. ​ nobj = gluNewNurbsRenderer();
  26. ​ gluNurbsProperty(nobj, GLU_SAMPLING_TOLERANCE, 25.0);
  27. }
  28. void Display()
  29. {
  30.  
  31. ​ GLfloat knot1[] = { 0.0,0.0,0.0,0.0,0.0,1.0,2.0,3.0,3.0,3.0,3.0,3.0 };
  32. ​ GLfloat knot2[] = { 0,0,1,1 };
  33. ​ glClear(GL_COLOR_BUFFER_BIT);
  34. ​ //glLineWidth(1);
  35. ​ //glPointSize(5);
  36. ​ //glColor3f(0.0, 0.5, 1.0);
  37. ​ //glBegin(GL_POINTS);
  38. ​ //for (int i = 0; i< 7; i++) {
  39. ​ //​ glVertex3f(ctlarray[i][0], ctlarray[i][1], ctlarray[i][2]);
  40. ​ //}
  41. ​ //glEnd();
  42. ​ glColor3f(0.0, 1.0, 1.0);
  43. ​ glRotatef(0.15, 0.2, 0.5, 0);
  44. ​ glLineWidth(1);
  45. ​ //gluNurbsCurve(nobj, 12, knot1, 4, &ctlarray[0][0], 5, GL_MAP1_VERTEX_3);
  46. ​ gluNurbsSurface(nobj, 12, knot1, 4, knot2, 4 * 2, 4, &ctlarray[0][0], 5, 2, GL_MAP2_VERTEX_4);
  47. ​ // glFlush();
  48. ​ glutPostRedisplay();
  49. ​ glutSwapBuffers();
  50. }
  51. int main()
  52. {
  53. ​ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
  54. ​ glutInitWindowSize(1100, 1100);
  55. ​ glutInitWindowPosition(1, 1);
  56. ​ glutCreateWindow("1");
  57. ​ init();
  58. ​ glutDisplayFunc(Display);
  59. ​ glutMainLoop();
  60.  
  61. ​ return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement