Two Squares : OpenGL

By | April 25, 2015
The following program displays two squares that can be moved around the screen using the keyboard. Clicking the left/right mouse button or the mouse wheel changes the colours of the squares: –

a) The first square can be moved left, up, down and right using the keys ‘a’, ‘w’, ‘s’ and ‘d’ respectively.

b) The second square can be moved in the four directions using the arrow keys i.e. the Up, Down, Left and Right keys.

c) Pressing ‘F1’ moves the first square to the top of the window and the second square to the bottom of the window.

d) Pressing ‘F2’ works just opposite to pressing ‘F1’.

e) Press ‘F1’ and ‘F2’ repeatedly a couple of times and you get a nice animation of two squares moving up and down repeatedly.

Two Squares - Initial State
In Motion 1
In Motion 2

The following video shows the Two Squares program in action :

Click here to view and download the source code of this project.
Click here to download Two Squares.exe only (You’ll need glut.dll for running this application. Put both the executable and glut.dll in the same folder).

(Visited 211 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *