CS602 Computer Graphics Assignment 4 Solution Fall 2013

Question:

Write a program in C/C++ to draw a circle on the screen using Opengl library. See the Assignment4demo    along with the assignment file. You have to draw the circle on screen. The circle should bounce at equal intervals. At each bounce the size of the circle should be reduced.  Follow the instructions given below.

Instructions:

  • The background color should be red.
  • Circle should be hollow
  • The outline of the circle should be in white color
  • The outline of the circle should be thick

Important Note:

You are required to fulfill all the requirements showed in the demo file “Assignment4demo”.

Solution:

gl.glBegin(GL.GL_LINE_LOOP);
for(int i =0; i <= 300; i++){
double angle = 2 * Math.PI * i / 300;
double x = Math.cos(angle);
double y = Math.sin(angle);
gl.glVertex2d(x,y);
}
gl.glEnd();

DOWNLOAD SOLUTION HERE
loading...