Assignment 1: Introduction to OpenGL Solution

$30.00 $26.40


Assignment Specification:

Install OpenGL as mentioned in the lecture note. Next, download the attached program

Triangle.cpp. Run and Compile the program. Next, Make the following changes:

  1. Change the background color. You can choose any color other than white as given in the original program. Write down the code to change the color. Show the screen shot with the code.

  1. Replace GL_TRIANGLE with GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN. Does the output for each case differ from the original output?

  1. The triangle is composed of three points. Show the points; no need to color the triangle this time. Vary the size of the points. Write down the codes that draw points. Change the size of the points. Show the screen shot with the code.

  1. The triangle has three sides. Draw the lines to show the three sides of the triangle; vary the width of the lines. Use GL_LINE, GL_LINE_LOOP. Write down the codes that draw lines. Show the screen shot for different line width along with the code.

Submit the cpp file after making the following changes to the original program.

  1. Add three more points to add another triangle so that the resultant figure looks like a square;

  1. Show the colored square;

  1. Now the square is composed of two triangles; Show the sides (lines) of the two triangles;

  1. Add a keyboard button to change from the polygon mode to wireframe mode.


Include a pdf file named Assignment1.pdf to answer questions 1 to 4. For questions 5 to 8, submit the modified file as TriangleModified.cpp. Include at the top of your solution (in comments) your name, what compiler(s) you used. Minimal documentation is required – use good naming conventions for variables and comment any non-trivial code (describe what it does).

Place your solution in a zipped file named with your last name followed by the first initial of your first name followed by 1 (ex: and submit the solution via canvas.

Thus, your zip should contain the following:

  • A file named TriangleModified.cpp, and a pdf file named Assignment1.pdf.

This assignment carries a weightage of 5% of the course.