Commit 8db1da30 authored by hybrid's avatar hybrid

Merge revisions 1572:1596 from 1.4 branch: Some late bugfixes of the 1.4.2...

Merge revisions 1572:1596 from 1.4 branch: Some late bugfixes of the 1.4.2 release. Tutorial generation mechanism.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1598 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 9d3b46ab
Changes in version 1.5 (... 2008) Changes in version 1.5 (... 2008)
- WindowsCE-Bugfix - WindowsCE-Bugfix
...@@ -209,7 +208,7 @@ Changes in version 1.5 (... 2008) ...@@ -209,7 +208,7 @@ Changes in version 1.5 (... 2008)
- Finally added StarSonata patch with table element and TabControl additions. Table is based on MultiColor listbox by Acki, and has loads of changes by CuteAlien. - Finally added StarSonata patch with table element and TabControl additions. Table is based on MultiColor listbox by Acki, and has loads of changes by CuteAlien.
------------------------------------------- -------------------------------------------
Changes in version 1.4.2 (x.x.2008) Changes in version 1.4.2 (22.9.2008)
- Unified the handling of zwrite enable with transparent materials on all hw accelerated drivers. This means that all transparent materials will now disable ZWrite, ignoring the material flag. - Unified the handling of zwrite enable with transparent materials on all hw accelerated drivers. This means that all transparent materials will now disable ZWrite, ignoring the material flag.
There is a scene manager attribute, though, which will revert this behavior to the usual SMaterial driven way. Simply call There is a scene manager attribute, though, which will revert this behavior to the usual SMaterial driven way. Simply call
......
...@@ -1277,3 +1277,40 @@ New overload/missing method (completing the findLast... and find...Char methods) ...@@ -1277,3 +1277,40 @@ New overload/missing method (completing the findLast... and find...Char methods)
Changed signature (Added return value) Changed signature (Added return value)
string<T>& trim() string<T>& trim()
Changes for Version 1.4.2
-------------------------
This is once more a bugfix release of the 1.4 branch, and hence pretty API-consistent and backward compatible. The major reason to publish this release is the OpenGL bug, which made several OpenGL 2.x drivers run in SW emulation.
However, we also introduced some driver consistency fixes, which might affect your application's behavior. So read through the next points thoroughly.
SceneParameters.h (and general video driver behavior)
The way Irrlicht handles zbuffer writing with transparent materials has changed. This was an issue ever since, because the default behavior in Irrlicht is to disable writing to the z-buffer for all really transparent, i.e. blending materials. This avoids problems with intersecting faces, but can also break renderings. And this is now consistent for both OpenGL and Direct3D.
If transparent materials should use the SMaterial flag for ZWriteEnable just as other material types use the newly introduced attribute scene::ALLOW_ZWRITE_ON_TRANSPARENT like this:
SceneManager->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
All transparent materials will henceforth work as specified by the material flag, until the scenemanager attribute is set to false.
SMaterialLayer.h
The texture matrix now uses irrAllocator for memory handling. This shouldn't be noticeable from the user application (besides fixed heap corruptions on Windows machines), but is still mentioned for completeness.
ISceneNode.h
Documentation error. The docs said that children of a scene node are not visible if the node itself is set to visible. This is of course wrong, children inherit non-visibility of the parent and are hence invisible if the parent is. If the parent is visible, the visibility flag of the child determines its status.
SColor.h
Removed methods (use the unsigned versions and cast in your app if necessary)
inline s32 getRedSigned(u16 color)
inline s32 getGreenSigned(u16 color)
inline s32 getBlueSigned(u16 color)
IParticleSystemSceneNode.h
Changed default values (the old direction default was no real direction)
virtual IParticleAnimatedMeshSceneNodeEmitter* createAnimatedMeshSceneNodeEmitter(...)
virtual IParticleCylinderEmitter* createCylinderEmitter(...)
virtual IParticleMeshEmitter* createMeshEmitter(...)
IBoneSceneNode.h
Changed signature (Made const)
virtual E_BONE_SKINNING_SPACE getSkinningSpace() const=0;
IrrlichtDevice.h
Changed signature (Return value bool instead of void). Returns whether the event has been handled somewhere.
virtual bool postEventFromUser(const SEvent& event) = 0;
This diff is collapsed.
/* /** Example 002 Quake3Map
This Tutorial shows how to load a Quake 3 map into the
engine, create a SceneNode for optimizing the speed of This Tutorial shows how to load a Quake 3 map into the engine, create a
rendering and how to create a user controlled camera. SceneNode for optimizing the speed of rendering, and how to create a user
controlled camera.
Lets start like the HelloWorld example: We include Please note that you should know the basics of the engine before starting this
the irrlicht header files and an additional file to be able tutorial. Just take a short look at the first tutorial, if you haven't done
to ask the user for a driver type using the console. this yet: http://irrlicht.sourceforge.net/tut001.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
console.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include <iostream> #include <iostream>
/* /*
As already written in the HelloWorld example, in the Irrlicht As already written in the HelloWorld example, in the Irrlicht Engine everything
Engine, everything can be found in the namespace 'irr'. can be found in the namespace 'irr'. To get rid of the irr:: in front of the
To get rid of the irr:: in front of the name of every class, name of every class, we tell the compiler that we use that namespace from now
we tell the compiler that we use that namespace from now on, on, and we will not have to write that 'irr::'. There are 5 other sub
and we will not have to write that 'irr::'. namespaces 'core', 'scene', 'video', 'io' and 'gui'. Unlike in the HelloWorld
There are 5 other sub namespaces 'core', 'scene', 'video', example, we do not call 'using namespace' for these 5 other namespaces, because
'io' and 'gui'. Unlike in the HelloWorld example, in this way you will see what can be found in which namespace. But if you like,
we do not a 'using namespace' for these 5 other namespaces you can also include the namespaces like in the previous example.
because in this way you will see what can be found in which
namespace. But if you like, you can also include the namespaces
like in the previous example. Code just like you want to.
*/ */
using namespace irr; using namespace irr;
/* /*
Again, to be able to use the Irrlicht.DLL file, we need to link with the Again, to be able to use the Irrlicht.DLL file, we need to link with the
Irrlicht.lib. We could set this option in the project settings, but Irrlicht.lib. We could set this option in the project settings, but to make it
to make it easy, we use a pragma comment lib: easy, we use a pragma comment lib:
*/ */
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "Irrlicht.lib")
#endif
/* /*
Ok, lets start. Again, we use the main() method as start, not the Ok, lets start. Again, we use the main() method as start, not the WinMain().
WinMain(), because its shorter to write.
*/ */
int main() int main()
{ {
/* /*
Like in the HelloWorld example, we create an IrrlichtDevice with Like in the HelloWorld example, we create an IrrlichtDevice with
createDevice(). The difference now is that we ask the user to select createDevice(). The difference now is that we ask the user to select
which hardware accelerated driver to use. The Software device would be which video driver to use. The Software device might be
too slow to draw a huge Quake 3 map, but just for the fun of it, we make too slow to draw a huge Quake 3 map, but just for the fun of it, we make
this decision possible too. this decision possible, too.
*/ */
// ask user for driver // ask user for driver
...@@ -79,36 +82,40 @@ int main() ...@@ -79,36 +82,40 @@ int main()
/* /*
Get a pointer to the video driver and the SceneManager so that Get a pointer to the video driver and the SceneManager so that
we do not always have to write device->getVideoDriver() and we do not always have to call irr::IrrlichtDevice::getVideoDriver() and
device->getSceneManager(). irr::IrrlichtDevice::getSceneManager().
*/ */
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
/* /*
To display the Quake 3 map, we first need to load it. Quake 3 maps To display the Quake 3 map, we first need to load it. Quake 3 maps
are packed into .pk3 files wich are nothing other than .zip files. are packed into .pk3 files which are nothing else than .zip files.
So we add the .pk3 file to our FileSystem. After it was added, 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 they would we are able to read from the files in that archive as if they are
directly be stored on disk. directly stored on the disk.
*/ */
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3"); device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
/* /*
Now we can load the mesh by calling getMesh(). We get a pointer returned Now we can load the mesh by calling
to a IAnimatedMesh. As you know, Quake 3 maps are not really animated, irr::scene::ISceneManager::getMesh(). We get a pointer returned to an
they are only a huge chunk of static geometry with some materials irr::scene::IAnimatedMesh. As you might know, Quake 3 maps are not
attached. Hence the IAnimated mesh consists of only one frame, really animated, they are only a huge chunk of static geometry with
so we get the "first frame" of the "animation", which is our quake level some materials attached. Hence the IAnimatedMesh consists of only one
and create an OctTree scene node with it, using addOctTreeSceneNode(). frame, so we get the "first frame" of the "animation", which is our
The OctTree optimizes the scene a little bit, trying to draw only quake level and create an OctTree scene node with it, using
geometry which is currently visible. An alternative to the OctTree irr::scene::ISceneManager::addOctTreeSceneNode().
would be a MeshSceneNode, which would draw always the complete geometry The OctTree optimizes the scene a little bit, trying to draw only geometry
of the mesh, without optimization. Try it out: Write addMeshSceneNode which is currently visible. An alternative to the OctTree would be a
instead of addOctTreeSceneNode and compare the primitives drawn by the irr::scene::IMeshSceneNode, which would always draw the complete
video driver. (There is a getPrimitiveCountDrawn() method in the geometry of the mesh, without optimization. Try it: Use
IVideoDriver class). Note that this optimization with the Octree is only irr::scene::ISceneManager::addMeshSceneNode() instead of
useful when drawing huge meshes consisting of lots of geometry. addOctTreeSceneNode() and compare the primitives drawn by the video
driver. (There is a irr::video::IVideoDriver::getPrimitiveCountDrawn()
method in the irr::video::IVideoDriver class). Note that this
optimization with the OctTree is only useful when drawing huge meshes
consisting of lots of geometry.
*/ */
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp"); scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0; scene::ISceneNode* node = 0;
...@@ -118,43 +125,52 @@ int main() ...@@ -118,43 +125,52 @@ int main()
// node = smgr->addMeshSceneNode(mesh->getMesh(0)); // node = smgr->addMeshSceneNode(mesh->getMesh(0));
/* /*
Because the level was modelled not around the origin (0,0,0), we translate Because the level was not modelled around the origin (0,0,0), we
the whole level a little bit. 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),
irr::scene::ISceneNode::setRotation(), and
irr::scene::ISceneNode::setScale().
*/ */
if (node) if (node)
node->setPosition(core::vector3df(-1300,-144,-1249)); node->setPosition(core::vector3df(-1300,-144,-1249));
/* /*
Now we only need a Camera to look at the Quake 3 map. Now we only need a camera to look at the Quake 3 map.
And we want to create a user controlled camera. There are some We want to create a user controlled camera. There are some
different cameras available in the Irrlicht engine. For example the cameras available in the Irrlicht engine. For example the
Maya Camera which can be controlled compareable to the camera in Maya: MayaCamera which can be controlled like the camera in Maya:
Rotate with left mouse button pressed, Zoom with both buttons pressed, Rotate with left mouse button pressed, Zoom with both buttons pressed,
translate with right mouse button pressed. This could be created with translate with right mouse button pressed. This could be created with
addCameraSceneNodeMaya(). But for this example, we want to create a irr::scene::ISceneManager::addCameraSceneNodeMaya(). But for this
camera which behaves like the ones in first person shooter games (FPS). example, we want to create a camera which behaves like the ones in
first person shooter games (FPS) and hence use
irr::scene::ISceneManager::addCameraSceneNodeFPS().
*/ */
smgr->addCameraSceneNodeFPS(); smgr->addCameraSceneNodeFPS();
/* /*
The mouse cursor needs not to be visible, so we make it invisible. The mouse cursor needs not be visible, so we hide it via the
irr::IrrlichtDevice::ICursorControl.
*/ */
device->getCursorControl()->setVisible(false); device->getCursorControl()->setVisible(false);
/* /*
We have done everything, so lets draw it. We also write the current We have done everything, so lets draw it. We also write the current
frames per second and the drawn primitives to the caption of the frames per second and the primitives drawn into the caption of the
window. The 'if (device->isWindowActive())' line is optional, but window. The test for irr::IrrlichtDevice::isWindowActive() is optional,
prevents the engine render to set the position of the mouse cursor but prevents the engine to grab the mouse cursor after task switching
after task switching when other program are 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; int lastFPS = -1;
while(device->run()) while(device->run())
{
if (device->isWindowActive()) if (device->isWindowActive())
{ {
driver->beginScene(true, true, video::SColor(0,200,200,200)); driver->beginScene(true, true, video::SColor(255,200,200,200));
smgr->drawAll(); smgr->drawAll();
driver->endScene(); driver->endScene();
...@@ -171,6 +187,9 @@ int main() ...@@ -171,6 +187,9 @@ int main()
lastFPS = fps; lastFPS = fps;
} }
} }
else
device->yield();
}
/* /*
In the end, delete the Irrlicht device. In the end, delete the Irrlicht device.
...@@ -179,3 +198,6 @@ int main() ...@@ -179,3 +198,6 @@ int main()
return 0; return 0;
} }
/*
That's it. Compile and play around with the program.
**/
This diff is collapsed.
/* /** Example 004 Movement
This Tutorial shows how to move and animate SceneNodes. The This Tutorial shows how to move and animate SceneNodes. The
basic concept of SceneNodeAnimators is shown as well as manual basic concept of SceneNodeAnimators is shown as well as manual
movement of nodes using the keyboard. movement of nodes using the keyboard.
...@@ -11,15 +12,17 @@ and tell the linker to link with the .lib file. ...@@ -11,15 +12,17 @@ and tell the linker to link with the .lib file.
using namespace irr; using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "Irrlicht.lib")
#endif
/* /*
To receive events like mouse and keyboard input, or GUI events like To receive events like mouse and keyboard input, or GUI events like "the OK
"the OK button has been clicked", we need an object which is derived from the button has been clicked", we need an object which is derived from the
IEventReceiver object. There is only one method to override: OnEvent. irr::IEventReceiver object. There is only one method to override:
This method will be called by the engine once when an event happens. irr::IEventReceiver::OnEvent(). This method will be called by the engine once
What we really want to know is whether a key is being held down, when an event happens. What we really want to know is whether a key is being
and so we will remember the current state of each key. held down, and so we will remember the current state of each key.
*/ */
class MyEventReceiver : public IEventReceiver class MyEventReceiver : public IEventReceiver
{ {
...@@ -53,10 +56,11 @@ private: ...@@ -53,10 +56,11 @@ private:
/* /*
The event receiver for moving a scene node is ready. So lets just create The event receiver for keeping the pressed keys is ready, the actual responses
an Irrlicht Device and the scene node we want to move. We also create some will be made inside the render loop, right before drawing the scene. So lets
other additional scene nodes, to show that there are also some different just create an irr::IrrlichtDevice and the scene node we want to move. We also
possibilities to move and animate scene nodes. create some other additional scene nodes, to show that there are also some
different possibilities to move and animate scene nodes.
*/ */
int main() int main()
{ {
...@@ -92,14 +96,12 @@ int main() ...@@ -92,14 +96,12 @@ int main()
if (device == 0) if (device == 0)
return 1; // could not create selected driver. return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
/* /*
Create the node for moving it with the 'W' and 'S' key. We create a Create the node which will be moved with the 'W' and 'S' key. We create a
sphere node, which is a built in geometry primitive. We place the node sphere node, which is a built-in geometry primitive. We place the node
at (0,0,30) and assign a texture to it to let it look a little bit more at (0,0,30) and assign a texture to it to let it look a little bit more
interesting. Because we have no dynamic lights in this scene we disable interesting. Because we have no dynamic lights in this scene we disable
lighting for each model (otherwise the models would be black). lighting for each model (otherwise the models would be black).
...@@ -112,15 +114,14 @@ int main() ...@@ -112,15 +114,14 @@ int main()
node->setMaterialFlag(video::EMF_LIGHTING, false); node->setMaterialFlag(video::EMF_LIGHTING, false);
} }
/* /*
Now we create another node, moving using a scene node animator. Scene Now we create another node, movable using a scene node animator. Scene
node animators modify scene nodes and can be attached to any scene node node animators modify scene nodes and can be attached to any scene node
like mesh scene nodes, billboards, lights and even camera scene nodes. like mesh scene nodes, billboards, lights and even camera scene nodes.
Scene node animators are not only able to modify the position of a Scene node animators are not only able to modify the position of a
scene node, they can also animate the textures of an object for scene node, they can also animate the textures of an object for
example. We create a cube scene node and attach a 'fly circle' scene example. We create a cube scene node and attach a 'fly circle' scene
node to it, letting this node fly around our sphere scene node. node animator to it, letting this node fly around our sphere scene node.
*/ */
scene::ISceneNode* n = smgr->addCubeSceneNode(); scene::ISceneNode* n = smgr->addCubeSceneNode();
...@@ -155,14 +156,16 @@ int main() ...@@ -155,14 +156,16 @@ int main()
} }
/* /*
To make to model look right we set the frames between which the animation To make the model look right we disable lighting, set the
should loop, rotate the model around 180 degrees, and adjust the animation speed frames between which the animation should loop, rotate the
and the texture. model around 180 degrees, and adjust the animation speed and
To set the right animation (frames and speed), we would also be able to just the texture. To set the right animation (frames and speed), we
call "anms->setMD2Animation(scene::EMAT_RUN)" for the 'run' animation would also be able to just call
instead of "setFrameLoop" and "setAnimationSpeed", "anms->setMD2Animation(scene::EMAT_RUN)" for the 'run'
but this only works with MD2 animations, and so you know how to start other animations. animation instead of "setFrameLoop" and "setAnimationSpeed",
but it a good advice to use not hardcoded frame-numbers... but this only works with MD2 animations, and so you know how to
start other animations. But a good advice is to not use
hardcoded frame-numbers...
*/ */
anms->setMaterialFlag(video::EMF_LIGHTING, false); anms->setMaterialFlag(video::EMF_LIGHTING, false);
...@@ -244,3 +247,6 @@ int main() ...@@ -244,3 +247,6 @@ int main()
return 0; return 0;
} }
/*
That's it. Compile and play around with the program.
**/
/* /** Example 005 User Interface
This tutorial shows how to use the built in User Interface of This tutorial shows how to use the built in User Interface of
the Irrlicht Engine. It will give a brief overview and show the Irrlicht Engine. It will give a brief overview and show
how to create and use windows, buttons, scroll bars, static how to create and use windows, buttons, scroll bars, static
texts and list boxes. texts, and list boxes.
As always, we include the header files, and use the irrlicht As always, we include the header files, and use the irrlicht
namespaces. We also store a pointer to the Irrlicht device, namespaces. We also store a pointer to the Irrlicht device,
...@@ -55,12 +56,12 @@ public: ...@@ -55,12 +56,12 @@ public:
{ {
/* /*
If a scrollbar changed its scroll position, and it is 'our' If a scrollbar changed its scroll position, and it is
scrollbar (the one with id 104), then we change the 'our' scrollbar (the one with id 104), then we change
transparency of all gui elements. This is a very easy task: the transparency of all gui elements. This is a very
There is a skin object, in which all color settings are stored. easy task: There is a skin object, in which all color
We simply go through all colors stored in the skin and change settings are stored. We simply go through all colors
their alpha value. stored in the skin and change their alpha value.
*/ */
case EGET_SCROLL_BAR_CHANGED: case EGET_SCROLL_BAR_CHANGED:
if (id == 104) if (id == 104)
...@@ -134,9 +135,9 @@ public: ...@@ -134,9 +135,9 @@ public:
/* /*
Ok, now for the more interesting part. First, create the Ok, now for the more interesting part. First, create the Irrlicht device. As in
Irrlicht device. As in some examples before, we ask the user which some examples before, we ask the user which driver he wants to use for this
driver he wants to use for this example: example:
*/ */
int main() int main()
{ {
...@@ -224,7 +225,9 @@ int main() ...@@ -224,7 +225,9 @@ int main()
listbox = env->addListBox(rect<s32>(50, 140, 250, 210)); listbox = env->addListBox(rect<s32>(50, 140, 250, 210));
env->addEditBox(L"Editable Text", rect<s32>(350, 80, 550, 100)); env->addEditBox(L"Editable Text", rect<s32>(350, 80, 550, 100));
// add the engine logo /*
And at last, we create a nice Irrlicht Engine logo in the top left corner.
*/
env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"), env->addImage(driver->getTexture("../../media/irrlichtlogo2.png"),
position2d<int>(10,10)); position2d<int>(10,10));
...@@ -247,3 +250,6 @@ int main() ...@@ -247,3 +250,6 @@ int main()
return 0; return 0;
} }
/*
**/
/* /** Example 006 2D Graphics
This Tutorial shows how to do 2d graphics with the Irrlicht Engine. This Tutorial shows how to do 2d graphics with the Irrlicht Engine.
It shows how to draw images, keycolor based sprites, It shows how to draw images, keycolor based sprites,
transparent rectangles and different fonts. You will may consider transparent rectangles, and different fonts. You may consider
this useful if you want to make a 2d game with the engine, or if this useful if you want to make a 2d game with the engine, or if
you want to draw a cool interface or head up display for your 3d game. you want to draw a cool interface or head up display for your 3d game.
...@@ -13,12 +14,13 @@ and tell the linker to link with the .lib file. ...@@ -13,12 +14,13 @@ and tell the linker to link with the .lib file.
using namespace irr; using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "Irrlicht.lib")
#endif
/* /*
At first, we let the user select the driver type, then At first, we let the user select the driver type, then start up the engine, set
start up the engine, set a caption, and get a pointer a caption, and get a pointer to the video driver.
to the video driver.
*/ */
int main() int main()
{ {
...@@ -57,58 +59,59 @@ int main() ...@@ -57,58 +59,59 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
/* /*
All 2d graphics in this example are put together into one texture, All 2d graphics in this example are put together into one texture,
2ddemo.bmp. Because we want to draw colorkey based sprites, we need 2ddemo.bmp. Because we want to draw colorkey based sprites, we need to
to load this texture and tell the engine, which load this texture and tell the engine, which part of it should be
part of it should be transparent based on a colorkey. In this example, transparent based on a colorkey.
we don't tell it the color directly, we just say "Hey Irrlicht Engine,
you'll find the color I want at position (0,0) on the texture.". In this example, we don't tell it the color directly, we just say "Hey
Instead, it would be also possible to call Irrlicht Engine, you'll find the color I want at position (0,0) on the
texture.". Instead, it would be also possible to call
driver->makeColorKeyTexture(images, video::SColor(0,0,0,0)), to make driver->makeColorKeyTexture(images, video::SColor(0,0,0,0)), to make
e.g. all black pixels transparent. Please note, that makeColorKeyTexture e.g. all black pixels transparent. Please note that
just creates an alpha channel based on the color. makeColorKeyTexture just creates an alpha channel based on the color.
*/ */
video::ITexture* images = driver->getTexture("../../media/2ddemo.bmp"); video::ITexture* images = driver->getTexture("../../media/2ddemo.bmp");
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0)); driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
/*
/* To be able to draw some text with two different fonts, we first load
To be able to draw some text with two different fonts, we load them. them. Ok, we load just one. As the first font we just use the default
Ok, we load just one, as first font we just use the default font which is font which is built into the engine. Also, we define two rectangles
built into the engine. which specify the position of the images of the red imps (little flying
Also, we define two rectangles, which specify the position of the creatures) in the texture.
images of the red imps (little flying creatures) in the texture. */
*/
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont(); gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
gui::IGUIFont* font2 = device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp"); gui::IGUIFont* font2 = device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp");
core::rect<s32> imp1(349,15,385,78); core::rect<s32> imp1(349,15,385,78);
core::rect<s32> imp2(387,15,423,78); core::rect<s32> imp2(387,15,423,78);
/*
/*
Everything is prepared, now we can draw everything in the draw loop, Everything is prepared, now we can draw everything in the draw loop,
between the begin scene and end scene calls. In this example, we between the begin scene and end scene calls. In this example, we are
are just doing 2d graphics, but it would be no problem to mix them just doing 2d graphics, but it would be no problem to mix them with 3d
with 3d graphics. Just try it out, and draw some 3d vertices or set graphics. Just try it out, and draw some 3d vertices or set up a scene
up a scene with the scene manager and draw it. with the scene manager and draw it.
*/ */
while(device->run() && driver) while(device->run() && driver)
{ {
if (device->isWindowActive()) if (device->isWindowActive())
{ {
u32 time = device->getTimer()->getTime(); u32 time = device->getTimer()->getTime();
driver->beginScene(true, true, video::SColor(0,120,102,136)); driver->beginScene(true, true, video::SColor(255,120,102,136));
/* /*
First, we draw 3 sprites, using the alpha channel we created with First, we draw 3 sprites, using the alpha channel we
makeColorKeyTexture. The last parameter specifiys that the drawing created with makeColorKeyTexture. The last parameter
method should use thiw alpha channel. The parameter before the last specifies that the drawing method should use this alpha
one specifies a color, with wich the sprite should be colored. channel. The last-but-one parameter specifies a
(255,255,255,255) is full white, so the sprite will look like the color, with which the sprite should be colored.
original. The third sprite is drawed colored based on the time. (255,255,255,255) is full white, so the sprite will
look like the original. The third sprite is drawn
with the red channel modulated based on the time.
*/ */
// draw fire & dragons background world // draw fire & dragons background world
...@@ -127,7 +130,8 @@ int main() ...@@ -127,7 +130,8 @@ int main()
video::SColor(255,(time) % 255,255,255), true); video::SColor(255,(time) % 255,255,255), true);
/* /*
Drawing text is really simple. The code should be self explanatory. Drawing text is really simple. The code should be self
explanatory.
*/ */
// draw some text // draw some text
...@@ -143,9 +147,9 @@ int main() ...@@ -143,9 +147,9 @@ int main()
video::SColor(255,time % 255,time % 255,255)); video::SColor(255,time % 255,time % 255,255));
/* /*
At last, we draw the Irrlicht Engine logo (without using a color or At last, we draw the Irrlicht Engine logo (without
an alpha channel) and a transparent 2d Rectangle at the position of using a color or an alpha channel) and a transparent 2d
the mouse cursor. Rectangle at the position of the mouse cursor.
*/ */
// draw logo // draw logo
...@@ -161,11 +165,11 @@ int main() ...@@ -161,11 +165,11 @@ int main()
} }
} }
/*
That's all, it was not really difficult, I hope.
*/
device->drop(); device->drop();
return 0; return 0;
} }
/*
That's all. I hope it was not too difficult.
**/
This diff is collapsed.
This diff is collapsed.
/* /** Example 009 Mesh Viewer
This tutorial show how to create a more complex application with the engine. We construct
a simple mesh viewer using the user interface API and the scenemanagement of Irrlicht. This tutorial show how to create a more complex application with the engine.
The tutorial show how to create and use Buttons, Windows, Toolbars, Menus, ComboBoxes, We construct a simple mesh viewer using the user interface API and the
Tabcontrols, Editboxes, Images, MessageBoxes, SkyBoxes, and how to parse XML files scene management of Irrlicht. The tutorial show how to create and use Buttons,
with the integrated XML reader of the engine. Windows, Toolbars, Menus, ComboBoxes, Tabcontrols, Editboxes, Images,
MessageBoxes, SkyBoxes, and how to parse XML files with the integrated XML
We start like in most other tutorials: Include all nesessary header files, add a reader of the engine.
comment to let the engine be linked with the right .lib file in Visual Studio,
and deklare some global variables. We also add two 'using namespece' statements, so We start like in most other tutorials: Include all nesessary header files, add
we do not need to write the whole names of all classes. In this tutorial, we use a a comment to let the engine be linked with the right .lib file in Visual
lot stuff from the gui namespace. Studio, and declare some global variables. We also add two 'using namespace'
statements, so we do not need to write the whole names of all classes. In this
tutorial, we use a lot stuff from the gui namespace.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include <iostream> #include <iostream>
...@@ -21,6 +23,9 @@ using namespace gui; ...@@ -21,6 +23,9 @@ using namespace gui;
#pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "Irrlicht.lib")
/*
Some global variables used later on
*/
IrrlichtDevice *Device = 0; IrrlichtDevice *Device = 0;
core::stringc StartUpModelFile; core::stringc StartUpModelFile;
core::stringw MessageText; core::stringw MessageText;
...@@ -31,7 +36,7 @@ scene::ISceneNode* SkyBox = 0; ...@@ -31,7 +36,7 @@ scene::ISceneNode* SkyBox = 0;
scene::ICameraSceneNode* Camera[2] = { 0, 0}; scene::ICameraSceneNode* Camera[2] = { 0, 0};
/* /*
toggles between various cameras Toggle between various cameras
*/ */
void setActiveCamera ( scene::ICameraSceneNode* newActive ) void setActiveCamera ( scene::ICameraSceneNode* newActive )
{ {
...@@ -45,10 +50,10 @@ void setActiveCamera ( scene::ICameraSceneNode* newActive ) ...@@ -45,10 +50,10 @@ void setActiveCamera ( scene::ICameraSceneNode* newActive )
} }
/* /*
The three following functions do several stuff used by the mesh viewer. The three following functions do several stuff used by the mesh viewer. The
The first function showAboutText() simply displays a messagebox with a caption first function showAboutText() simply displays a messagebox with a caption and
and a message text. The texts will be stored in the MessageText and a message text. The texts will be stored in the MessageText and Caption
Caption variables at startup. variables at startup.
*/ */
void showAboutText() void showAboutText()
{ {
...@@ -60,9 +65,9 @@ void showAboutText() ...@@ -60,9 +65,9 @@ void showAboutText()
/* /*
The second function loadModel() loads a model and displays it using an The second function loadModel() loads a model and displays it using an
addAnimatedMeshSceneNode and the scene manager. Nothing difficult. It also addAnimatedMeshSceneNode and the scene manager. Nothing difficult. It also
displays a short message box, if the model could not be loaded. displays a short message box, if the model could not be loaded.
*/ */
void loadModel(const c8* fn) void loadModel(const c8* fn)
{ {
...@@ -138,9 +143,9 @@ void loadModel(const c8* fn) ...@@ -138,9 +143,9 @@ void loadModel(const c8* fn)
/* /*
Finally, the third function creates a toolbox window. In this simple mesh viewer, Finally, the third function creates a toolbox window. In this simple mesh
this toolbox only contains a tab control with three edit boxes for changing viewer, this toolbox only contains a tab control with three edit boxes for
the scale of the displayed model. changing the scale of the displayed model.
*/ */
void createToolBox() void createToolBox()
{ {
...@@ -170,7 +175,7 @@ void createToolBox() ...@@ -170,7 +175,7 @@ void createToolBox()
// add senseless checkbox // add senseless checkbox
env->addCheckBox(true, core::rect<s32>(10,220,200,240), t1, -1, L"Senseless Checkbox"); env->addCheckBox(true, core::rect<s32>(10,220,200,240), t1, -1, L"Senseless Checkbox");
// add undocumentated transparent control // add undocumented transparent control
env->addStaticText(L"Transparent Control:", core::rect<s32>(10,240,150,260), true, false, t1); env->addStaticText(L"Transparent Control:", core::rect<s32>(10,240,150,260), true, false, t1);
IGUIScrollBar* scrollbar = env->addScrollBar(true, core::rect<s32>(10,260,150,275), t1, 104); IGUIScrollBar* scrollbar = env->addScrollBar(true, core::rect<s32>(10,260,150,275), t1, 104);
scrollbar->setMax(255); scrollbar->setMax(255);
...@@ -183,10 +188,10 @@ void createToolBox() ...@@ -183,10 +188,10 @@ void createToolBox()
/* /*
To get all the events sent by the GUI Elements, we need to create an event To get all the events sent by the GUI Elements, we need to create an event
receiver. This one is really simple. If an event occurs, it checks the id receiver. This one is really simple. If an event occurs, it checks the id of
of the caller and the event type, and starts an action based on these values. the caller and the event type, and starts an action based on these values. For
For example, if a menu item with id 100 was selected, if opens a file-open-dialog. example, if a menu item with id 100 was selected, if opens a file-open-dialog.
*/ */
class MyEventReceiver : public IEventReceiver class MyEventReceiver : public IEventReceiver
{ {
...@@ -411,14 +416,14 @@ public: ...@@ -411,14 +416,14 @@ public:
/* /*
Most of the hard work is done. We only need to create the Irrlicht Engine device Most of the hard work is done. We only need to create the Irrlicht Engine
and all the buttons, menus and toolbars. device and all the buttons, menus and toolbars. We start up the engine as
We start up the engine as usual, using createDevice(). To make our application usual, using createDevice(). To make our application catch events, we set our
catch events, we set our eventreceiver as parameter. The #ifdef WIN32 preprocessor eventreceiver as parameter. The #ifdef WIN32 preprocessor commands are not
commands are not necesarry, but I included them to make the tutorial use DirectX on necessary, but I included them to make the tutorial use DirectX on Windows and
Windows and OpenGL on all other platforms like Linux. OpenGL on all other platforms like Linux. As you can see, there is also a
As you can see, there is also a unusual call to IrrlichtDevice::setResizeAble(). unusual call to IrrlichtDevice::setResizeAble(). This makes the render window
This makes the render window resizeable, which is quite useful for a mesh viewer. resizeable, which is quite useful for a mesh viewer.
*/ */
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
...@@ -474,6 +479,7 @@ int main(int argc, char* argv[]) ...@@ -474,6 +479,7 @@ int main(int argc, char* argv[])
The next step is to read the configuration file. It is stored in the xml The next step is to read the configuration file. It is stored in the xml
format and looks a little bit like this: format and looks a little bit like this:
@verbatim
<?xml version="1.0"?> <?xml version="1.0"?>
<config> <config>
<startUpModel file="some filename" /> <startUpModel file="some filename" />
...@@ -481,6 +487,7 @@ int main(int argc, char* argv[]) ...@@ -481,6 +487,7 @@ int main(int argc, char* argv[])
Hello! Hello!
</messageText> </messageText>
</config> </config>
@endverbatim
We need the data stored in there to be written into the global variables We need the data stored in there to be written into the global variables
StartUpModelFile, MessageText and Caption. This is now done using the StartUpModelFile, MessageText and Caption. This is now done using the
...@@ -489,15 +496,15 @@ int main(int argc, char* argv[]) ...@@ -489,15 +496,15 @@ int main(int argc, char* argv[])
// read configuration from xml file // read configuration from xml file
io::IXMLReader* xml = Device->getFileSystem()->createXMLReader( io::IXMLReader* xml = Device->getFileSystem()->createXMLReader("config.xml");
"config.xml");
while(xml && xml->read()) while(xml && xml->read())
{ {
switch(xml->getNodeType()) switch(xml->getNodeType())
{ {
case io::EXN_TEXT: case io::EXN_TEXT:
// in this xml file, the only text which occurs is the messageText // in this xml file, the only text which occurs is the
// messageText
MessageText = xml->getNodeData(); MessageText = xml->getNodeData();
break; break;
case io::EXN_ELEMENT: case io::EXN_ELEMENT:
...@@ -519,12 +526,12 @@ int main(int argc, char* argv[]) ...@@ -519,12 +526,12 @@ int main(int argc, char* argv[])
StartUpModelFile = argv[1]; StartUpModelFile = argv[1];
/* /*
That wasn't difficult. Now we'll set a nicer font and create the That wasn't difficult. Now we'll set a nicer font and create the Menu.
Menu. It is possible to create submenus for every menu item. The call It is possible to create submenus for every menu item. The call
menu->addItem(L"File", -1, true, true); for example adds a new menu menu->addItem(L"File", -1, true, true); for example adds a new menu
Item with the name "File" and the id -1. The following parameter says Item with the name "File" and the id -1. The following parameter says
that the menu item should be enabled, and the last one says, that that the menu item should be enabled, and the last one says, that there
there should be a submenu. The submenu can now be accessed with should be a submenu. The submenu can now be accessed with
menu->getSubMenu(0), because the "File" entry is the menu item with menu->getSubMenu(0), because the "File" entry is the menu item with
index 0. index 0.
*/ */
...@@ -578,9 +585,8 @@ int main(int argc, char* argv[]) ...@@ -578,9 +585,8 @@ int main(int argc, char* argv[])
submenu->addItem(L"About", 500); submenu->addItem(L"About", 500);
/* /*
Below the toolbar, we want a toolbar, onto which we can place Below the menu we want a toolbar, onto which we can place colored
colored buttons and important looking stuff like a senseless buttons and important looking stuff like a senseless combobox.
combobox.
*/ */
// create toolbar // create toolbar
...@@ -609,10 +615,10 @@ int main(int argc, char* argv[]) ...@@ -609,10 +615,10 @@ int main(int argc, char* argv[])
box->addItem(L"Isotropic"); box->addItem(L"Isotropic");
/* /*
To make the editor look a little bit better, we disable transparent To make the editor look a little bit better, we disable transparent gui
gui elements, and add a Irrlicht Engine logo. In addition, a text elements, and add an Irrlicht Engine logo. In addition, a text showing
showing the current frame per second value is created and the current frames per second value is created and the window caption is
the window caption is changed. changed.
*/ */
// disable alpha // disable alpha
...@@ -640,11 +646,11 @@ int main(int argc, char* argv[]) ...@@ -640,11 +646,11 @@ int main(int argc, char* argv[])
Device->setWindowCaption(Caption.c_str()); Device->setWindowCaption(Caption.c_str());
/* /*
That's nearly the whole application. We simply show the about That's nearly the whole application. We simply show the about message
message box at start up, and load the first model. To make everything box at start up, and load the first model. To make everything look
look better, a skybox is created and a user controled camera, better, a skybox is created and a user controled camera, to make the
to make the application a little bit more interactive. Finally, application a little bit more interactive. Finally, everything is drawn
everything is drawed in a standard drawing loop. in a standard drawing loop.
*/ */
// show about message box and load default model // show about message box and load default model
...@@ -704,3 +710,6 @@ int main(int argc, char* argv[]) ...@@ -704,3 +710,6 @@ int main(int argc, char* argv[])
Device->drop(); Device->drop();
return 0; return 0;
} }
/*
**/
This diff is collapsed.
This diff is collapsed.
/* /** Example 012 Terrain Rendering
This tutorial will briefly show how to use the terrain renderer of Irrlicht. It will also
show the terrain renderer triangle selector to be able to do collision detection with This tutorial will briefly show how to use the terrain renderer of Irrlicht. It
terrain. will also show the terrain renderer triangle selector to be able to do
collision detection with terrain.
Note that the Terrain Renderer in Irrlicht is based on Spintz' GeoMipMapSceneNode, lots
of thanks go to him. Note that the Terrain Renderer in Irrlicht is based on Spintz'
DeusXL provided a new elegant simple solution for building larger area on small heightmaps GeoMipMapSceneNode, lots of thanks go to him. DeusXL provided a new elegant
-> terrain smoothing. simple solution for building larger area on small heightmaps -> terrain
In the beginning there is nothing special. We include the needed header files and create smoothing.
an event listener to listen if the user presses the 'W' key so we can switch to wireframe
mode and if he presses 'D' we toggle to material between solid and detail mapped. In the beginning there is nothing special. We include the needed header files
and create an event listener to listen if the user presses a key: The 'W' key
switches to wireframe mode, the 'P' key to pointcloud mode, and the 'D' key
toggles between solid and detail mapped material.
*/ */
#include <irrlicht.h> #include <irrlicht.h>
#include <iostream> #include <iostream>
...@@ -134,16 +137,19 @@ int main() ...@@ -134,16 +137,19 @@ int main()
/* /*
Here comes the terrain renderer scene node: We add it just like any Here comes the terrain renderer scene node: We add it just like any
other scene node to the scene using ISceneManager::addTerrainSceneNode(). other scene node to the scene using
The only parameter we use is a file name to the heightmap we use. A heightmap ISceneManager::addTerrainSceneNode(). The only parameter we use is a
is simply a gray scale texture. The terrain renderer loads it and creates file name to the heightmap we use. A heightmap is simply a gray scale
the 3D terrain from it. texture. The terrain renderer loads it and creates the 3D terrain from
To make the terrain look more big, we change the scale factor of it to (40, 4.4, 40). it.
Because we don't have any dynamic lights in the scene, we switch off the lighting,
and we set the file terrain-texture.jpg as texture for the terrain and To make the terrain look more big, we change the scale factor of
detailmap3.jpg as second texture, called detail map. At last, we set it to (40, 4.4, 40). Because we don't have any dynamic lights in the
the scale values for the texture: The first texture will be repeated only one time over scene, we switch off the lighting, and we set the file
the whole terrain, and the second one (detail map) 20 times. terrain-texture.jpg as texture for the terrain and detailmap3.jpg as
second texture, called detail map. At last, we set the scale values for
the texture: The first texture will be repeated only one time over the
whole terrain, and the second one (detail map) 20 times.
*/ */
// add terrain scene node // add terrain scene node
...@@ -154,7 +160,7 @@ int main() ...@@ -154,7 +160,7 @@ int main()
core::vector3df(0.f, 0.f, 0.f), // position core::vector3df(0.f, 0.f, 0.f), // position
core::vector3df(0.f, 0.f, 0.f), // rotation core::vector3df(0.f, 0.f, 0.f), // rotation
core::vector3df(40.f, 4.4f, 40.f), // scale core::vector3df(40.f, 4.4f, 40.f), // scale
video::SColor ( 255, 255, 255, 255 ), // vertexColor, video::SColor ( 255, 255, 255, 255 ), // vertexColor
5, // maxLOD 5, // maxLOD
scene::ETPS_17, // patchSize scene::ETPS_17, // patchSize
4 // smoothFactor 4 // smoothFactor
...@@ -194,9 +200,10 @@ int main() ...@@ -194,9 +200,10 @@ int main()
anim->drop(); anim->drop();
/* /*
To make the user be able to switch between normal and wireframe mode, we create To make the user be able to switch between normal and wireframe mode,
an instance of the event reciever from above and let Irrlicht know about it. In we create an instance of the event reciever from above and let Irrlicht
addition, we add the skybox which we already used in lots of Irrlicht examples. know about it. In addition, we add the skybox which we already used in
lots of Irrlicht examples.
*/ */
// create event receiver // create event receiver
...@@ -218,7 +225,7 @@ int main() ...@@ -218,7 +225,7 @@ int main()
/* /*
That's it, draw everything. Now you know how to use terrain in Irrlicht. That's it, draw everything.
*/ */
int lastFPS = -1; int lastFPS = -1;
...@@ -256,3 +263,6 @@ int main() ...@@ -256,3 +263,6 @@ int main()
return 0; return 0;
} }
/*
Now you know how to use terrain in Irrlicht.
**/
/* /** Example 013 Render To Texture
This tutorial shows how to render to a texture using Irrlicht. Render to texture is a feature with which
it is possible to create nice special effects. In addition, this tutorial shows how to enable specular This tutorial shows how to render to a texture using Irrlicht. Render to
highlights. texture is a feature with which it is possible to create nice special effects.
In addition, this tutorial shows how to enable specular highlights.
In the beginning, everything as usual. Include the needed headers, ask the user for the rendering In the beginning, everything as usual. Include the needed headers, ask the user
driver, create the Irrlicht Device: for the rendering driver, create the Irrlicht Device:
*/ */
#include <irrlicht.h> #include <irrlicht.h>
...@@ -54,10 +55,10 @@ int main() ...@@ -54,10 +55,10 @@ int main()
/* /*
Now, we load an animated mesh to be displayed. As in most examples, Now, we load an animated mesh to be displayed. As in most examples,
we'll take the fairy md2 model. The difference here: We set the shininess we'll take the fairy md2 model. The difference here: We set the
of the model to a value other than 0 which is the default value. This shininess of the model to a value other than 0 which is the default
enables specular highlights on the model if dynamic lighting is on. value. This enables specular highlights on the model if dynamic
The value influences the size of the highlights. lighting is on. The value influences the size of the highlights.
*/ */
// load and display animated fairy mesh // load and display animated fairy mesh
...@@ -75,9 +76,10 @@ int main() ...@@ -75,9 +76,10 @@ int main()
} }
/* /*
To make specular highlights appear on the model, we need a dynamic light in the scene. To make specular highlights appear on the model, we need a dynamic
We add one directly in vicinity of the model. In addition, to make the model not that light in the scene. We add one directly in vicinity of the model. In
dark, we set the ambient light to gray. addition, to make the model not that dark, we set the ambient light to
gray.
*/ */
// add white light // add white light
...@@ -88,8 +90,9 @@ int main() ...@@ -88,8 +90,9 @@ int main()
smgr->setAmbientLight(video::SColor(0,60,60,60)); smgr->setAmbientLight(video::SColor(0,60,60,60));
/* /*
The next is just some standard stuff: Add a user controlled camera to the scene, disable The next is just some standard stuff: Add a user controlled camera to
mouse cursor, and add a test cube and let it rotate to make the scene more interesting. the scene, disable mouse cursor, and add a test cube and let it rotate
to make the scene more interesting.
*/ */
// add fps camera // add fps camera
...@@ -115,14 +118,16 @@ int main() ...@@ -115,14 +118,16 @@ int main()
device->setWindowCaption(L"Irrlicht Engine - Render to Texture and Specular Highlights example"); device->setWindowCaption(L"Irrlicht Engine - Render to Texture and Specular Highlights example");
/* /*
To test out the render to texture feature, we need a render target texture. These are not To test out the render to texture feature, we need a render target
like standard textures, but need to be created first. To create one, we call texture. These are not like standard textures, but need to be created
IVideoDriver::createRenderTargetTexture() and specify the size of the texture. Please first. To create one, we call IVideoDriver::createRenderTargetTexture()
don't use sizes bigger than the frame buffer for this, because the render target shares and specify the size of the texture. Please don't use sizes bigger than
the zbuffer with the frame buffer. And because we want to render the scene not from the the frame buffer for this, because the render target shares the zbuffer
user camera into the texture, we add another, fixed camera to the scene. But before we with the frame buffer. And because we want to render the scene not from
do all this, we check if the current running driver is able to render to textures. If the user camera into the texture, we add another fixed camera to the
it is not, we simply display a warning text. scene. But before we do all this, we check if the current running
driver is able to render to textures. If it is not, we simply display a
warning text.
*/ */
// create render target // create render target
...@@ -156,11 +161,12 @@ int main() ...@@ -156,11 +161,12 @@ int main()
} }
/* /*
Nearly finished. Now we need to draw everything. Every frame, we draw the scene twice. Nearly finished. Now we need to draw everything. Every frame, we draw
Once from the fixed camera into the render target texture and once as usual. When rendering the scene twice. Once from the fixed camera into the render target
into the render target, we need to disable the visibilty of the test cube, because it has texture and once as usual. When rendering into the render target, we
the render target texture applied to it. need to disable the visibilty of the test cube, because it has the
That's, wasn't quite complicated I hope. :) render target texture applied to it. That's it, wasn't too complicated
I hope. :)
*/ */
int lastFPS = -1; int lastFPS = -1;
...@@ -218,3 +224,6 @@ int main() ...@@ -218,3 +224,6 @@ int main()
device->drop(); // drop device device->drop(); // drop device
return 0; return 0;
} }
/*
**/
// this example only runs in windows and demonstrates that Irrlicht /** Example 014 Win32 Window
// can run inside a win32 window.
This example only runs under MS Windows and demonstrates that Irrlicht can
render inside a win32 window. MFC and .NET Windows.Forms windows are possible,
too.
In the begining, we create a windows window using the windows API. I'm not
going to explain this code, because it is windows specific. See the MSDN or a
windows book for details.
*/
#include <irrlicht.h> #include <irrlicht.h>
#ifndef _IRR_WINDOWS_ #ifndef _IRR_WINDOWS_
...@@ -41,9 +49,6 @@ static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message, WPARAM wParam, LP ...@@ -41,9 +49,6 @@ static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message, WPARAM wParam, LP
} }
int main() int main()
//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpre, LPSTR cmd, int cc) //int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpre, LPSTR cmd, int cc)
{ {
...@@ -99,6 +104,12 @@ int main() ...@@ -99,6 +104,12 @@ int main()
HWND hIrrlichtWindow = CreateWindow("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, HWND hIrrlichtWindow = CreateWindow("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
50, 80, 320, 220, hWnd, NULL, hInstance, NULL); 50, 80, 320, 220, hWnd, NULL, hInstance, NULL);
/*
So now that we have some window, we can create an Irrlicht device
inside of it. We use Irrlicht createEx() function for this. We only
need the handle (HWND) to that window, set it as windowsID parameter
and start up the engine as usual. That's it.
*/
// create irrlicht device in the button window // create irrlicht device in the button window
irr::SIrrlichtCreationParameters param; irr::SIrrlichtCreationParameters param;
...@@ -141,13 +152,17 @@ int main() ...@@ -141,13 +152,17 @@ int main()
// do message queue // do message queue
// Instead of this, you can also simply use your own message loop /*
// using GetMessage, DispatchMessage and whatever. Calling Now the only thing missing is the drawing loop using
// Device->run() will cause Irrlicht to dispatch messages internally too. IrrlichtDevice::run(). We do this as usual. But instead of this, there
// You need not call Device->run() if you want to do your own message is another possibility: You can also simply use your own message loop
// dispatching loop, but Irrlicht will not be able to fetch using GetMessage, DispatchMessage and whatever. Calling
// user input then and you have to do it on your own using the window Device->run() will cause Irrlicht to dispatch messages internally too.
// messages, DirectInput, or whatever. You need not call Device->run() if you want to do your own message
dispatching loop, but Irrlicht will not be able to fetch user input
then and you have to do it on your own using the window messages,
DirectInput, or whatever.
*/
while (device->run()) while (device->run())
{ {
...@@ -156,8 +171,10 @@ int main() ...@@ -156,8 +171,10 @@ int main()
driver->endScene(); driver->endScene();
} }
// the alternative, own message dispatching loop without Device->run() would /*
// look like this: The alternative, own message dispatching loop without Device->run()
would look like this:
*/
/*MSG msg; /*MSG msg;
while (true) while (true)
...@@ -187,3 +204,6 @@ int main() ...@@ -187,3 +204,6 @@ int main()
} }
#endif // if windows #endif // if windows
/*
That's it, Irrlicht now runs in your own windows window.
**/
/* /** Example 015 Loading Scenes from .irr Files
Since version 1.1, Irrlicht is able to save and load Since version 1.1, Irrlicht is able to save and load
the full scene graph into an .irr file, an xml based the full scene graph into an .irr file, an xml based
format. There is an editor available to edit format. There is an editor available to edit
those files, named irrEdit on http://www.ambiera.com/irredit, those files, named irrEdit (http://www.ambiera.com/irredit)
which can also be used as world and particle editor. which can also be used as world and particle editor.
This tutorial shows how to use .irr files. This tutorial shows how to use .irr files.
...@@ -13,7 +14,9 @@ Lets start: Create an Irrlicht device and setup the window. ...@@ -13,7 +14,9 @@ Lets start: Create an Irrlicht device and setup the window.
#include <iostream> #include <iostream>
using namespace irr; using namespace irr;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib") #pragma comment(lib, "Irrlicht.lib")
#endif
int main() int main()
{ {
...@@ -53,30 +56,35 @@ int main() ...@@ -53,30 +56,35 @@ int main()
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
/* Now load our .irr file. /*
.irr files can store the whole scene graph including animators, materials Now load our .irr file.
and particle systems. And there is also the possibility to store arbitrary .irr files can store the whole scene graph including animators,
user data for every scene node in that file. To keep this materials and particle systems. And there is also the possibility to
example simple, we are simply loading the scene here. See the documentation store arbitrary user data for every scene node in that file. To keep
at ISceneManager::loadScene and ISceneManager::saveScene for more information. this example simple, we are simply loading the scene here. See the
So to load and display a complicated huge scene, we only need a single call documentation at ISceneManager::loadScene and ISceneManager::saveScene
to loadScene(). for more information. So to load and display a complicated huge scene,
we only need a single call to loadScene().
*/ */
// load the scene // load the scene
smgr->loadScene("../../media/example.irr"); smgr->loadScene("../../media/example.irr");
// Now we'll create a camera, and give it a collision response animator /*
// that's built from the mesh nodes in the scene we just loaded. Now we'll create a camera, and give it a collision response animator
that's built from the mesh nodes in the scene we just loaded.
*/
scene::ICameraSceneNode * camera = smgr->addCameraSceneNodeFPS(0, 50, 100); scene::ICameraSceneNode * camera = smgr->addCameraSceneNodeFPS(0, 50, 100);
// Create a meta triangle selector to hold several triangle selectors. // Create a meta triangle selector to hold several triangle selectors.
scene::IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector(); scene::IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();
// Now we will find all the nodes in the scene and create triangle /*
// selectors for all suitable nodes. Typically, you would want to make a Now we will find all the nodes in the scene and create triangle
// more informed decision about which nodes to performs collision checks selectors for all suitable nodes. Typically, you would want to make a
// on; you could capture that information in the node name or Id. more informed decision about which nodes to performs collision checks
on; you could capture that information in the node name or Id.
*/
core::array<scene::ISceneNode *> nodes; core::array<scene::ISceneNode *> nodes;
smgr->getSceneNodesFromType(scene::ESNT_ANY, nodes); // Find all nodes smgr->getSceneNodesFromType(scene::ESNT_ANY, nodes); // Find all nodes
...@@ -88,7 +96,8 @@ int main() ...@@ -88,7 +96,8 @@ int main()
switch(node->getType()) switch(node->getType())
{ {
case scene::ESNT_CUBE: case scene::ESNT_CUBE:
case scene::ESNT_ANIMATED_MESH: // Because the selector won't animate with the mesh, case scene::ESNT_ANIMATED_MESH:
// Because the selector won't animate with the mesh,
// and is only being used for camera collision, we'll just use an approximate // and is only being used for camera collision, we'll just use an approximate
// bounding box instead of ((scene::IAnimatedMeshSceneNode*)node)->getMesh(0) // bounding box instead of ((scene::IAnimatedMeshSceneNode*)node)->getMesh(0)
selector = smgr->createTriangleSelectorFromBoundingBox(node); selector = smgr->createTriangleSelectorFromBoundingBox(node);
...@@ -121,8 +130,10 @@ int main() ...@@ -121,8 +130,10 @@ int main()
} }
} }
// Now that the mesh scene nodes have had triangle selectors created and added /*
// to the meta selector, create a collision response animator from that meta selector. Now that the mesh scene nodes have had triangle selectors created and added
to the meta selector, create a collision response animator from that meta selector.
*/
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator( scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
meta, camera, core::vector3df(5,5,5), meta, camera, core::vector3df(5,5,5),
core::vector3df(0,0,0)); core::vector3df(0,0,0));
...@@ -139,7 +150,9 @@ int main() ...@@ -139,7 +150,9 @@ int main()
if(cube) if(cube)
camera->setTarget(cube->getAbsolutePosition()); camera->setTarget(cube->getAbsolutePosition());
// and draw everything. /*
That's it. Draw everything and finish as usual.
*/
int lastFPS = -1; int lastFPS = -1;
...@@ -170,3 +183,5 @@ int main() ...@@ -170,3 +183,5 @@ int main()
return 0; return 0;
} }
/*
**/
/* /** Example 016 Quake3 Map Shader Support
This Tutorial shows how to load a Quake 3 map into the This Tutorial shows how to load a Quake 3 map into the
engine, create a SceneNode for optimizing the speed of engine, create a SceneNode for optimizing the speed of
rendering and how to create a user controlled camera. rendering and how to create a user controlled camera.
...@@ -291,12 +292,12 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -291,12 +292,12 @@ int IRRCALLCONV main(int argc, char* argv[])
} }
/* /*
Now we only need a Camera to look at the Quake 3 map. Now we only need a Camera to look at the Quake 3 map. And we want to
And we want to create a user controlled camera. There are some create a user controlled camera. There are some different cameras
different cameras available in the Irrlicht engine. For example the available in the Irrlicht engine. For example the Maya Camera which can
Maya Camera which can be controlled compareable to the camera in Maya: be controlled compareable to the camera in Maya: Rotate with left mouse
Rotate with left mouse button pressed, Zoom with both buttons pressed, button pressed, Zoom with both buttons pressed, translate with right
translate with right mouse button pressed. This could be created with mouse button pressed. This could be created with
addCameraSceneNodeMaya(). But for this example, we want to create a addCameraSceneNodeMaya(). But for this example, we want to create a
camera which behaves like the ones in first person shooter games (FPS). camera which behaves like the ones in first person shooter games (FPS).
*/ */
...@@ -425,4 +426,5 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -425,4 +426,5 @@ int IRRCALLCONV main(int argc, char* argv[])
return 0; return 0;
} }
/*
**/
# Makefile for Irrlicht Examples
# It's usually sufficient to change just the target name and source file list
# and be sure that CXX is set to a valid compiler
Target = 17.SplitScreen
Sources = main.cpp
# general compiler settings
CPPFLAGS = -I../../include -I/usr/X11R6/include
CXXFLAGS = -O3 -ffast-math
#CXXFLAGS = -g -Wall
#default target is Linux
all: all_linux
ifeq ($(HOSTTYPE), x86_64)
LIBSELECT=64
endif
# target specific settings
all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11
all_linux clean_linux: SYSTEM=Linux
all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm
all_win32 clean_win32: SYSTEM=Win32-gcc
all_win32 clean_win32: SUF=.exe
# name of the binary - only valid for targets which set SYSTEM
DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF)
all_linux all_win32:
$(warning Building...)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS)
clean: clean_linux clean_win32
$(warning Cleaning...)
clean_linux clean_win32:
@$(RM) $(DESTPATH)
.PHONY: all all_win32 clean clean_linux clean_win32
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "17.SplitScreen", "SplitScreen.vcproj", "{EB3B38EA-5CE7-4983-845B-880661E69D09}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Debug.ActiveCfg = Debug|Win32
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Debug.Build.0 = Debug|Win32
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Release.ActiveCfg = Release|Win32
{EB3B38EA-5CE7-4983-845B-880661E69D09}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="17.SplitScreen"
ProjectGUID="{EB3B38EA-5CE7-4983-845B-880661E69D09}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\bin\Win32-VisualStudio\17.SplitScreen.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/SplitScreen.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="TRUE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/QIfist /Oa"
Optimization="3"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OmitFramePointers="TRUE"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="4"
BufferSecurityCheck="FALSE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"
CallingConvention="1"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\bin\Win32-VisualStudio\17.SplitScreen.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
GenerateDebugInformation="FALSE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\main.cpp">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="17.SplitScreen_vc8"
ProjectGUID="{EB3B38EA-5CE7-4983-845B-880661E69D09}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\bin\Win32-VisualStudio\17.SplitScreen.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/SplitScreen.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="0"
CallingConvention="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\bin\Win32-VisualStudio\17.SplitScreen.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
GenerateDebugInformation="false"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\main.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="17.SplitScreen_vc9"
ProjectGUID="{EB3B38EA-5CE7-4983-845B-880661E69D09}"
RootNamespace="17.SplitScreen_vc9"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\bin\Win32-VisualStudio\17.SplitScreen.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/SplitScreen.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="0"
CallingConvention="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\..\bin\Win32-VisualStudio\17.SplitScreen.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib\Win32-visualstudio"
GenerateDebugInformation="false"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\main.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
[Project]
FileName=example.dev
Name=Irrlicht Example 17 SplitScreen
UnitCount=1
Type=1
Ver=1
ObjFiles=
Includes=..\..\include
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=../../lib/Win32-gcc/libIrrlicht.a_@@_
IsCpp=1
Icon=
ExeOutput=../../bin/Win32-gcc
ObjectOutput=obj
OverrideOutput=1
OverrideOutputName=17.SplitScreen.exe
HostApplication=
Folders=
CommandLine=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000000000000000000
UseCustomMakefile=0
CustomMakefile=
[Unit1]
FileName=main.cpp
CompileCpp=1
Folder=Projekt1
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[VersionInfo]
Major=0
Minor=1
Release=1
Build=1
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Irrlicht Engine example compiled using DevCpp and gcc
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0
/** Example 017 Splitscreen
A tutorial by Max Winkel.
In this tutorial we'll learn how to use splitscreen (e.g. for racing-games)
with Irrlicht. We'll create a viewport divided
into 4 parts, wtih 3 fixed cameras and one user-controlled.
Ok, let's start with the headers (I think there's
nothing to say about it)
*/
#include <irrlicht.h>
#include <stdio.h>
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
//Namespaces for the engine
using namespace irr;
using namespace video;
using namespace core;
using namespace scene;
using namespace io;
using namespace gui;
/*
Now we'll define the resolution in a constant for use in
initializing the device and setting up the viewport. In addition
we set up a global variable saying splitscreen is active or not.
*/
//Resolution
const int ResX=800;
const int ResY=600;
const bool fullScreen=false;
//Use SplitScreen?
bool SplitScreen=true;
/*
Now we need four pointers to our cameras which are created later:
*/
//cameras
ICameraSceneNode *camera[4]={0,0,0,0};
/*
In our event-receiver we switch the SplitScreen-variable,
whenever the user press the S-key. All other events are sent
to the FPS camera.
*/
class MyEventReceiver : public IEventReceiver {
public:
virtual bool OnEvent(const SEvent& event)
{
//Key S enables/disables SplitScreen
if (event.EventType == irr::EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_KEY_S && event.KeyInput.PressedDown)
{
SplitScreen = !SplitScreen;
return true;
}
//Send all other events to camera4
if (camera[3])
return camera[3]->OnEvent(event);
return false;
}
};
/*
Ok, now the main-function:
First, we initialize the device, get the SourceManager and
VideoDriver, load an animated mesh from .md2 and a map from
.pk3. Because that's old stuff, I won't explain every step.
Just take care of the maps position.
*/
int main()
{
//Instance of the EventReceiver
MyEventReceiver receiver;
//Initialise the engine
IrrlichtDevice *device = createDevice(
EDT_OPENGL, dimension2d<s32>(ResX,ResY), 32, fullScreen, false, false, &receiver);
ISceneManager *smgr = device->getSceneManager();
IVideoDriver *driver = device->getVideoDriver();
//Load model
IAnimatedMesh *model = smgr->getMesh("../../media/sydney.md2");
if (!model)
return 1;
IAnimatedMeshSceneNode *model_node = smgr->addAnimatedMeshSceneNode(model);
//Load texture
ITexture *texture = driver->getTexture("../../media/sydney.bmp");
model_node->setMaterialTexture(0,texture);
//Disable lighting (we've got no light)
model_node->setMaterialFlag(EMF_LIGHTING,false);
//Load map
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
IAnimatedMesh *map = smgr->getMesh("20kdm2.bsp");
if (map)
{
ISceneNode *map_node = smgr->addOctTreeSceneNode(map->getMesh(0));
//Set position
map_node->setPosition(vector3df(-850,-220,-850));
}
/*
Now we create our four cameras. One is looking at the model
from the front, one from the top and one from the side. In
addition there's a FPS-camera which can be controlled by the
user.
*/
// Create 3 fixed and one user-controlled cameras
//Front
camera[0] = smgr->addCameraSceneNode(0, vector3df(50,0,0), vector3df(0,0,0));
//Top
camera[1] = smgr->addCameraSceneNode(0, vector3df(0,50,0), vector3df(0,0,0));
//Left
camera[2] = smgr->addCameraSceneNode(0, vector3df(0,0,50), vector3df(0,0,0));
//User-controlled
camera[3] = smgr->addCameraSceneNodeFPS();
/*
Create a variable for counting the fps and hide the mouse:
*/
//Hide mouse
device->getCursorControl()->setVisible(false);
//We want to count the fps
int lastFPS = -1;
/*
There wasn't much new stuff - till now!
Only by defining four cameras, the game won't be splitscreen.
To do this you need several steps:
- Set the viewport to the whole screen
- Begin a new scene (Clear screen)
- The following 3 steps are repeated for every viewport in the splitscreen
- Set the viewport to the area you wish
- Activate the camera which should be "linked" with the viewport
- Render all objects
- If you have a GUI:
- Set the viewport the whole screen
- Display the GUI
- End scene
Sounds a little complicated, but you'll see it isn't:
*/
while(device->run())
{
//Set the viewpoint to the whole screen and begin scene
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
driver->beginScene(true,true,SColor(255,100,100,100));
//If SplitScreen is used
if (SplitScreen)
{
//Activate camera1
smgr->setActiveCamera(camera[0]);
//Set viewpoint to the first quarter (left top)
driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
//Draw scene
smgr->drawAll();
//Activate camera2
smgr->setActiveCamera(camera[1]);
//Set viewpoint to the second quarter (right top)
driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
//Draw scene
smgr->drawAll();
//Activate camera3
smgr->setActiveCamera(camera[2]);
//Set viewpoint to the third quarter (left bottom)
driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
//Draw scene
smgr->drawAll();
//Set viewport the last quarter (right bottom)
driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));
}
//Activate camera4
smgr->setActiveCamera(camera[3]);
//Draw scene
smgr->drawAll();
driver->endScene();
/*
As you can probably see, the image is rendered for every
viewport seperately. That means, that you'll loose much performance.
Ok, if you're aksing "How do I have to set the viewport
to get this or that screen?", don't panic. It's really
easy: In the rect-function you define 4 coordinates:
- X-coordinate of the corner left top
- Y-coordinate of the corner left top
- X-coordinate of the corner right bottom
- Y-coordinate of the corner right bottom
That means, if you want to split the screen into 2 viewports
you would give the following coordinates:
- 1st viewport: 0,0,ResX/2,ResY
- 2nd viewport: ResX/2,0,ResX,ResY
If you didn't fully understand, just play arround with the example
to check out what happens.
Now we just view the current fps and shut down the engine,
when the user wants to:
*/
//Get and show fps
if (driver->getFPS() != lastFPS)
{
lastFPS = driver->getFPS();
wchar_t tmp[1024];
swprintf( tmp, 1024, L"Irrlicht SplitScreen-Example (FPS: %d)", lastFPS);
device->setWindowCaption(tmp);
}
}
//Delete device
device->drop();
return 0;
}
/*
That's it! Just compile and play around with the program.
Note: With the S-Key you can switch between using splitscreen
and not.
**/
...@@ -45,7 +45,7 @@ void CDemo::run() ...@@ -45,7 +45,7 @@ void CDemo::run()
resolution.Height = 480; resolution.Height = 480;
} }
device = createDevice(driverType,resolution, 32, fullscreen, shadows, vsync, this); device = createDevice(driverType, resolution, 32, fullscreen, shadows, vsync, this);
if (!device) if (!device)
return; return;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#ifndef __C_DEMO_H_INCLUDED__ #ifndef __C_DEMO_H_INCLUDED__
#define __C_DEMO_H_INCLUDED__ #define __C_DEMO_H_INCLUDED__
//#define USE_IRRKLANG #define USE_IRRKLANG
//#define USE_SDL_MIXER //#define USE_SDL_MIXER
#include <irrlicht.h> #include <irrlicht.h>
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#define __IRR_COMPILE_CONFIG_H_INCLUDED__ #define __IRR_COMPILE_CONFIG_H_INCLUDED__
//! Irrlicht SDK Version //! Irrlicht SDK Version
#define IRRLICHT_SDK_VERSION "1.4.1" #define IRRLICHT_SDK_VERSION "1.4.2"
//! The defines for different operating system are: //! The defines for different operating system are:
//! _IRR_XBOX_PLATFORM_ for XBox //! _IRR_XBOX_PLATFORM_ for XBox
...@@ -82,7 +82,7 @@ to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK ...@@ -82,7 +82,7 @@ to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK
and this to the linker settings: -ld3dx9 -ld3dx8 **/ and this to the linker settings: -ld3dx9 -ld3dx8 **/
#if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) #if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK))
//#define _IRR_COMPILE_WITH_DIRECT3D_8_ #define _IRR_COMPILE_WITH_DIRECT3D_8_
#define _IRR_COMPILE_WITH_DIRECT3D_9_ #define _IRR_COMPILE_WITH_DIRECT3D_9_
#endif #endif
......
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
#include "SMeshBufferTangents.h" #include "SMeshBufferTangents.h"
#include "SViewFrustum.h" #include "SViewFrustum.h"
/*! \mainpage Irrlicht Engine 1.4.1 API documentation /*! \mainpage Irrlicht Engine 1.4.2 API documentation
* *
* <div align="center"><img src="logobig.png" ></div> * <div align="center"><img src="logobig.png" ></div>
* *
......
========================================================================== ==========================================================================
The Irrlicht Engine SDK version 1.4.1 The Irrlicht Engine SDK version 1.4.2
========================================================================== ==========================================================================
Welcome the Irrlicht Engine SDK. Welcome the Irrlicht Engine SDK.
......
No preview for this file type
...@@ -444,7 +444,7 @@ WARN_LOGFILE = ...@@ -444,7 +444,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # with spaces.
INPUT = ../../../include/ INPUT = ../../../include/ tut.txt
# If the value of the INPUT tag contains directories, you can use the # If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
...@@ -504,7 +504,7 @@ EXAMPLE_RECURSIVE = NO ...@@ -504,7 +504,7 @@ EXAMPLE_RECURSIVE = NO
# directories that contain image that are included in the documentation (see # directories that contain image that are included in the documentation (see
# the \image command). # the \image command).
IMAGE_PATH = IMAGE_PATH = ../../../media
# The INPUT_FILTER tag can be used to specify a program that doxygen should # The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program # invoke to filter for each input file. Doxygen will invoke the filter program
......
...@@ -444,7 +444,7 @@ WARN_LOGFILE = ...@@ -444,7 +444,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # with spaces.
INPUT = ../../../include/ INPUT = ../../../include/ tut.txt
# If the value of the INPUT tag contains directories, you can use the # If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
...@@ -504,7 +504,7 @@ EXAMPLE_RECURSIVE = NO ...@@ -504,7 +504,7 @@ EXAMPLE_RECURSIVE = NO
# directories that contain image that are included in the documentation (see # directories that contain image that are included in the documentation (see
# the \image command). # the \image command).
IMAGE_PATH = IMAGE_PATH = ../../../media
# The INPUT_FILTER tag can be used to specify a program that doxygen should # The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program # invoke to filter for each input file. Doxygen will invoke the filter program
...@@ -761,13 +761,13 @@ LATEX_HEADER = ...@@ -761,13 +761,13 @@ LATEX_HEADER =
# contain links (just like the HTML output) instead of page references # contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer. # This makes the output suitable for online browsing using a pdf viewer.
PDF_HYPERLINKS = NO PDF_HYPERLINKS = YES
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a # plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation. # higher quality PDF documentation.
USE_PDFLATEX = NO USE_PDFLATEX = YES
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep # command to the generated LaTeX files. This will instruct LaTeX to keep
......
...@@ -14,6 +14,6 @@ ...@@ -14,6 +14,6 @@
| <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF"> | <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF">
Namespace&nbsp;Members</font></a> | <a class="qindex" href="functions.html"><font color="#FFFFFF">Class Namespace&nbsp;Members</font></a> | <a class="qindex" href="functions.html"><font color="#FFFFFF">Class
members</font></a> | <a class="qindex" href="globals.html"><font color="#FFFFFF">File members</font></a> | <a class="qindex" href="globals.html"><font color="#FFFFFF">File
members</font></a></font> </td> members</font></a> | <a class="qindex" href="pages.html"><font color="#FFFFFF">Tutorials</font></a></font> </td>
</tr> </tr>
</table> </table>
...@@ -4,6 +4,25 @@ copy doxygen.css ..\..\..\doctemp\html ...@@ -4,6 +4,25 @@ copy doxygen.css ..\..\..\doctemp\html
copy irrlicht.png ..\..\..\doctemp\html copy irrlicht.png ..\..\..\doctemp\html
copy logobig.png ..\..\..\doctemp\html copy logobig.png ..\..\..\doctemp\html
rem for /F %%i in ('dir ..\..\..\examples\[01]*\main.cpp') DO ..\sed.exe -f tutorials.sed %i >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\01.HelloWorld\main.cpp >tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\02.Quake3Map\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\03.CustomSceneNode\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\04.Movement\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\05.UserInterface\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\06.2DGraphics\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\07.Collision\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\08.SpecialFX\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\09.MeshViewer\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\10.Shaders\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\11.PerPixelLighting\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\12.TerrainRendering\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\13.RenderToTexture\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\14.Win32Window\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\15.LoadIrrFile\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\16.Quake3MapShader\main.cpp >>tut.txt
..\sed.exe -f tutorials.sed ..\..\..\examples\17.SplitScreen\main.cpp >>tut.txt
..\doxygen.exe doxygen.cfg ..\doxygen.exe doxygen.cfg
pause pause
doxygen doxygen.cfg rm tut.txt || true;
for i in ../../../examples/[01]*/main.cpp; do
sed -f tutorials.sed $i >>tut.txt;
done
doxygen doxygen-pdf.cfg
cp doxygen.css irrlicht.png logobig.png ../../../doctemp/html cp doxygen.css irrlicht.png logobig.png ../../../doctemp/html
......
# Page start and end are delimited by /** and **/
# we keep the end unchanged, the header is extended
s/\/\*\* Example \(0*\)\([0-9]*\) \(.*\)$/\/\*\* \\page example\1\2 Tutorial \2: \3\n \\image html \"\1\2shot.jpg\"\n \\image latex \"\1\2shot.jpg\"/
# All other comments start and end code sections
s/\([^\*]\)\*\//\1\\code/
s/^\*\//\\code/
s/\/\*\([^\*]\)/\\endcode \1/
s/\/\*$/\\endcode\n/
#remove DOS line endings
s/\r//g
GNU sed version 4.0.7 - compiled for Win32.
Native executable requires only the Microsoft
C runtime MSVCRT.DLL, not an emulation layer
like Cygwin. This .EXE file was obtained from
http://unxutils.sourceforge.net on 2003-10-21.
For documentation, GPL license, source code,
etc., visit http://unxutils.sourceforge.net.
Downloaded from http://www.student.northpark.edu/pemente/sed/
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# norootforbuild # norootforbuild
Name: libIrrlicht1 Name: libIrrlicht1
Version: 1.4.beta Version: 1.4.2
Release: 0.pm.1 Release: 0.pm.1
Summary: The Irrlicht Engine SDK Summary: The Irrlicht Engine SDK
License: see readme.txt License: see readme.txt
......
...@@ -589,8 +589,8 @@ bool C3DSMeshFileLoader::readTrackChunk(io::IReadFile* file, ChunkData& data, ...@@ -589,8 +589,8 @@ bool C3DSMeshFileLoader::readTrackChunk(io::IReadFile* file, ChunkData& data,
file->read(&vec.Z, sizeof(f32)); file->read(&vec.Z, sizeof(f32));
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
vec.X = os::Byteswap::byteswap(vec.X); vec.X = os::Byteswap::byteswap(vec.X);
vec.Y = os::Byteswap::byteswap(vec.X); vec.Y = os::Byteswap::byteswap(vec.Y);
vec.Z = os::Byteswap::byteswap(vec.X); vec.Z = os::Byteswap::byteswap(vec.Z);
#endif #endif
data.read += 12; data.read += 12;
vec-=pivot; vec-=pivot;
......
VERSION = 1.4 VERSION = 1.4.2
# Irrlicht Engine 1.4 # Irrlicht Engine 1.4.2
# Makefile for Linux # Makefile for Linux
# #
# To use, just run: # To use, just run:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment