![opengl cygwin tutorial opengl cygwin tutorial](https://web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/ec3.6.1-fig2e.png)
Each number in the star array will hold all of the information in our structure called stars. Instead of creating 50 red values, 50 green values, 50 blue values, 50 distance values and 50 angle values, we just create an array called star. Unfortunately we have more than one star to keep track of. So now we have this group of data that describes the color, distance and angle of a star on the screen. I know this sometimes is a pain, but this is the correct way to do it. You should SORT THE TRANSPARENT POLYGONS BY DEPTH and draw them AFTER THE ENTIRE SCENE HAS BEEN DRAWN, with the DEPTH BUFFER ENABLED, or you will get incorrect results.
![opengl cygwin tutorial opengl cygwin tutorial](https://s1.o7planning.com/fr/10469/images/1503949.png)
If you look at it, like in reality, all the light comming from behind these two polys (which are transparent) has to pass poly 2 first and then poly 1 before it reaches the eye of the viewer. (assuming poly 1 is nearest to the viewer, the correct way would be to draw poly 2 first and then poly 1. This is due to the fact that blending two polygons (1 and 2) in different order gives different results, i.e. Rui Martins Adds: The correct way is to draw all the transparent (with alpha < 1.0) polys after you have drawn the entire scene, and to draw them in reverse depth order (farthest first). This isn't the proper way to blend, but most the time in simple projects it will work fine. Then we set the equation, and turn off depth buffer writing when drawing transparent objects, since we still want objects behind the translucent shapes to be drawn.
![opengl cygwin tutorial opengl cygwin tutorial](https://i.ytimg.com/vi/Y4y8I-OCoUo/hqdefault.jpg)
We enable blending just like everything else. Of course if the crate was no longer behind the glass on your monitor, you would no longer see the crate, so it doesn't matter where the light is. By doing this, the only way the light would be behind the crate is if the crate was also in front of the glass on your monitor. If you could actually see the light, it would be floating in front of the glass on your monitor. We'll position the light at 2.0f on the z plane. Lets say the glass on your monitor is at 0.0f on the z plane. So we'll position the light off the screen, towards the viewer. For the third value we want to make sure the light is always in front of the crate. Because we want our light hitting directly on the front of the crate, we don't move left or right so the first value is 0.0f (no movement on x), we don't want to move up and down, so the second value is 0.0f as well. The first number is for moving left and right on the x plane, the second number is for moving up and down on the y plane, and the third number is for moving into and out of the screen on the z plane. The first three numbers are the same as glTranslate's three numbers. Finally we store the position of the light.