If you want to start learning OpenGL, see Part 1 of the answer. If you just want to get an image like the one you presented (and image editor transformation will work for you) and don't want unnecessary complications, see Part 2.
You indeed can generate such a picture with OpenGL, but it's a bit too big for the answer here. Here's the link to some (quite old) OpenGL tutorials and the second pack, all with the source code, and there you can learn and understand how to create such a program, or if needed, just take the sources and modify them slightly for your needs.
In the first pack linked above you can learn how to set up a window and render basic primitives, also how to apply transformations etc. The second pack will teach you how to apply textures (lessons 06-07, others are on advanced topics).
Keep in mind though that those lessons are outdated, and they use the deprecated FFP (fixed functionality pipeline) interface of the OpenGL, but this interface is better suited for the beginners in my opinion. Modern OpenGL applications use the programmable pipeline, where all transformation/projection matrices are filled up manually and transferred to the shaders, immediate primitive mode is unavailable (you can only send primitive data in batches), etc; this may be confusing initially.
But if you just need a picture like that, and do not want to learn how to use OpenGL, then you might want to get some image editor and use something similar to this perspective adjustment. Seems like this freeware editor also has similar adjustments available.