First off, SDL requires your main function to have this exact signature: int main(int argc, char* argv[]).
Everything starts with a call to SDL_Init(SDL_INIT_EVERYTHING) which returns less than 0 on failure.
Then call SDL_CreateWindow("TITLE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN) which returns an SDL_Window*.
Next, gain access to the actual drawing surface with SDL_GetWindowSurface(WINDOW_POINTER) and store it in a SDL_Surface* for later use.
Now you can load your images from BMP files using SDL_LoadBMP("FILE_PATH") which returns an SDL_Surface* to the image. This image needs to be optimized so call SDL_ConvertSurface(SDL_Surface*, SDL_Surface->format, 0) to get a new SDL_Surface* which is optimized for the window you have. You'll need to SDL_FreeSurface(SDL_Surface*) both your non-optimized surface, as well as any surfaces still around at exiting time. Don't do anything to the SDL_GetWindowSurface one though.
You'll need to SDL_DestroyWindow(WINDOW_POINTER) and SDL_Quit() before exiting as well.
Now you'll need your main loop:
bool quit = false;
SDL_Event e;
while (!quit)
{
while (SDL_PollEvent(&e) != 0)
{
if (e.type == SDL_QUIT || (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE))
quit = true;
}
// draw
if (SDL_UpdateWindowSurface(g_window) != 0)
{
ss.str("");
ss << "Failed to update window surface: " << SDL_GetError();
LOG_FAIL(ss.str());
return -1;
}
SDL_Delay(1);
}
And with that, you can now draw loaded surfaces to the screen like so:
SDL_Rect rect;
rect.w = IMAGE_WIDTH;
rect.h = IMAGE_HEIGHT;
rect.x = 0;
rect.y = 0;
if (SDL_BlitSurface(imageSurface, nullptr, g_screenSurface, &rect) != 0)
{
ss.str("");
ss << "Failed to blit surface: " << SDL_GetError();
LOG_FAIL(ss.str());
return false;
}