Fix driverChoiceConsole when allDrivers is set to false.
Simply didn't work before. Is now the default - so examples should only show available drivers. Also update documentation in example 02 slightly. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5496 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
970ec0fa74
commit
d476cbe3e9
|
@ -6,7 +6,7 @@ controlled camera.
|
|||
|
||||
Please note that you should know the basics of the engine before starting this
|
||||
tutorial. Just take a short look at the first tutorial, if you haven't done
|
||||
this yet: http://irrlicht.sourceforge.net/tut001.html
|
||||
this yet: http://irrlicht.sourceforge.net/docu/example001.html
|
||||
|
||||
Lets start like the HelloWorld example: We include the irrlicht header files
|
||||
and an additional file to be able to ask the user for a driver type using the
|
||||
|
@ -38,7 +38,7 @@ easy, we use a pragma comment lib:
|
|||
#endif
|
||||
|
||||
/*
|
||||
Ok, lets start. Again, we use the main() method as start, not the WinMain().
|
||||
OK, lets start. Again, we use the main() method as start, not the WinMain().
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ int main()
|
|||
*/
|
||||
|
||||
// ask user for driver
|
||||
video::E_DRIVER_TYPE driverType=driverChoiceConsole();
|
||||
video::E_DRIVER_TYPE driverType=driverChoiceConsole(true);
|
||||
if (driverType==video::EDT_COUNT)
|
||||
return 1;
|
||||
|
||||
|
@ -75,16 +75,14 @@ int main()
|
|||
To display the Quake 3 map, we first need to load it. Quake 3 maps
|
||||
are packed into .pk3 files which are nothing else than .zip files.
|
||||
So we add the .pk3 file to our irr::io::IFileSystem. After it was added,
|
||||
we are able to read from the files in that archive as if they are
|
||||
directly stored on the disk.
|
||||
we can read from the files in that archive as if they were stored on disk.
|
||||
*/
|
||||
device->getFileSystem()->addFileArchive(getExampleMediaPath() + "map-20kdm2.pk3");
|
||||
|
||||
/*
|
||||
Now we can load the mesh by calling
|
||||
irr::scene::ISceneManager::getMesh(). We get a pointer returned to an
|
||||
irr::scene::IAnimatedMesh. As you might know, Quake 3 maps are not
|
||||
really animated, they are only a huge chunk of static geometry with
|
||||
Now we can load the mesh by calling irr::scene::ISceneManager::getMesh().
|
||||
We get a pointer returned to an irr::scene::IAnimatedMesh. Quake 3 maps are
|
||||
not really animated, they are only a chunk of static geometry with
|
||||
some materials attached. Hence the IAnimatedMesh consists of only one
|
||||
frame, so we get the "first frame" of the "animation", which is our
|
||||
quake level and create an Octree scene node with it, using
|
||||
|
@ -98,7 +96,8 @@ int main()
|
|||
driver. (There is a irr::video::IVideoDriver::getPrimitiveCountDrawn()
|
||||
method in the irr::video::IVideoDriver class). Note that this
|
||||
optimization with the Octree is only useful when drawing huge meshes
|
||||
consisting of lots of geometry.
|
||||
consisting of lots of geometry and if users can't see the whole scene at
|
||||
once.
|
||||
*/
|
||||
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
|
||||
scene::ISceneNode* node = 0;
|
||||
|
@ -108,7 +107,7 @@ int main()
|
|||
// node = smgr->addMeshSceneNode(mesh->getMesh(0));
|
||||
|
||||
/*
|
||||
Because the level was not modelled around the origin (0,0,0), we
|
||||
Because the level was not modeled around the origin (0,0,0), we
|
||||
translate the whole level a little bit. This is done on
|
||||
irr::scene::ISceneNode level using the methods
|
||||
irr::scene::ISceneNode::setPosition() (in this case),
|
||||
|
@ -119,7 +118,7 @@ int main()
|
|||
node->setPosition(core::vector3df(-1300,-144,-1249));
|
||||
|
||||
/*
|
||||
Now we only need a camera to look at the Quake 3 map.
|
||||
Now we need a camera to look at the Quake 3 map.
|
||||
We want to create a user controlled camera. There are some
|
||||
cameras available in the Irrlicht engine. For example the
|
||||
MayaCamera which can be controlled like the camera in Maya:
|
||||
|
@ -139,13 +138,13 @@ int main()
|
|||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
/*
|
||||
We have done everything, so lets draw it. We also write the current
|
||||
Everything is set up, so lets draw it. We also write the current
|
||||
frames per second and the primitives drawn into the caption of the
|
||||
window. The test for irr::IrrlichtDevice::isWindowActive() is optional,
|
||||
but prevents the engine to grab the mouse cursor after task switching
|
||||
when other programs are active. The call to
|
||||
irr::IrrlichtDevice::yield() will avoid the busy loop to eat up all CPU
|
||||
cycles when the window is not active.
|
||||
when other programs are active. The call to irr::IrrlichtDevice::yield()
|
||||
will avoid the busy loop to eat up all CPU cycles when the window is not
|
||||
active.
|
||||
*/
|
||||
int lastFPS = -1;
|
||||
|
||||
|
|
|
@ -14,36 +14,38 @@ namespace irr
|
|||
{
|
||||
|
||||
//! ask user for driver
|
||||
static irr::video::E_DRIVER_TYPE driverChoiceConsole(bool allDrivers=true)
|
||||
static irr::video::E_DRIVER_TYPE driverChoiceConsole(bool allDrivers=false)
|
||||
{
|
||||
#if defined (_IRR_IPHONE_PLATFORM_) || defined (_IRR_ANDROID_PLATFORM_)
|
||||
return irr::video::EDT_OGLES2;
|
||||
#else
|
||||
printf("Please select the driver you want:\n");
|
||||
irr::u32 i=0;
|
||||
char c;
|
||||
char c = 'a';
|
||||
|
||||
for (i=irr::video::EDT_COUNT; i>0; --i)
|
||||
{
|
||||
if (allDrivers || (irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1))))
|
||||
if ( allDrivers || irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1)) )
|
||||
{
|
||||
if (irr::video::E_DRIVER_TYPE(i-1) == irr::video::EDT_OPENGL)
|
||||
c = 'a'+irr::video::EDT_COUNT-i;
|
||||
|
||||
printf(" (%c) %s\n", 'a'+irr::video::EDT_COUNT-i, irr::video::DRIVER_TYPE_NAMES[i-1]);
|
||||
printf(" (%c) %s\n", c, irr::video::DRIVER_TYPE_NAMES[i-1]);
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
std::cin >> c;
|
||||
c = irr::video::EDT_COUNT+'a'-c;
|
||||
char userSelection;
|
||||
std::cin >> userSelection;
|
||||
c = 'a';
|
||||
|
||||
for (i=irr::video::EDT_COUNT; i>0; --i)
|
||||
{
|
||||
if (!(allDrivers || (irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1)))))
|
||||
--c;
|
||||
if ((char)i==c)
|
||||
return irr::video::E_DRIVER_TYPE(i-1);
|
||||
if ( allDrivers || irr::IrrlichtDevice::isDriverSupported(irr::video::E_DRIVER_TYPE(i-1)) )
|
||||
{
|
||||
if (userSelection == c)
|
||||
return irr::video::E_DRIVER_TYPE(i-1);
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
return irr::video::EDT_COUNT;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue