Does anyone have an opinion on this?
// 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();
}