Horje
opengl draw cresent moon c++ Code Example
opengl draw cresent moon c++
//first circle moon
	int moonr = 50;
	int mooncenterx = 700;
	int mooncentery = 500;
	int moonsteps = 100;
	float circleangle = PI * 2.0f;
	glColor3f(1.0, 1.0, 1.0);
	glBegin(GL_TRIANGLE_FAN);

	for (int a = 0; a <= moonsteps; a++) {
		float angle = circleangle * float(a) / float(moonsteps);//get the current angl
		float moonx = moonr * cosf(angle);//calculate the x component
		float moony = moonr * sinf(angle);//calculate the y component
		glVertex2f(moonx + mooncenterx, moony + mooncentery);//output vertex
	}
	glEnd();

	//second circle moon
	int moon2r = 50;
	int mooncenter2x = 725;
	int mooncenter2y = 525;
	int moonsteps2 = 100;
	float circleangle2 = PI * 2.0f;
	glColor3f(0.5, 0.9, 0.4);
	glBegin(GL_TRIANGLE_FAN);

	for (int b = 0; b <= moonsteps; b++) {
		float angle2 = circleangle * float(b) / float(moonsteps2);//get the current angle
		float moon2x = moonr * cosf(angle2);//calculate the x component
		float moon2y = moonr * sinf(angle2);//calculate the y component
		glVertex2f(moon2x + mooncenter2x, moon2y + mooncenter2y);//output vertex
	}
	glEnd();




Cpp

Related
18 in 12 hour time Code Example 18 in 12 hour time Code Example
c++ get string between two characters Code Example c++ get string between two characters Code Example
Vs Code cpp not run Code Example Vs Code cpp not run Code Example
cuda shared array Code Example cuda shared array Code Example
libraries required for gaming in c++ Code Example libraries required for gaming in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8