Diamond OpenGL in C++

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

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

}
Where is your camera and where it is pointing at? How small diamond can you see?

Try to divide random bits with 1000 or so..

EDIT: Do srand() only once using ctime library
Last edited on
Topic archived. No new replies allowed.