driverChoice.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (C) 2009-2012 Christian Stehno
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef __E_DRIVER_CHOICE_H_INCLUDED__
  5. #define __E_DRIVER_CHOICE_H_INCLUDED__
  6. #include <iostream>
  7. #include <cstdio>
  8. #include "EDriverTypes.h"
  9. #include "irrTypes.h"
  10. #include "IrrlichtDevice.h"
  11. namespace irr
  12. {
  13. //! ask user for driver
  14. static irr::video::E_DRIVER_TYPE driverChoiceConsole(bool allDrivers=true)
  15. {
  16. const char* const names[] = {"NullDriver","Software Renderer","Burning's Video","Direct3D 8.1","Direct3D 9.0c","OpenGL 1.x/2.x/3.x"};
  17. printf("Please select the driver you want:\n");
  18. irr::u32 i=0;
  19. for (i=irr::video::EDT_COUNT; i>0; --i)
  20. {
  21. if (allDrivers || (irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1))))
  22. printf(" (%c) %s\n", 'a'+irr::video::EDT_COUNT-i, names[i-1]);
  23. }
  24. char c;
  25. std::cin >> c;
  26. c = irr::video::EDT_COUNT+'a'-c;
  27. for (i=irr::video::EDT_COUNT; i>0; --i)
  28. {
  29. if (!(allDrivers || (irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1)))))
  30. --c;
  31. if ((char)i==c)
  32. return irr::video::E_DRIVER_TYPE(i-1);
  33. }
  34. return irr::video::EDT_COUNT;
  35. }
  36. } // end namespace irr
  37. #endif