Lightning in OpenGL without material effect .

This is the first tutorial in Lightning in OpenGL. In this tutorial, I am going to show you how to produce a simple lightning effect in OpenGL without material effect. In later tutorial, I will discuss about material effect and also discuss about spot light. OpenGL implementations are required to have at least 8 primary lights ranging from GL_LIGHT0 to GL_LIGHT7. In order to use lighting in the code, we have to first enable lighting by calling the routine glEnable(GL_LIGHTING). A glLookAt() routine sets the camera position and we have can set the position of the lighting using glLightfv(). This routine actually sets the direction of the light, but not the actual position of the light. Though we are able to set a position for the light source, the light source behaves as if it is at an infinite distance. The following example creates a sphere and produces a simple light effect.
 Source Code



SHARE Lightning in OpenGL without material effect .

You may also like...

Leave a Reply

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