driverChoice.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "IrrlichtDevice.h"
  10. namespace irr
  11. {
  12. //! ask user for driver
  13. static irr::video::E_DRIVER_TYPE driverChoiceConsole(bool allDrivers=false)
  14. {
  15. #if defined (_IRR_IPHONE_PLATFORM_) || defined (_IRR_ANDROID_PLATFORM_)
  16. return irr::video::EDT_OGLES2;
  17. #else
  18. printf("Please select the driver you want:\n");
  19. irr::u32 i=0;
  20. char c = 'a';
  21. for (i=irr::video::EDT_COUNT; i>0; --i)
  22. {
  23. if ( allDrivers || irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1)) )
  24. {
  25. printf(" (%c) %s\n", c, irr::video::DRIVER_TYPE_NAMES[i-1]);
  26. ++c;
  27. }
  28. }
  29. char userSelection;
  30. std::cin >> userSelection;
  31. c = 'a';
  32. for (i=irr::video::EDT_COUNT; i>0; --i)
  33. {
  34. if ( allDrivers || irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1)) )
  35. {
  36. if (userSelection == c)
  37. return irr::video::E_DRIVER_TYPE(i-1);
  38. ++c;
  39. }
  40. }
  41. return irr::video::EDT_COUNT;
  42. #endif
  43. }
  44. } // end namespace irr
  45. #endif