Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. // glutInit(&argc, const_cast<char**>(argv));
  2. //int main(int argc, const char * argv[])
  3.  
  4. #include <iostream>
  5. #include <stdlib.h>
  6. #include <GLUT/glut.h>
  7.  
  8. using namespace std;
  9.  
  10. GLUnurbsObj* nobj;
  11.  
  12. GLfloat ctlarray[7][2][4] = {
  13.     -0.6, 0.3, -0.2, 1.0,
  14.     -0.6, 0.0, -0.2, 1.0,
  15.    
  16.     -0.4, 0.3, 0.2, 1.0,
  17.     -0.4, 0.0, 0.2, 1.0,
  18.    
  19.     -0.2, 0.3, -0.2, 1.0,
  20.     -0.2, 0.0, -0.2, 1.0,
  21.    
  22.     0.0, 0.3, 0.2, 1.0,
  23.     0.0, 0.0, 0.2, 1.0,
  24.    
  25.     0.2, 0.3, -0.2, 1.0,
  26.     0.2, 0.0, -0.2, 1.0,
  27.    
  28.     0.4, 0.3, 0.2, 1.0,
  29.     0.4, 0.0, 0.2, 1.0,
  30.  
  31.     0.6, 0.3, -0.2, 1.0,
  32.     0.6, 0.0, -0.2, 1.0,
  33. };
  34.  
  35. void init(void)
  36.  
  37. {
  38.    
  39.     glClearColor(1, 1, 1, 1);
  40.    
  41.     nobj = gluNewNurbsRenderer();
  42.    
  43.     gluNurbsProperty(nobj, GLU_SAMPLING_TOLERANCE, 25.0);
  44.    
  45.     glEnable(GL_TEXTURE_1D);
  46. }
  47.  
  48. void Display()
  49.  
  50. {
  51.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  52.     glLineWidth(3.0);
  53.     glRotatef(0.2, 1, 0, 0);
  54.     glColor3f(5, 0.3, 1);
  55.    
  56.     GLfloat knot2[] = { 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 6.0};
  57.     GLfloat knot1[] = { 0.0, 0.0, 1.0, 1.0 };
  58.    
  59.     gluBeginSurface(nobj);
  60.     gluNurbsSurface(nobj, 9, knot2, 4, knot1, 8, 4, &ctlarray[0][0][0], 2, 2, GL_MAP2_VERTEX_4);
  61.    
  62.     gluEndSurface(nobj);
  63.     glutPostRedisplay();
  64.     glutSwapBuffers();
  65.    
  66. }
  67.  
  68. int main(int argc, const char * argv[])
  69.  
  70. {
  71.     glutInit(&argc, const_cast<char**>(argv));
  72.     glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
  73.     glutInitWindowSize(480, 480);
  74.     glutInitWindowPosition(100, 100);
  75.     glutCreateWindow(" ");
  76.     init();
  77.     glutDisplayFunc(Display);
  78.     glutMainLoop();
  79.    
  80.     return 0;
  81.    
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement