Results 1 to 2 of 2

Thread: Using Control Point To Generate Loops

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    1

    Using Control Point To Generate Loops

    Does anyone have an opinion on this?

    Code :
    // use window coords - not abstract axis
    void reshape(int w, int h)
    {
       glViewport(0, 0, w, h);
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(0, w, 0, h, -1, 1);
       glScalef(1, -1, 1);
       glTranslatef(0, -h, 0);
    }
     
    void display(void)
    {
       int i;
       GLfloat ctrlpt[7][3];
     
       memset(&ctrlpt, 0x0, sizeof(ctrlpt));
       // control point info..
       // center is 150, 150
       // w = 100, h = 100
       ctrlpt[0][0] = ctrlpt[3][0] = 150.0; // x
       ctrlpt[1][0] = ctrlpt[2][0] = 210.0;
       ctrlpt[4][0] = ctrlpt[5][0] =  90.0;
     
       ctrlpt[0][1] = ctrlpt[1][1] = ctrlpt[5][1] = 100.0; // y
       ctrlpt[2][1] = ctrlpt[3][1] = ctrlpt[4][1] = 200.0;
     
       ctrlpt[6][0] = ctrlpt[0][0]; // close the loop
       ctrlpt[6][1] = ctrlpt[0][1];
     
     
       // or manually playing..
       /*ctrlpt[0][0] = ctrlpt[6][0] = 150.0; // 1st and last are same, close loop
       ctrlpt[0][1] = ctrlpt[6][1] = 100.0;
       ctrlpt[1][0] = 210.0;
       ctrlpt[1][1] = 100.0;
       ctrlpt[2][0] = 250.0;
       ctrlpt[2][1] = 220.0;
       ctrlpt[3][0] = 150.0;
       ctrlpt[3][1] = 195.0;
       ctrlpt[4][0] =  90.0;
       ctrlpt[4][1] = 200.0;
       ctrlpt[5][0] =  90.0;
       ctrlpt[5][1] = 100.0;*/
     
       glEnable(GL_MAP1_VERTEX_3);
       glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 7, &ctrlpt[0][0]);
     
     
       glClear(GL_COLOR_BUFFER_BIT);
       glColor3f(0.0, 1.0, 1.0);
       glLineWidth(1.0);
       glBegin(GL_LINE_STRIP);
    #ifdef MORE_ITER
          for(i = 0; i < 37; i++) glEvalCoord1f((GLdouble)(i*1.0)/36.0);
    #else
          for(i = 0; i < 19; i++)
          //for(i = 0; i < 5; i++) // 1/4 arc
          {
             glEvalCoord1f((GLdouble)(i*2.0)/36.0);
          }
    #endif
       glEnd();
     
       glPointSize(5.0);
       glColor3f(0.5, 1.0, 1.0);
       glBegin(GL_POINTS);
          for(i = 0; i < 6; i++) glVertex3fv(ctrlpt[i]);
       glEnd();
     
       glutSwapBuffers();
    }

  2. #2
    Senior Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: Using Control Point To Generate Loops

    some functions are deprecated

Similar Threads

  1. Dynamic control point array in gluNurbsSurface()
    By urhere in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 02-28-2012, 02:40 PM
  2. Map2 control point limit?
    By LetsGoOutside in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-20-2010, 06:35 PM
  3. gluNurbsSurface control point weights
    By spurserh in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-01-2009, 04:04 PM
  4. gluNurbsSurface control point weights
    By spurserh in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 03-30-2009, 08:46 AM
  5. how to determine the bezier surface' control point
    By ruixp in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-23-2001, 02:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean