PDA

View Full Version : Diamond OpenGL in C++



noobatopengl
09-30-2015, 09:24 AM
I am try to create a flurry Diamond which the diamond will create a lot of diamond within screen of set. The code below is what i have try but it show me nothing at all. I have try to debug all night still couldnt figure what is wrong with it



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);

}