SDL (Simple DirectMedia Layer)/Graphics/Rendering images

In this section, we'll demonstrate how to render an BMP image to a window. In this chapter, we'll start writing in multiple files to keep the project organised.

You can download the source code of this section in this GitLab repository. All source code is stored in this group.

We declare a  and two   pointers. We use the first one as it is rendered for the window and the second as a buffer to load the image.

Initialisation
We set the  a   using  :

Image rendering
We first load the BMP image into a  using.

Now we've loaded the image onto its surface, we'll need to blit it to another surface, the one contained by the window, using. We'll then have to update the window in order to render the image using.

Freeing the memory
Destroying the surfaces is much the same as destroying the window.

We define the time delay to be 3000 milliseconds and declare the  object as , making sure its member pointers are set to. We run the appopriate member functions and that's it!

|.