使用OpenGL绘制钻石

时间:2015-05-20 20:45:57

标签: c++ opengl

我尝试画一颗钻石

这里是我想要的东西

http://i.stack.imgur.com/SP9vK.png

考虑红色部分。

我想要的是使用这个公式绘制钻石

point = (int *) malloc (sizeof (int) * n * 2) ;
w = 2 * pi / n;
wi = w / 2;
for (int i = 0; i <3; i ++ ) {

    point [i] = (int) (CX + R * cos (wi));
    point [i +1] = (int) (CY + R * sin (wi));
}

任何意识形态?

1 个答案:

答案 0 :(得分:0)

draw-&GT;

void drawLine (int x1, int y1, int x2, int y2) {
glBegin (GL_LINES);
glVertex2d (x1, y1);
glVertex2d (x2, y2);
glEnd();
glFlush();

}

第二个

  for (int i = 0; i <3; i ++) {
    for (int j = 0 ; j < 3; j ++) {
        drawLine (point [i], point [i +1], point [j], point [j +1]);
    }
}

首先运行此

point = (int *) malloc (sizeof (int) * n * 2) ;
w = 2 * pi / n;
wi = w / 2;
for (int i = 0; i <7; i ++ ) {

    point [i] = (int) (CX + R * cos (wi));
    point [i +1] = (int) (CY + R * sin (wi));


    printf("pointX = %d \n",(int)point[i]);
    printf("pointY = %d \n",(int)point[i+1]);




    wi += w;
}