Using subset of SDL2 subsystems


I have failed to find info how to use SDL2, if one wish to use just few of its subsystems.
For example, my app needs only:
-one fullscreen window with opengl context support on various SDL supported platforms
-input (joystick, keyboard, mouse, maybe touchscreen)

I wish to avoid to include all libraries of SDL, I do not need audio, nor renderer, as I have my own.
This is a bit difficulty to me, not knowing the dependencies between the subsystems.

So instead of including SDL.h at the beginning of my app,
I would rather include only the subsystem’s headers.

These are all the include from SDL.h.
Could anybody can help me to pickup the ones, which such minimal app would need?

#include “SDL_main.h”
#include “SDL_stdinc.h”
#include “SDL_assert.h”
#include “SDL_atomic.h”
#include “SDL_audio.h”
#include “SDL_clipboard.h”
#include “SDL_cpuinfo.h”
#include “SDL_endian.h”
#include “SDL_error.h”
#include “SDL_events.h”
#include “SDL_filesystem.h”
#include “SDL_joystick.h”
#include “SDL_gamecontroller.h”
#include “SDL_haptic.h”
#include “SDL_hints.h”
#include “SDL_loadso.h”
#include “SDL_log.h”
#include “SDL_messagebox.h”
#include “SDL_mutex.h”
#include “SDL_power.h”
#include “SDL_render.h”
#include “SDL_rwops.h”
#include “SDL_system.h”
#include “SDL_thread.h”
#include “SDL_timer.h”
#include “SDL_version.h”
#include “SDL_video.h”

Thank you for the time!

Why would you do that ? :slight_smile:

You will link your app against ( dll ) anyways, and you’ll not see any great impact on performance or your binary size if you will write a bunch of includes of discrete subsystems.

If you have your own media subsystems - it’s good! Use them, don’t mess with SDL2 internals and they won’t mess with you :slight_smile:

For SDL2 OpenGL context use explicit OpenGL initialization as it’s stated in wiki.

To init only the video subsystem one can call:

 Uint32 initMask = SDL_WasInit ( 0 );
assert ( ! ( initMask & SDL_INIT_VIDEO ) ); // video must not be inited
int res = SDL_InitSubSystem ( SDL_INIT_VIDEO );
if ( 0 != res ) {
	std::cerr << "Error initializing SDL video: " << SDL_GetError() << "\n";
	exit ( -1 );

the same goes for audio, joysticks and etc.