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 C++ program that creates a file called Readings.txt. Inside the file, your program must...
Write a C++ program that creates a file called Readings.txt. Inside the file, your program must create a list. The list is composed of integer double pairs. There is one pair per line. The integers are in sequence (0, 1, 2, 3, ...) beginning with zero and ending with some random value between 512 and 1024. The doubles should be random values between 50.000 and 90.000. The doubles only have 3 decimal places. The file should look like this (of...
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.
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...
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...
Part One: Write a program to draw a repetitive pattern or outline of a shape using...
Part One: Write a program to draw a repetitive pattern or outline of a shape using for loops and Turtle Graphics. Use the following guidelines to write your program. Decide on a repetitive pattern or the outline of a shape, such as a house, to draw. Give your artwork a name. Print the name to the output. Using for loops and the Turtle Module, draw the outline of a shape or a repetitive pattern. At least one for loop that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT