Written Questions Due Friday, Sept 9th by 2:00 PM (in class) Submit a graded pdf to Canvas by Wednesday, Sept 14th.

Program Due: Tuesday, Sept 13th by 11:59 PM Late assignments will be penalized 20 points per day.

Getting Started

Download CS370_Assign01.zip, saving it into the CS370-Fall2022 directory.

Double-click on CS370_Assign01.zip and extract the contents of the archive into a subdirectory called CS370_Assign01

Open CLion, select CS370-Fall2022 from the main screen (you may need to close any open projects), and open the CMakeLists.txt file in this directory (not the one in the CS370_Assign01 subdirectory). Uncomment the line

	add_subdirectory("CS370_Assign01" "CS370_Assign01/bin")

Finally, select Reload changes which should build the project and add DonQuixote to the dropdown menu at the top of the IDE window.

Written Questions

  1. What are the main advantages and main disadvantages to generating images using the graphics pipeline?
  2. Show that a rotation and a uniform scaling transformations (i.e. one where all the scale factors are identical) are commutative, i.e. that they can be applied in either order.

    Hint: Given the general 4x4 matrices for each transformation

    Scaling and Rotation Matrices

    show that the appropriate matrix products commute, i.e. give the same result for both orderings.

  3. Given the following set of vertices that define a square

Don Quixote Window

Diamond

Triangle

Programming assignment

Write a program that draws a simple 2D “windmill” scene using OpenGL. A sample executable is included in the demo directory as either DonQuixoteSolWin or DonQuixoteSolMac. The scene should include:

Hints:

OpenGL renders scenes using a Painter’s Algorithm (at least for now). In this type of algorithm, the object that is rendered last will appear on top. This can be useful for making complicated shapes by simply overlapping simple shapes rather than using a single polygon with many vertices.

All the square and triangle shapes should be generated with the provided sets of vertices. Use indexing to create the geometry from the vertices.

Define separate color buffers for the different colors needed for each shape, e.g. gradient blue for the sky, gradient green for the grass, solid brown for the house, etc. in the corresponding build_square() or build_triangle() functions. Consider which colors should be assigned to which vertices to achieve the desired effect.

Use transformations to create all the geometry from the square (triangle) objects. It may be helpful to sketch the scene on a sheet of graph paper to determine proper scale factors, rotation angles, and translation offsets. Note: Scalings and rotations are defined relative to the world coordinate origin not the object center.

For the sun, GL_TRIANGLE is not the only type of object that can be rendered in OpenGL. Chap 3 of OpenGL: Programming Guide discusses several other primitive types that can be used to render a set of vertices, e.g. GL_TRIANGLE_FAN, which can then be rendered using the provided draw_color_fan_object() function.

Use global variables to avoid magic numbers in the code, particularly for object transformations.

Don’t forget to register your callbacks, otherwise user interaction will have no effect.

Grading Criteria

The program MUST compile to receive any credit (so develop incrementally). Be sure to comment all creativity at the top of the source file.

Be creative! For example, have the <space> act like a “puff” of air that starts the fan spinning but then gradually slows down until another <space> is pressed. Another option would be to add a keypress that changes the scene from day to night with the sun changing to a moon.

Compiling and running the program

You should be able to build and run the program by selecting DonQuixote in the dropdown box in the toolbar and clicking the small green arrow next to it.

Don Quixote Window

To quit the program simply close the window.

Submitting to Marmoset

When you are done, submit the assignment to the Marmoset server using the Terminal window in CLion (click Terminal at the bottom left of the IDE). Navigate to the directory using

$ cd CS370_Assign01
CS370-Fall2022/CS370_Assign01
$ make submit

Enter your Marmoset username and password, if successful you should see

######################################################################
              >>>>>>>> Successful submission! <<<<<<<<<

Make sure that you log into the marmoset server to manually
check that the files you submitted are correct.

Details:

         Semester:   Fall 2022
         Course:     CS 370
         Assignment: assign01

######################################################################

You are responsible for making sure that your submission contains the correct file(s).