driverChoice.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 IRR_E_DRIVER_CHOICE_H_INCLUDED
  5. #define IRR_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. /*
  45. For using an alternative camera in the examples.
  46. Try to translate the viewpoint (Maya internal CameraRotation)
  47. */
  48. static inline void switchToMayaCamera(IrrlichtDevice* device)
  49. {
  50. #if 1
  51. return;
  52. #else
  53. if (!device) return;
  54. scene::ICameraSceneNode* camera = device->getSceneManager()->getActiveCamera();
  55. if (!camera || camera->getID() == 54321) return;
  56. core::vector3df target = camera->getTarget() - camera->getPosition();
  57. core::vector3df relativeRotation = target.getHorizontalAngle();
  58. scene::ICameraSceneNode* maya = device->getSceneManager()->addCameraSceneNodeMaya(
  59. 0, -1500, 1000, 1500,
  60. 54321,
  61. target.getLength(),
  62. true,
  63. relativeRotation.X + 90, relativeRotation.Y
  64. );
  65. if (maya)
  66. {
  67. maya->setNearValue(camera->getNearValue());
  68. maya->setFarValue(camera->getFarValue());
  69. }
  70. device->getCursorControl()->setVisible(true);
  71. device->setResizable(true);
  72. #endif
  73. }
  74. } // end namespace irr
  75. #endif