I have been studying computer graphics, from the book Fundamentals of Computer Graphic (but the third edition), and I lastly read about texture mapping and shadow maps. Though, I didn't exactly understand how they function. I know there is also another type of texture map called projective texture map which allows to cast hard shadows, but how they function? On the other hand, how are soft shadows cast? And what's exactly the difference between hard and soft shadows?
Hard shadows are simple that only needs a point light.
How it's done is by rendering the scene from the point of view of the light and only keep only the depth information. This is the shadow map.
Then when doing the actual rendering you calculate the point on the triangle in world space and find where it would be on the shadow map. Then you sample the depth from the shadowmap at that point and compare it to the distance to the light.
Soft shadows are harder. They require figuring out how close you are to the edge of what would be a hard shadow and adjusting the light value based on that. There are several techniques for that. One of which is simply sampling multiple times.
@ratchetfreak's answer describes shadow mapping, however, there's another not so difficult to implement way of drawing hard shadows. The shadow volume technique uses extruded geometry plus some stencil buffer tricks to simulate the area occluded by an object. The idea behind it is to generate a volume from the light source's perspective and then render it as you would render other geometry. The resulting shadow geometry will be as accurate as your graphics hardware is capable of rendering it, so the shadows will be very clear cut. There's no simple way of producing soft shadow edges with this technique though.