How can I write a Fade In and Fade Out Effect by OpenGL ?

Usually A Introduction have FadeIn and FadeOut but I don’t know how to write it.

This may not be the best solution, however, you can simply render a full screen quad with blending enabled. To fade in start with a quad that its 100% opaque (alpha value 1.0) and transition to fully transparent (alpha value 0.0). Reverse the process for fade out. The color of the quad will be what ever color you want (you can even transtion to different textures).