Question

In: Computer Science

Write a program to draw a Pentagon with blue color inside a window. Using C ++...

Write a program to draw a Pentagon with blue color inside a window. Using C ++ with Output.

Solutions

Expert Solution

#include<iostream.h>

//Install GLUT If you do not have GLUT installed on your machine
#include<GL/glut.h>                                

//this is car function
void car(){

    //define the color of class
        glClearColor(.3,.16,.4,1);

    //Clear the color of buffer bit
        glClear(GL_COLOR_BUFFER_BIT);
        
    //set the width of line
        glLineWidth(5);

    //start draw polygon from here
        glBegin(GL_POLYGON);

    //set color
        glColor3f(.1,.1,.1);
        
    //set vertex .2 from x axis and .2 from y axis
        glVertex2f(.2,.2);

    //set vertex .2 from x axis and -.2 from y axis
        glVertex2f(.2,-.2);

    //set vertex -.2 from x axis and -.2 from y axis
        glVertex2f(-.2,-.2);

    //set vertex -.2 from x axis and .2 from y axis
        glVertex2f(-.2,.2);

    //set vertex 0 from x axis and .4 from y axis
        glVertex2f(0,.4);

    //End of gl
        glEnd();

    //Flush gl function
        glFlush();      
        
}

//starting of main function
//passing two arguments in it
void main(int argc, char **argv){

    //Initialize gl function and pass two arguments in it
        glutInit(&argc, argv);

    //initialize the size of window
        glutInitWindowSize(600,600);

    //Create window
        glutCreateWindow("CAR");

    //call car function
        glutDisplayFunc(car);

    //call MainLoop
        glutMainLoop();
}

Related Solutions

write c++ program that takes the depth ( in kilometer) inside the earth to compute and...
write c++ program that takes the depth ( in kilometer) inside the earth to compute and display the temperature at the depth in degrees celsius and fahrenheit. the relevant formulas are: celsius+ 10 x depth + 20 fahrenheit = 9/5 celsius + 23
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Write a C++ program which prints consecutive dates to the console window starting at January 1,...
Write a C++ program which prints consecutive dates to the console window starting at January 1, 2000, as follows. Saturday, January 1, 2000 Sunday, January 2, 2000 Monday, January 3, 2000 Tuesday, January 4, 2000 ... You will define a function which prints the dates indefinitely, exactly as given above, or prints a specific number of dates. For example, if your function prints 7,581 days the result would look like this. Saturday, January 1, 2000 Sunday, January 2, 2000 ......
write a Program in C++ Using a structure (struct) for a timeType, create a program to...
write a Program in C++ Using a structure (struct) for a timeType, create a program to read in 2 times into structures, and call the method addTime, in the format: t3 = addTime(t1, t2); Make sure to use add the code to reset and carry, when adding 2 times. Also, display the resultant time using a function: display(t3);
Can you solve this C program by using Function? Q1. Write a C program to ring...
Can you solve this C program by using Function? Q1. Write a C program to ring the computer bell at any number of times you specify. Use the system clock as a delay, you need to include the time header file.
write C++ program using functions (separate function for each bottom) Write a program to find if...
write C++ program using functions (separate function for each bottom) Write a program to find if a number is large word for two given bottom base - bottom1 and bottom2. You can predict that a number, when converted to any given base shall not exceed 10 digits. . the program should ask from user to enter a number that it should ask to enter the base ranging from 2 to 16 after that it should check if the number is...
write a c++ program using micro soft visual studio 2010 to write a program and store...
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and...
6. Write a program in C programming (compile and run), a pseudocode, and draw a flowchart...
6. Write a program in C programming (compile and run), a pseudocode, and draw a flowchart for each of the following problems: a) Obtain three numbers from the keyboard, compute their product and display the result. b) Obtain two numbers from the keyboard, and determine and display which (if either) is the smaller of the two numbers. c) Obtain a series of positive numbers from the keyboard, and determine and display their average (with 4 decimal points). Assume that the...
Loop Introduction Assignment Please write a program in c# Using the conditions below, write one program...
Loop Introduction Assignment Please write a program in c# Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches.   Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into BMI is as follows: BMI = Weight *...
please write in c using linux or unix Write a program that will simulate non -...
please write in c using linux or unix Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT