Reputation: 650
Basically, SDL fails to acquire display mode when running inside a VirtualBox machine.
SDL_GetNumDisplayModes() fails reporting -1 then SDL_InitSubSystem(SDL_INIT_VIDEO) fails with No available video device.
int main(void)
{
int numberOfDrivers = SDL_GetNumVideoDrivers();
printf("Number of drivers: %d\n", numberOfDrivers);
for (int i = 0; i < numberOfDrivers; i++)
printf("Driver name: %s\n", SDL_GetVideoDriver(i));
int numberOfDisplays = SDL_GetNumVideoDisplays();
printf("Number of displays: %d\n", numberOfDisplays);
printf("Display 0 mode: %d\n", SDL_GetNumDisplayModes(0));
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
SDL_Log("SDL fails to initialize video subsystem!\n%s", SDL_GetError());
return 0;
}
This is the output:
Number of drivers: 2
Driver name: x11
Driver name: dummy
Number of displays: 0
Display 0 mode: -1
INFO: SDL fails to initialize video subsystem!
No available video device
Unable to initialize system
VirtualBox machine running Ubuntu 18.04 64 bit guest inside Ubuntu 18.04 64 bit host. Application is 32 bit.
Is there a way to resolve?
Upvotes: 0
Views: 2061
Reputation: 650
SOLUTION
There was 2 problems, one in the example code.
So, for No available video device error you need xorg-dev libx11-dev libgl1-mesa-glx libraries, maybe xorg-dev installs libx11-dev
Upvotes: 2