Homework2

SUN YAT-SEN UNIVERSITY

Homework 2: Hello, OpenGL!

Computer Graphics
2017-02-027

1. Introduction

Welcome to the first programming homework of CG course! I believe most of you started your programming careers by writing a simple program called ‘Hello, world!’. Let’s do the same thing with OpenGL! In this HW, you are required to draw some basic primitives with OpenGL and to know about some inner operating mechanisms of OpenGL.

Warning: We encourage discussions among students, but codes and documents should be written and submitted individually, without copying existed answers (Neither from other student nor from the Internet). Plagiarism = Fail. Besides, there may be at least 30% penalty for late homework.

2. Tasks

2.1 Pre-requirement

2.2 Hello, triangle!

Write a program to draw some basic primitives in one window.

  1. Draw a triangle. The result may be this:

  2. Change the color of 3 vertices into Red, Green and Blue. What does the result look like? Explain why this happen in your report.
  3. Write down your main algorithm and post your results in your report.
  4. Bonus: Draw other primitives, such as quads, points, lines, polygons… Draw as many as you can in one window. You can even create your own art with these primitives.

3. Submitting Format

Please submit your homework to sysucg2017@163.com. You subject of the email should be as same as your attachment(aka. your .zip file)

Only a .zip file should be submitted. Under the .zip file, the content should look like this:

classTpye_studentID_Name_hw?_version?/
  |— src/
  |— doc/
  |— bin/

For example, a student in required class want to submit homework2 for the second time, his .zip file should be:

  R_16214382_杨耀兴_hw2_version1.zip
    |—R_16214382_杨耀兴_hw2_version1/
       |—src/        ——放整个工程
       |—doc/        ——放report.pdf
       |—bin/        ——放可执行文件和readme

4. References

[1] Why C/C++?
C/C++ is the only common language you guys know. All of classic books and websites used C/C++ as a language for code samples. C/C++ seems to be the most popular choice in this area.
It is worth noticing that no matter what programming language you chose, the graphics theory is the same. So if you know how to make a graphics effect in one language, then it should be relatively easy to do it similarly in some different language.
Anyway, you can try other language’s OpenGL at some time —— Not in this homework.
All supported languages: https://www.khronos.org/opengl/wiki/Language_bindings

[2] freeglut project: http://freeglut.sourceforge.net/

[3] glfw project: http://www.glfw.org/

[4] Enviorment configuration: