Пример #1
0
void drawCurves(GLenum mode) {
	/* Draw the curves */
	glColor3f(0,0,0);
	for(int i=0; i<OUTER_CPTS-3; i +=3) {
		if (mode == GL_SELECT) {
			glLoadName(i);
		}
		/* Draw the outer curve using OpenGL evaluators */
		glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, cpts[i]);
		glMapGrid1f(30, 0.0, 1.0);
		glEvalMesh1(GL_LINE, 0, 30);
	}
	
	for(int i=0; i<INNER_CPTS-3; i +=3) {
		if (mode == GL_SELECT) {
			glLoadName(i+OUTER_CPTS);
		}
		/* Draw the inner curve using OpenGL evaluators */
		glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, cpts[OUTER_CPTS+i]);
		glMapGrid1f(30, 0.0, 1.0);
		glEvalMesh1(GL_LINE, 0, 30);
	}
	
	glFlush();
}
Пример #2
0
void display(void)
{
	int i;

	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(1.0, 1.0, 1.0);

	glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);// first curve
	glEnable(GL_MAP1_VERTEX_3);
	glBegin(GL_LINE_STRIP);
	for (i = 0; i <= 30; i++)
		glEvalCoord1f((GLfloat)i / 30.0);
	glEnd();

	glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[3][0]);// secconed curve
	glEnable(GL_MAP1_VERTEX_3);
	glBegin(GL_LINE_STRIP);
	for (i = 0; i <= 30; i++)
		glEvalCoord1f((GLfloat)i / 30.0);
	glEnd();

	/* The following code displays the control points as dots. */
	glPointSize(5.0);
	glColor3f(1.0, 1.0, 0.0);
	glBegin(GL_POINTS);
	for (i = 0; i < 7; i++){
		glVertex3fv(&ctrlpoints[i][0]);
	}
	glEnd();
	glFlush();
}
Пример #3
0
void drawCurves() {
	int 		i;
	GLfloat gain;
	
	/* Draw the curves */
	glColor3f(0,0,0);
	for(i=0; i<OUTER_CPTS-3; i +=3) {
		/* Draw the outer curve using OpenGL evaluators */
		glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, cpts[i]);
		glMapGrid1f(30, 0.0, 1.0);
		glEvalMesh1(GL_LINE, 0, 30);
	}
	
	for(i=0; i<INNER_CPTS-3; i +=3) {
		/* Draw the inner curve using OpenGL evaluators */
		glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, cpts[OUTER_CPTS+i]);
		glMapGrid1f(30, 0.0, 1.0);
		glEvalMesh1(GL_LINE, 0, 30);
	}
	
	glFlush();
	
	// determin gain
	for(i=0;i<ncpts;i++){
		cpts[i][0]=(-16.0+cpts[i][0])/20.0;
		cpts[i][1]=(-16.0+cpts[i][1])/20.0;
		cpts[i][2]=cpts[i][2];
		//printf("\n %d %f %f",i,cpts[i][0],cpts[i][1]);
	}
}
Пример #4
0
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
void curve :: render(GemState *state)
{
  if(m_numVertices<1) {
    return;
  }

  TexCoord*texCoords=NULL;
  int texType=0;
  int texNum=0;
  bool lighting=false;
  state->get(GemState::_GL_TEX_COORDS, texCoords);
  state->get(GemState::_GL_TEX_TYPE, texType);
  state->get(GemState::_GL_TEX_NUMCOORDS, texNum);

  if(m_drawType==GL_DEFAULT_GEM) {
    m_drawType=GL_LINE_STRIP;
  }
  glNormal3f(0.0f, 0.0f, 1.0f);
  glLineWidth(m_linewidth);
  if(texType) {
    switch(texNum) {
    default:
      m_texCoords[0][0]=texCoords[0].s;
      m_texCoords[0][1]=texCoords[0].t;
      m_texCoords[1][0]=texCoords[1].s;
      m_texCoords[1][1]=texCoords[1].t;
      m_texCoords[2][0]=texCoords[2].s;
      m_texCoords[2][1]=texCoords[2].t;
      m_texCoords[3][0]=texCoords[3].s;
      m_texCoords[3][1]=texCoords[3].t;
      break;
    case 0:
    case 1:
    case 2:
    case 3:
      m_texCoords[0][0]=0.f;
      m_texCoords[0][1]=0.f;
      m_texCoords[1][0]=1.f;
      m_texCoords[1][1]=0.f;
      m_texCoords[2][0]=1.f;
      m_texCoords[2][1]=1.f;
      m_texCoords[3][0]=0.f;
      m_texCoords[3][1]=1.f;
      break;
    }

    glEnable(GL_MAP1_TEXTURE_COORD_2);
    glMap1f(GL_MAP1_TEXTURE_COORD_2, 0,   1,   2, m_numVertices,
            &m_texCoords[0][0]);
  }
  glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, m_numVertices, &(m_vert[0][0]));
  glEnable(GL_MAP1_VERTEX_3);
  glBegin(m_drawType);
  for (int n = 0; n <= m_resolution; n++) {
    glEvalCoord1f(static_cast<GLfloat>(n)/static_cast<GLfloat>(m_resolution));
  }
  glEnd();
  glLineWidth(1.0);
}
Пример #5
0
void RenderScene()
{
  glClear(GL_COLOR_BUFFER_BIT);
  
  //设置贝塞尔曲线,这个函数其实只需要调用一次,可以放在SetupRC中设置
  glMap1f(GL_MAP1_VERTEX_3, //生成的数据类型
    0.0f, //u值的下界
    100.0f, //u值的上界
    3, //顶点在数据中的间隔,x,y,z所以间隔是3
    numOfPoints, //u方向上的阶,即控制点的个数
    &controlPoints[0][0] //指向控制点数据的指针
  );

  //必须在绘制顶点之前开启
  glEnable(GL_MAP1_VERTEX_3);
  //使用画线的方式来连接点
  /*glBegin(GL_LINE_STRIP);
  for (int i = 0; i <= 100; i++)
  {
    glEvalCoord1f((GLfloat)i);
  }
  glEnd();*/

  glMapGrid1f(100, 0.0f, 100.0f);

  glEvalMesh1(GL_LINE, 0, 100);
  DrawPoints();

  glutSwapBuffers();

}
Пример #6
0
void ReDraw(void)
{
	int i;
	glClear(GL_COLOR_BUFFER_BIT);

	glMap1f(GL_MAP1_VERTEX_3,	// 产生的数据类型
	0.0f,						// 参数最小值
	100.0f,						// 参数最大值
	3,							// 控制点数据顶点之间的数目
	nNumPoints,					// 控制点数目
	&ctrlPoints[0][0]);			// 保存控制点的数组

	//启动求职器
	glEnable(GL_MAP1_VERTEX_3);

	// 将曲线上的点连接起来
	glBegin(GL_LINE_STRIP);
		for(i = 0; i <= 100; i++)
		{
			// 计算当前曲线点的坐标
			glEvalCoord1f((GLfloat) i); 
		}
	glEnd();

//	glMapGrid1d(100,0.0,100.0);
//	glEvalMesh1(GL_LINE,0,100);

	DrawPoints();
	glutSwapBuffers();
}
Пример #7
0
void  GrEdge::draw()
{
	GLfloat heightCoef	= Manager::getInstance()->getHeightCoef();
	GLfloat curvewidth	= Manager::getInstance()->getCurveWidthCoef();


	GLfloat ctrlpoints[4][3] = {
		{ _sx, _sy, _srh*heightCoef+heightCoef/2}, { _sx, _sy, _srh*heightCoef*2},
		{ _tx, _ty, _trh*heightCoef*2}, {_tx, _ty, _trh*heightCoef+heightCoef/2}};


	int ncl = 4;
	glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, ncl, &ctrlpoints[0][0]);
	glEnable(GL_MAP1_VERTEX_3);


	// curva

	glColor4f(_r, _g, _b, _a);
	glLineWidth(curvewidth);
	glBegin(GL_LINE_STRIP);
	for (int i = 0; i <= 30; i++)
		glEvalCoord1f((GLfloat) i/30.0);
	glEnd();


}
Пример #8
0
void tglDraw(const TCubic &cubic, int precision, GLenum pointOrLine)
{
	CHECK_ERRORS_BY_GL;
	assert(pointOrLine == GL_POINT || pointOrLine == GL_LINE);
	float(*ctrlPts)[3];
	ctrlPts = new float[4][3];

	ctrlPts[0][0] = cubic.getP0().x;
	ctrlPts[0][1] = cubic.getP0().y;
	ctrlPts[0][2] = 0.0;

	ctrlPts[1][0] = cubic.getP1().x;
	ctrlPts[1][1] = cubic.getP1().y;
	ctrlPts[1][2] = 0.0;

	ctrlPts[2][0] = cubic.getP2().x;
	ctrlPts[2][1] = cubic.getP2().y;
	ctrlPts[2][2] = 0.0;

	ctrlPts[3][0] = cubic.getP3().x;
	ctrlPts[3][1] = cubic.getP3().y;
	ctrlPts[3][2] = 0.0;

	CHECK_ERRORS_BY_GL;
	glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlPts[0][0]);
	CHECK_ERRORS_BY_GL;
	glEnable(GL_MAP1_VERTEX_3);
	CHECK_ERRORS_BY_GL;
	glMapGrid1f(precision, 0.0, 1.0);
	CHECK_ERRORS_BY_GL;
	glEvalMesh1(pointOrLine, 0, precision);
	CHECK_ERRORS_BY_GL;

	delete[] ctrlPts;
}
Пример #9
0
void
__glXDispSwap_Map1f(GLbyte * pc)
{
    GLint order, k;
    GLfloat u1, u2, *points;
    GLenum target;
    GLint compsize;

    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;

    __GLX_SWAP_INT(pc + 0);
    __GLX_SWAP_INT(pc + 12);
    __GLX_SWAP_FLOAT(pc + 4);
    __GLX_SWAP_FLOAT(pc + 8);

    target = *(GLenum *) (pc + 0);
    order = *(GLint *) (pc + 12);
    u1 = *(GLfloat *) (pc + 4);
    u2 = *(GLfloat *) (pc + 8);
    points = (GLfloat *) (pc + 16);
    k = __glMap1f_size(target);

    if (order <= 0 || k < 0) {
        /* Erroneous command. */
        compsize = 0;
    }
    else {
        compsize = order * k;
    }
    __GLX_SWAP_FLOAT_ARRAY(points, compsize);

    glMap1f(target, u1, u2, k, order, points);
}
Пример #10
0
void fdrawbezier(float vec[4][3])
{
	float dist;
	float curve_res = 24, spline_step = 0.0f;
	
	dist = 0.5f * ABS(vec[0][0] - vec[3][0]);
	
	/* check direction later, for top sockets */
	vec[1][0] = vec[0][0] + dist;
	vec[1][1] = vec[0][1];
	
	vec[2][0] = vec[3][0] - dist;
	vec[2][1] = vec[3][1];
	/* we can reuse the dist variable here to increment the GL curve eval amount*/
	dist = 1.0f / curve_res;
	
	cpack(0x0);
	glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]);
	glBegin(GL_LINE_STRIP);
	while (spline_step < 1.000001f) {
#if 0
		if (do_shaded)
			UI_ThemeColorBlend(th_col1, th_col2, spline_step);
#endif
		glEvalCoord1f(spline_step);
		spline_step += dist;
	}
	glEnd();
}
Пример #11
0
void init(void)
{
   glClearColor(0.0, 0.0, 0.0, 0.0);
   glShadeModel(GL_FLAT);
   glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);
   glEnable(GL_MAP1_VERTEX_3);
}
Пример #12
0
void BezierCurve::draw()
{
    int i;
    glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);

    //glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
    glBegin(GL_LINE_STRIP);
    for (i = 0; i <= 30; i++)
        glEvalCoord1f((GLfloat) i/30.0);
    glEnd();
    
    /* The following code displays the control points as dots. */
    glPointSize(5.0);
    glColor3f(1.0, 0.0, 0.0);
    glBegin(GL_POINTS);
    for (i = 0; i < 4; i++)
        glVertex3fv(&ctrlpoints[i][0]);
    glEnd();
    
    glColor3f(0.0, 0.5, 1.0);
    glBegin(GL_LINE_STRIP);
    for (i = 0; i<4; i++) {
        glVertex3fv(&ctrlpoints[i][0]);
    }
    glEnd();
}
Пример #13
0
void Sample_12_1::initGL()
{
	glPushAttrib(GL_ALL_ATTRIB_BITS);

	glClearColor(0.0, 0.0, 0.0, 0.0);
	glShadeModel(GL_FLAT);
	glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints_12_1[0][0]);
	glEnable(GL_MAP1_VERTEX_3);
}
Пример #14
0
void GLEngine::drawCurve(GLfloat *ctrlpoints, int stride, int order, float r,
		float g, float b) {

	glColor3f(r, g, b);
	glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, stride, order, ctrlpoints);

	glBegin(GL_LINE_STRIP);
	for (int i = 0; i <= 30; i++)
		glEvalCoord1f((GLfloat) i / 30.0);
	glEnd();
}
Пример #15
0
void drawCurves()
{
    int i;
    for(i=0; i<numberOfBezierCurve; i++)
    {
        /* draw the curve using OpenGL evaluators */
        glColor3f(BC[i].color[0], BC[i].color[1], BC[i].color[2]);
        glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, BC[i].cpts[0]);
        glMapGrid1f(30, 0.0, 1.0);
        glEvalMesh1(GL_LINE, 0, 30);
    }
    glFlush();
}
Пример #16
0
void Bezier::drawVertexMode()
{
	float ctrlPoints[m_vertexManager->size()][3];
	for(int i = 0; i < m_vertexManager->size() ; i++)
	{
		ctrlPoints[i][0] = m_vertexManager->at(i)->x;
		ctrlPoints[i][1] = m_vertexManager->at(i)->y;
		ctrlPoints[i][2] = m_vertexManager->at(i)->z;
	}
	glMap1f(GL_MAP1_VERTEX_3, 0.0f, 100.0f, 3, m_vertexManager->size(), &ctrlPoints[0][0]);
	glEnable(GL_MAP1_VERTEX_3);
	glBegin(GL_LINE_STRIP);
	{
		for(int i = 0 ; i <= 100 ; i++)
		{
			glEvalCoord1f(i);
		}
	}
	glEnd();

	glColor3f(1.0, 1.0, 1.0);
	int i = 0;
	glPointSize(8);
	glBegin(GL_POINTS);
	while(i != m_vertexManager->size())
	{
		if(m_vertexManager->at(i)->getSelection())
		{
			glColor3f(0.0, 1.0, 0.0);
		}
		else
		{
			glColor3f(1.0, 1.0, 1.0);
		}
		glVertex3f(m_vertexManager->at(i)->x, m_vertexManager->at(i)->y, m_vertexManager->at (i)->z);
		i++;
	}
	glEnd();

	glColor3f(1.0, 1.0, 1.0);
	glBegin(GL_LINE_STRIP);
	i = 0;
	while(i != m_vertexManager->size())
	{
		glVertex3f(m_vertexManager->at(i)->x, m_vertexManager->at(i)->y, m_vertexManager->at (i)->z);
		i++;
	}
	glEnd();
}
Пример #17
0
void
__glXDisp_Map1f(GLbyte * pc)
{
    GLint order, k;
    GLfloat u1, u2, *points;
    GLenum target;

    target = *(GLenum *) (pc + 0);
    order = *(GLint *) (pc + 12);
    u1 = *(GLfloat *) (pc + 4);
    u2 = *(GLfloat *) (pc + 8);
    points = (GLfloat *) (pc + 16);
    k = __glMap1f_size(target);

    glMap1f(target, u1, u2, k, order, points);
}
Пример #18
0
// Called to draw scene
void RenderScene(void)
{
    int i;

    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);

    // Sets up the bezier
    // This actually only needs to be called once and could go in
    // the setup function
    glMap1f(GL_MAP1_VERTEX_3,	// Type of data generated
            0.0f,						// Lower u range
            100.0f,						// Upper u range
            3,							// Distance between points in the data
            nNumPoints,					// number of control points
            &ctrlPoints[0][0]);			// array of control points

    // Enable the evaluator
    glEnable(GL_MAP1_VERTEX_3);

    // Use a line strip to "connect-the-dots"
    glBegin(GL_LINE_STRIP);
    for(i = 0; i <= 100; i++)
    {
        // Evaluate the curve at this point
        glEvalCoord1f((GLfloat) i);
    }
    glEnd();

    // Use higher level functions to map to a grid, then evaluate the
    // entire thing.
    // Put these two functions in to replace above loop

    // Map a grid of 100 points from 0 to 100
    //glMapGrid1d(100,0.0,100.0);

    // Evaluate the grid, using lines
    //glEvalMesh1(GL_LINE,0,100);

    // Draw the Control Points
    DrawPoints();

    // Flush drawing commands
    glutSwapBuffers();
}
Пример #19
0
static void hugsprim_glMap1f_0(HugsStackPtr hugs_root)
{
    HsWord32 arg1;
    HsFloat arg2;
    HsFloat arg3;
    HsInt32 arg4;
    HsInt32 arg5;
    HsPtr arg6;
    arg1 = hugs->getWord32();
    arg2 = hugs->getFloat();
    arg3 = hugs->getFloat();
    arg4 = hugs->getInt32();
    arg5 = hugs->getInt32();
    arg6 = hugs->getPtr();
    glMap1f(arg1, arg2, arg3, arg4, arg5, arg6);
    
    hugs->returnIO(hugs_root,0);
}
Пример #20
0
//-*****************************************************************************
void ICurvesDrw::draw( const DrawContext &iCtx )
{
    if ( ! ( m_positions && m_nVertices ) ) { return; }

    const V3f *points = m_positions->get();
    const Alembic::Util::int32_t *nVertices = m_nVertices->get();

    glDisable( GL_LIGHTING );

    glColor3f( 1.0, 1.0, 1.0 );
    glEnable( GL_POINT_SMOOTH );
    glPointSize( 1.0 );
    glLineWidth( 1.0 );

    for ( size_t currentCurve = 0, currentVertex = 0 ; currentCurve < m_nCurves ;
          ++currentCurve )
    {

        m_curvePoints.clear();
        for ( size_t currentCurveVertex = 0 ;
              currentCurveVertex < ( size_t ) ( nVertices[currentCurve] );
              ++currentCurveVertex, ++currentVertex )
        {
            m_curvePoints.push_back(&points[currentVertex]);
        }

        glMap1f( GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4,
                 (const GLfloat *)m_curvePoints[0] );
        glEnable( GL_MAP1_VERTEX_3 );

        glBegin( GL_LINE_STRIP );
        for ( size_t currentSegment = 0 ; currentSegment < 30 ;
              ++currentSegment )
        {
            glEvalCoord1f(
                static_cast<GLfloat>( currentSegment ) / static_cast<GLfloat>( 30.0f ) );
        }
        glEnd();
    }

    glEnable( GL_LIGHTING );

    IObjectDrw::draw( iCtx );
}
Пример #21
0
void Bezier::drawObjectModeSelect()
{
	glClear(GL_DEPTH_BUFFER_BIT);//This must be exist.For drawing in same z depth.
	float ctrlPoints[m_vertexManager->size()][3];
	for(int i = 0; i < m_vertexManager->size() ; i++)
	{
		ctrlPoints[i][0] = m_vertexManager->at(i)->x;
		ctrlPoints[i][1] = m_vertexManager->at(i)->y;
		ctrlPoints[i][2] = 0.0;
	}
	glMap1f(GL_MAP1_VERTEX_3, 0.0f, 100.0f, 3, m_vertexManager->size(), &ctrlPoints[0][0]);
	glEnable(GL_MAP1_VERTEX_3);
	glBegin(GL_LINE_STRIP);
	{
		for(int i = 0 ; i <= 100 ; i++)
		{
			glEvalCoord1f(i);
		}
	}
	glEnd();
}
Пример #22
0
void BasicObject::bezierLine()
{
	GLfloat ctrlPts [4][3] = { {-50.0, 40.0, 0.0}, {-10.0, 70.0, 0.0},{10.0, -70.0, 0.0}, {80.0, 40.0, 0.0} };
	glMap1f (GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, *ctrlPts);
    glEnable (GL_MAP1_VERTEX_3);
    GLint k;
    glColor3f (0.0, 0.0, 1.0);           
    glBegin (GL_LINE_STRIP); //绘制Bezier  曲线          
        for (k = 0; k <= 50; k++)     glEvalCoord1f (GLfloat (k) / 50.0);
    glEnd ();

    glColor3f (1.0, 0.0, 0.0); glPointSize (5.0); //绘制控制点
    glBegin (GL_POINTS);                 
       for (k = 0; k < 4; k++)    glVertex3fv (ctrlPts [k]);
    glEnd ();
    //绘制控制多边形
    glColor3f (0.0, 1.0, 0.0);  glLineWidth (2.0);                   
    glBegin (GL_LINE_STRIP);                 
         for (k = 0; k < 4; k++)  glVertex3fv (&ctrlPts [k][0]);
    glEnd ();
	glLineWidth (1.0);
}
void display(void){
    int i;
    glClear(GL_COLOR_BUFFER_BIT);
    switch(spline){
        case BEZIER:
            glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, nVertices, &vertices[0][0]);
            glBegin(GL_LINE_STRIP);
            for (i = 0; i <= 30; i++){
              glEvalCoord1f((GLfloat) i/30.0);
            }
            glEnd();
        break;
        case NURBS:
            gluBeginCurve(nc);

                gluNurbsCurve(nc, nNos, nos, 3, &vertices[0][0], 4, GL_MAP1_VERTEX_3);

            gluEndCurve(nc);
        break;
    }

    glPointSize(5.0);
    glColor3f(1.0, 1.0, 0.0);
    glBegin(GL_LINE_STRIP);
    for (i = 0; i < nVertices; i++) 
        glVertex3fv(&vertices[i][0]);
    glEnd();
    
    glColor3f(1.0, 0.0, 0.0);
    glBegin(GL_POINTS);
    for (i = 0; i < nVertices; i++) 
        glVertex3fv(&vertices[i][0]);
    glEnd();
    glColor3f(1.0, 1.0, 1.0);

    glFlush();
    glutSwapBuffers();
}
Пример #24
0
void NurbsCurve::draw() {
	
	// This fucntion could have problems if the number of points is different in the interpolator e nurbs curve
	#ifdef DEBUG
		cout << "NUMBER OF POINTS : " << numberOfPoints << endl;
	#endif
	
	if ( numberOfPoints == 0 ) cerr << "Not points defined in Nurbs Curve" << endl;
	
	glMap1f(GL_MAP1_VERTEX_3,0,100,3,numberOfPoints,controlPoint);
		
	glEnable(GL_MAP1_VERTEX_3);
	
	glBegin(GL_LINE_STRIP);
		
	float c;
	for(c=0;c<=100;c++) {
		glEvalCoord1f(c);
	}
	
	glEnd();
	
}
Пример #25
0
void Bezier()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glLineWidth(5);
    float PuntosdeControl[7][3] = {
        {411.0,posy(249.0),0.0},
        {505.0,posy(274.0),0.0},
        {597.0,posy(239.0),0.0},
        {620.0,posy(137.0),0.0},
        {518.0,posy(84.0),0.0},
        {414.0,posy(150.0),0.0},
        {412.0,posy(248.0),0.0}
    };
    
    glMap1f(GL_MAP1_VERTEX_3,0.0,1.0,3,7,*PuntosdeControl);
    glEnable(GL_MAP1_VERTEX_3);
    glMapGrid1f(100,0.0,1.0);
    glColor3f(1,0,0);
    glEvalMesh1(GL_LINE,0,100);
    glDisable(GL_MAP1_VERTEX_3);
    
    glFlush();
}
Пример #26
0
static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
{
  int i;
  
  if (mode == CD_CLIP)
    return;

  if (mode == CD_BEZIER)
  {
    int i, prec = 100;
    float (*points)[3] = malloc(n * sizeof(*points));

    for(i = 0; i < n; i++)
    {
      points[i][0] = (float)poly[i].x;
      points[i][1] = (float)poly[i].y;
      points[i][2] = 0;
    }

    glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, n, &points[0][0]);
    glEnable(GL_MAP1_VERTEX_3);
    glMapGrid1f(prec, 0.0, 1.0);
    glEvalMesh1(GL_LINE, 0, prec);
    glDisable(GL_MAP1_VERTEX_3);

    free(points);
    return;
  }

  if (mode == CD_PATH)
  {
    cdSimPolyPath(ctxcanvas->canvas, poly, n);
    return;
  }

  switch (mode)
  {
  case CD_CLOSED_LINES :
    glBegin(GL_LINE_LOOP);
    break;
  case CD_OPEN_LINES :
    glBegin(GL_LINE_STRIP);
    break;
  case CD_FILL :
    if(ctxcanvas->canvas->back_opacity == CD_OPAQUE && glIsEnabled(GL_POLYGON_STIPPLE))
    {
      /* draw twice, one with background color only, and one with foreground color */
      glDisable(GL_POLYGON_STIPPLE);
      glColor4ub(cdRed(ctxcanvas->canvas->background), 
                 cdGreen(ctxcanvas->canvas->background), 
                 cdBlue(ctxcanvas->canvas->background), 
                 cdAlpha(ctxcanvas->canvas->background));

      glBegin(GL_POLYGON);
      for(i = 0; i < n; i++)
        glVertex2i(poly[i].x, poly[i].y);
      glEnd();

      /* restore the foreground color */
      glColor4ub(cdRed(ctxcanvas->canvas->foreground), 
                 cdGreen(ctxcanvas->canvas->foreground), 
                 cdBlue(ctxcanvas->canvas->foreground), 
                 cdAlpha(ctxcanvas->canvas->foreground));
      glEnable(GL_POLYGON_STIPPLE);
    }

    glBegin(GL_POLYGON);
    break;
  }

  for(i = 0; i < n; i++)
    glVertex2i(poly[i].x, poly[i].y);
  glEnd();

  (void)ctxcanvas;
}
Пример #27
0
M(void, glMap1f, jint target, jfloat u1, jfloat u2, jint stride, jint order, jobject points) {
	glMap1f(target, u1, u2, stride, order, BUFF(GLfloat, points));
}