Using images in sdl 2


I’m pretty new to SDL, and I’m wondering if there is a way to put/ remove an image from the screen, versus just using single pixels. I tried to find documentation on SDL_Image (which I think is a thing), but I couldn’t find any. Can anyone help? thanks!


You basically need to:

Initialize SDL, create a window and a renderer.
Load the image (with IMG_Load if you use SDL_Image) into a SDL_Surface
Create a SDL_Texture from the Surface

And then draw the image, using SDL_RenderCopy or something like that.

I’m pretty sure that if you Google something like “SDL2 SDL_Renderer hello world” you might get to some nice tutorials, such as this: