////////////// OpenGL CGCore for 2D Functions ver 1 ///////////////// #include #include #include #include "CGCore3D.h" void C_Point::draw() { color.set(); glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); } void C_Vertex::resize() //resize to unit size { float length=sqrt(x*x+y*y+z*z); float invlength; if (length!=0.) { invlength=1./length; x*=invlength; y*=invlength; z*=invlength; } } void C_Vertex::homogenize() { float inv=1./t; x*=inv; y*=inv; z*=inv; t=1.; } C_Line::C_Line(float x1,float y1,float z1,float x2,float y2,float z2,C_Color col) { p.x=x1;p.y=y1;p.z=z1; q.x=x2;q.y=y2;q.z=z2; color=col; p.t=1.;q.t=1.; } void C_Line::draw() { color.set(); glBegin(GL_LINES); glVertex2f(p.x, p.y); glVertex2f(q.x, q.y); glEnd(); } void C_Line::homogenize() { p.homogenize(); q.homogenize(); } C_Polyline::C_Polyline(int numberPoints0) { numberPoints=numberPoints0; p=new C_Vertex[numberPoints]; } C_Polyline::C_Polyline(C_Vertex *p0,int numberPoints0) { int i; numberPoints=numberPoints0; p=new C_Vertex[numberPoints]; for (i=0;i