Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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

PREVIOUS NEXT
Code Example
Cpp :: progress bar custom color c++ buider 
Cpp :: int and char in c++ compiler 
Cpp :: Get the absolute path of a boost filePath as a string 
Cpp :: c++ if 
Cpp :: Opengl GLFW basic window 
Cpp :: Shuffle String leetcode solution in cpp 
Cpp :: how to change the icon of an exe in c++ 
Cpp :: c++ terinary operator 
Cpp :: Missing GL version 
Cpp :: nothrow new in cpp 
Cpp :: how to open program in c++ 
Cpp :: vector literal in cpp 
Cpp :: facade pattern C++ code 
Cpp :: assegnare valori in c++ 
Cpp :: move letter position using c++ with input 
Cpp :: using of and || c++ 
Cpp :: c++ poitner 
Cpp :: fsafdsfdsaf 
Cpp :: return multiple objects from a function C++ using references 
Cpp :: Passing a string to a function 
Cpp :: Implement a currency converter which ask the user to enter value in Pak Rupees and convert in following: in cpp 
Cpp :: Pawri Meme codechef solution in c++ 
Cpp :: ue_log example 
Cpp :: no argument but return value in c++ 
Cpp :: python pour débutant 
Cpp :: set app icon qt 
Cpp :: can derived class access base class non-static members without object of the base class 
Cpp :: 2160. Minimum Sum of Four Digit Number After Splitting Digits leetcode solution in c++ 
Cpp :: how to read qlistwidget in c++ 
Cpp :: c++ how to print out 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =