You may want to learn spherical coordinates and the mathematics behind rotation matrices. Graphics programming will seem nearly impossible without a solid understanding of trigonometry, linear algebra, and vector analysis. In your case, the camera model is easier to describe using spherical coordinates but it needs to be transformed into rectangular coordinates before you can use it in your OpenGL scene.

For the view matrix, you need a direction vector, a right vector, and the up vector. The direction vector is found by converting the horizontal and vertical angles from spherical coordinates to rectangular. The other "trigonometric" code computes the right vector. It takes the horizontal angle and rotates it by 90 degrees, which is the same thing as rotating pi / 2 radians. Taking the sin of the horizontal for x, y equal to 0, and the cos of the horizontal for z, gives the required coordinates. Finally, the up vector is just the cross product of the right and direction vectors. This gives the three vectors needed for constructing the view matrix which will update the camera.