1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
void drawDiamond(GLintPoint center, int size,int x, int y)
{
float green, red, blue;
green = (float)rand()/(float)(RAND_MAX);
red = (float)rand()/(float)(RAND_MAX);
blue = (float)rand()/(float)(RAND_MAX);
glColor3f(red, green, blue);
glBegin(GL_POLYGON);
glVertex2f(center.x, center.y);
glVertex2f(center.x-1, center.y-1);
glVertex2f(center.x, center.y);
glVertex2f(center.x - 1, center.y - 1);
cout << "x" << center.x << endl;
cout << "y" << center. y<< endl;
glEnd();
glFlush();
}
void diamond(void)
{
GLintPoint Center;
int numx, numy;
int sizeofdim = rand() % 640;
for (int size = 0; size < 10; size++)
{
srand(size + 1);
numx = rand() % 640; // 640 is screen size
numy = rand() % 640;
Center.x = numx; // place enter randomly
Center.y = numy;
}
drawDiamond(Center, sizeofdim, Center.x, Center.y);
// drawDiamond(640.0, 10);
}
|