Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #include <stdio.h>
  2. //#include <window.h>
  3. #include <gl/glut.h>
  4.  
  5. GLfloat ctlarray[3][2][4] = { 0.5, 0.0, -0.5, 1.0, 0.5, 0.0, 0.5, 1.0,
  6. 0.0, 0.866*0.55, -0.5 * 0.55, 1.0*0.55, 0.0, 0.866*0.55, 0.5 * 0.55, 1.0 * 0.55, -0.5, 0.0, -0.5, 1.0, -0.5, 0.0, 0.5, 1.0 };
  7.  
  8. GLUnurbsObj *theNurb;
  9. GLfloat texpt[2][2][2] = { 0, 0, 0, 1, 1, 0, 1, 1 };
  10. GLUquadricObj* theqw;
  11. GLubyte *Iz_RGB;
  12.  
  13. void file_read()
  14. {
  15. }
  16.  
  17. void init()
  18. {
  19. glClearColor(0.1, 0.98, 0.3, 1);
  20. theNurb = gluNewNurbsRenderer();
  21. theqw = gluNewQuadric();
  22. glEnable(GL_DEPTH_TEST);
  23. gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0);
  24. glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  25. glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  26. glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  27. glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, Iz_RGB);
  28. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
  29. gluQuadricTexture(theqw, true);
  30. glEnable(GL_TEXTURE_2D);
  31. free(Iz_RGB);
  32. }
  33.  
  34. void Display()
  35. {
  36. GLfloat knot[] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 };
  37. GLfloat knot1[] = { 0.0, 0.0, 1.0, 1.0 };
  38. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  39. glRotatef(1, 1.0, 1.0, 1.0);
  40. glColor3f(1, 0, 0);
  41. glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, &texpt[0][0][0]);
  42. glEnable(GL_MAP2_TEXTURE_COORD_2);
  43.  
  44. gluSphere(theqw, 0.3, 50, 50);
  45.  
  46. gluBeginSurface(theNurb);
  47. gluNurbsSurface(theNurb, 6, knot, 4, knot1, 2 * 4, 4, &ctlarray[0][0][0], 3, 2, GL_MAP2_VERTEX_4);
  48. gluEndSurface(theNurb);
  49.  
  50. glutPostRedisplay();
  51. glutSwapBuffers();
  52. }
  53.  
  54. void main()
  55. {
  56. file_read();
  57. glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
  58. glutInitWindowSize(500, 500);
  59. glutCreateWindow("Task4");
  60. init();
  61. glutDisplayFunc(Display);
  62. glutMainLoop();
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement