Search
 
SCRIPT & CODE EXAMPLE
 

CPP

opengl draw semi circle c++

//semi-circle roof
	//fix variable naming
	int centerx = 400;//x axis center
	int centery = 400;//y axis center
	int roofr = 100;//radius
	int roofd = 200;//diameter
	float PI = 3.141592653589793238f;
	float semicircleangle = PI * 1.0f;
	int steps = 100;
	glBegin(GL_TRIANGLE_FAN);

	for (int i = 0; i < steps; i++) {
		float theta = semicircleangle * float(i) / float(steps);//get the current angle
		float x = roofr * cosf(theta);//calculate the x component
		float y = roofr * sinf(theta);//calculate the y component
		glVertex2f(x + centerx, y + centery);//output vertex

	}
	glEnd();
Comment

PREVIOUS NEXT
Code Example
Cpp :: pure virtual function in c++ 
Cpp :: sort vector c++ 
Cpp :: how can we create 4 digit random number in c++ 
Cpp :: cpp string find all occurence 
Cpp :: c++ program to convert kelvin to fahrenheit 
Cpp :: c++ compile to exe command line 
Cpp :: c++ string slicing 
Cpp :: reversing a string in c++ 
Cpp :: c++ doubly linked list 
Cpp :: c++ find object in vector by attribute 
Cpp :: cpp detect os 
Cpp :: cpp map insert 
Cpp :: how to create 2d array using vector in c++ 
Cpp :: How to turn an integer variable into a char c++ 
Cpp :: access last element of set c++ 
Cpp :: c++ function of find maximum value in an array 
Cpp :: c++ array pointer 
Cpp :: preorder 
Cpp :: C++ Calculating the Mode of a Sorted Array 
Cpp :: fill vector with zeros c++ 
Cpp :: c++ sizeof 
Cpp :: basic cpp 
Cpp :: flutter single instance app 
Cpp :: google test assert exception 
Cpp :: bit++ codeforces in c++ 
Cpp :: c++ generic pointer 
Cpp :: how to find size of int in c++ 
Cpp :: c++ hash 
Cpp :: c++ pass function as argument 
Cpp :: c++ last element of array 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =