SDL and C++ Class…how to separate this code?

Your question isn’t complete. Please take a look at Biffen’s comment, and post a more concrete problem.

That said, the refactor you’re looking to perform is quite simple. I’m not going to install my own copy of SDL to confirm, but here’s the approach you should be taking.

Instead of a generic file name like class.cpp/h use something more descriptive! The class going into these files is LTexture, so name your files to match.

LTexture.h

  • The LTexture class definition
  • SDL_Renderer* gRenderer

LTexture.cpp

  • Include LTexture.h
  • Every function in the LTexture class (i.e. signatures that begin with LTexture::)

Main.cpp

  • Include LTexture.h
  • Everything else

Leave a Comment