Move the OpenGL ES Camera

The camera is the user’s point of view. The first six buttons change the location of the camera: up and down, left and right, forward and backwards. The last four buttons change the direction in which the camera is pointing.

The camera is implemented as the global variable camera at the top of threedimensions.cpp. It holds a location and a direction. The ten functions up, down, left, etc. change the contents of the camera. The display function gets the current contents of the camera (the position and the direction) in the form of a matrix. It then uses this matrix as the model view matrix.

The View holds the EAGLView and the 10 buttons.

Source code in GL.zip

  1. threedimensions.cpp
  2. main.m
  3. Class GLAppDelegate
  4. Class View
  5. Class GLViewController
  6. Class EAGLView
  7. MainWindow.xib
  8. GLViewController.xib