From 393b5cd1dc438872af89d334ef6e5fcc59f27d47 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 13 Jan 2013 17:24:39 +1000 Subject: Added Irrlicht 1.8, but without all the Windows binaries. --- .../examples/01.HelloWorld/HelloWorld.cbp | 55 +++ .../examples/01.HelloWorld/HelloWorld.dev | 59 +++ .../examples/01.HelloWorld/HelloWorld.vcproj | 163 +++++++++ .../examples/01.HelloWorld/HelloWorld_vc10.vcxproj | 231 ++++++++++++ .../examples/01.HelloWorld/HelloWorld_vc11.vcxproj | 235 ++++++++++++ .../examples/01.HelloWorld/HelloWorld_vc8.vcproj | 231 ++++++++++++ .../examples/01.HelloWorld/HelloWorld_vc9.vcproj | 230 ++++++++++++ .../irrlicht-1.8/examples/01.HelloWorld/Makefile | 66 ++++ .../irrlicht-1.8/examples/01.HelloWorld/main.cpp | 236 ++++++++++++ .../examples/01.HelloWorld/tutorial.html | 394 +++++++++++++++++++++ 10 files changed, 1900 insertions(+) create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.cbp create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.dev create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.vcproj create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc10.vcxproj create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc11.vcxproj create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc8.vcproj create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc9.vcproj create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/Makefile create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/main.cpp create mode 100644 libraries/irrlicht-1.8/examples/01.HelloWorld/tutorial.html (limited to 'libraries/irrlicht-1.8/examples/01.HelloWorld') diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.cbp b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.cbp new file mode 100644 index 0000000..bba207a --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.cbp @@ -0,0 +1,55 @@ + + + + + + diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.dev b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.dev new file mode 100644 index 0000000..9de3da7 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.dev @@ -0,0 +1,59 @@ +[Project] +FileName=example.dev +Name=Irrlicht Example 01 HelloWorld +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= +OverrideOutput=1 +OverrideOutputName=01.HelloWorld.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 + diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.vcproj b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.vcproj new file mode 100644 index 0000000..3a2fdb0 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld.vcproj @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc10.vcxproj b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc10.vcxproj new file mode 100644 index 0000000..696621f --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc10.vcxproj @@ -0,0 +1,231 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 01.HelloWorld + {5AD4C95C-BA38-4692-BA4B-8C25A86208F9} + HelloWorld + + + + Application + false + MultiByte + + + Application + false + MultiByte + + + Application + false + MultiByte + + + Application + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win32-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + .\Debug/HelloWorld.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\01.HelloWorld.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Debug/HelloWorld.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\01.HelloWorld.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Release/HelloWorld.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\01.HelloWorld.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Release/HelloWorld.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\01.HelloWorld.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + Disabled + Disabled + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc11.vcxproj b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc11.vcxproj new file mode 100644 index 0000000..f5f1fae --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc11.vcxproj @@ -0,0 +1,235 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 01.HelloWorld + {5AD4C95C-BA38-4692-BA4B-8C25A86208F9} + HelloWorld + + + + Application + false + MultiByte + v110 + + + Application + false + MultiByte + v110 + + + Application + false + MultiByte + v110 + + + Application + false + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win32-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + .\Debug/HelloWorld.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\01.HelloWorld.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Debug/HelloWorld.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\01.HelloWorld.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Release/HelloWorld.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\01.HelloWorld.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Release/HelloWorld.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\01.HelloWorld.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + Disabled + Disabled + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc8.vcproj b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc8.vcproj new file mode 100644 index 0000000..ac11031 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc8.vcproj @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc9.vcproj b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc9.vcproj new file mode 100644 index 0000000..982d202 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/HelloWorld_vc9.vcproj @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/Makefile b/libraries/irrlicht-1.8/examples/01.HelloWorld/Makefile new file mode 100644 index 0000000..c834ab7 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/Makefile @@ -0,0 +1,66 @@ +# 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 + +# Name of the executable created (.exe will be added automatically if necessary) +Target := 01.HelloWorld +# List of source files, separated by spaces +Sources := main.cpp +# Path to Irrlicht directory, should contain include/ and lib/ +IrrlichtHome := ../.. +# Path for the executable. Note that Irrlicht.dll should usually also be there for win32 systems +BinPath = ../../bin/$(SYSTEM) + +# general compiler settings (might need to be set when compiling the lib, too) +# preprocessor flags, e.g. defines and include paths +USERCPPFLAGS = +# compiler flags such as optimization flags +USERCXXFLAGS = -O3 -ffast-math +#USERCXXFLAGS = -g -Wall +# linker flags such as additional libraries and link paths +USERLDFLAGS = + +#### +#no changes necessary below this line +#### + +CPPFLAGS = -I$(IrrlichtHome)/include -I/usr/X11R6/include $(USERCPPFLAGS) +CXXFLAGS = $(USERCXXFLAGS) +LDFLAGS = $(USERLDFLAGS) + +#default target is Linux +all: all_linux + +# target specific settings +all_linux all_win32 static_win32: LDFLAGS += -L$(IrrlichtHome)/lib/$(SYSTEM) -lIrrlicht +all_linux: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm -lXext -lX11 -lXcursor +all_linux clean_linux: SYSTEM=Linux +all_win32 clean_win32 static_win32: SYSTEM=Win32-gcc +all_win32 clean_win32 static_win32: SUF=.exe +static_win32: CPPFLAGS += -D_IRR_STATIC_LIB_ +all_win32: LDFLAGS += -lopengl32 -lm +static_win32: LDFLAGS += -lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lopengl32 +# name of the binary - only valid for targets which set SYSTEM +DESTPATH = $(BinPath)/$(Target)$(SUF) + +all_linux all_win32 static_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 static_win32 clean clean_linux clean_win32 + +#multilib handling +ifeq ($(HOSTTYPE), x86_64) +LIBSELECT=64 +endif +#solaris real-time features +ifeq ($(HOSTTYPE), sun4) +LDFLAGS += -lrt +endif + diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/main.cpp b/libraries/irrlicht-1.8/examples/01.HelloWorld/main.cpp new file mode 100644 index 0000000..a53483c --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/main.cpp @@ -0,0 +1,236 @@ +/** Example 001 HelloWorld + +This Tutorial shows how to set up the IDE for using the Irrlicht Engine and how +to write a simple HelloWorld program with it. The program will show how to use +the basics of the VideoDriver, the GUIEnvironment, and the SceneManager. +Microsoft Visual Studio is used as an IDE, but you will also be able to +understand everything if you are using a different one or even another +operating system than windows. + +You have to include the header file in order to use the engine. The +header file can be found in the Irrlicht Engine SDK directory \c include. To let +the compiler find this header file, the directory where it is located has to be +specified. This is different for every IDE and compiler you use. Let's explain +shortly how to do this in Microsoft Visual Studio: + +- If you use Version 6.0, select the Menu Extras -> Options. + Select the directories tab, and select the 'Include' Item in the combo box. + Add the \c include directory of the irrlicht engine folder to the list of + directories. Now the compiler will find the Irrlicht.h header file. We also + need the irrlicht.lib to be found, so stay in that dialog, select 'Libraries' + in the combo box and add the \c lib/VisualStudio directory. + \image html "vc6optionsdir.jpg" + \image latex "vc6optionsdir.jpg" + \image html "vc6include.jpg" + \image latex "vc6include.jpg" + +- If your IDE is Visual Studio .NET, select Tools -> Options. + Select the projects entry and then select VC++ directories. Select 'show + directories for include files' in the combo box, and add the \c include + directory of the irrlicht engine folder to the list of directories. Now the + compiler will find the Irrlicht.h header file. We also need the irrlicht.lib + to be found, so stay in that dialog, select 'show directories for Library + files' and add the \c lib/VisualStudio directory. + \image html "vcnetinclude.jpg" + \image latex "vcnetinclude.jpg" + +That's it. With your IDE set up like this, you will now be able to develop +applications with the Irrlicht Engine. + +Lets start! + +After we have set up the IDE, the compiler will know where to find the Irrlicht +Engine header files so we can include it now in our code. +*/ +#include + +/* +In the Irrlicht Engine, everything can be found in the namespace 'irr'. So if +you want to use a class of the engine, you have to write irr:: before the name +of the class. For example to use the IrrlichtDevice write: irr::IrrlichtDevice. +To get rid of the irr:: in front of the name of every class, we tell the +compiler that we use that namespace from now on, and we will not have to write +irr:: anymore. +*/ +using namespace irr; + +/* +There are 5 sub namespaces in the Irrlicht Engine. Take a look at them, you can +read a detailed description of them in the documentation by clicking on the top +menu item 'Namespace List' or by using this link: +http://irrlicht.sourceforge.net/docu/namespaces.html +Like the irr namespace, we do not want these 5 sub namespaces now, to keep this +example simple. Hence, we tell the compiler again that we do not want always to +write their names. +*/ +using namespace core; +using namespace scene; +using namespace video; +using namespace io; +using namespace gui; + +/* +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 to make it easy, we use a +pragma comment lib for VisualStudio. On Windows platforms, we have to get rid +of the console window, which pops up when starting a program with main(). This +is done by the second pragma. We could also use the WinMain method, though +losing platform independence then. +*/ +#ifdef _IRR_WINDOWS_ +#pragma comment(lib, "Irrlicht.lib") +#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") +#endif + + +/* +This is the main method. We can now use main() on every platform. +*/ +int main() +{ + /* + The most important function of the engine is the createDevice() + function. The IrrlichtDevice is created by it, which is the root + object for doing anything with the engine. createDevice() has 7 + parameters: + + - deviceType: Type of the device. This can currently be the Null-device, + one of the two software renderers, D3D8, D3D9, or OpenGL. In this + example we use EDT_SOFTWARE, but to try out, you might want to + change it to EDT_BURNINGSVIDEO, EDT_NULL, EDT_DIRECT3D8, + EDT_DIRECT3D9, or EDT_OPENGL. + + - windowSize: Size of the Window or screen in FullScreenMode to be + created. In this example we use 640x480. + + - bits: Amount of color bits per pixel. This should be 16 or 32. The + parameter is often ignored when running in windowed mode. + + - fullscreen: Specifies if we want the device to run in fullscreen mode + or not. + + - stencilbuffer: Specifies if we want to use the stencil buffer (for + drawing shadows). + + - vsync: Specifies if we want to have vsync enabled, this is only useful + in fullscreen mode. + + - eventReceiver: An object to receive events. We do not want to use this + parameter here, and set it to 0. + + Always check the return value to cope with unsupported drivers, + dimensions, etc. + */ + IrrlichtDevice *device = + createDevice( video::EDT_SOFTWARE, dimension2d(640, 480), 16, + false, false, false, 0); + + if (!device) + return 1; + + /* + Set the caption of the window to some nice text. Note that there is an + 'L' in front of the string. The Irrlicht Engine uses wide character + strings when displaying text. + */ + device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo"); + + /* + Get a pointer to the VideoDriver, the SceneManager and the graphical + user interface environment, so that we do not always have to write + device->getVideoDriver(), device->getSceneManager(), or + device->getGUIEnvironment(). + */ + IVideoDriver* driver = device->getVideoDriver(); + ISceneManager* smgr = device->getSceneManager(); + IGUIEnvironment* guienv = device->getGUIEnvironment(); + + /* + We add a hello world label to the window, using the GUI environment. + The text is placed at the position (10,10) as top left corner and + (260,22) as lower right corner. + */ + guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", + rect(10,10,260,22), true); + + /* + To show something interesting, we load a Quake 2 model and display it. + We only have to get the Mesh from the Scene Manager with getMesh() and add + a SceneNode to display the mesh with addAnimatedMeshSceneNode(). We + check the return value of getMesh() to become aware of loading problems + and other errors. + + Instead of writing the filename sydney.md2, it would also be possible + to load a Maya object file (.obj), a complete Quake3 map (.bsp) or any + other supported file format. By the way, that cool Quake 2 model + called sydney was modelled by Brian Collins. + */ + IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2"); + if (!mesh) + { + device->drop(); + return 1; + } + IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); + + /* + To let the mesh look a little bit nicer, we change its material. We + disable lighting because we do not have a dynamic light in here, and + the mesh would be totally black otherwise. Then we set the frame loop, + such that the predefined STAND animation is used. And last, we apply a + texture to the mesh. Without it the mesh would be drawn using only a + color. + */ + if (node) + { + node->setMaterialFlag(EMF_LIGHTING, false); + node->setMD2Animation(scene::EMAT_STAND); + node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") ); + } + + /* + To look at the mesh, we place a camera into 3d space at the position + (0, 30, -40). The camera looks from there to (0,5,0), which is + approximately the place where our md2 model is. + */ + smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); + + /* + Ok, now we have set up the scene, lets draw everything: We run the + device in a while() loop, until the device does not want to run any + more. This would be when the user closes the window or presses ALT+F4 + (or whatever keycode closes a window). + */ + while(device->run()) + { + /* + Anything can be drawn between a beginScene() and an endScene() + call. The beginScene() call clears the screen with a color and + the depth buffer, if desired. Then we let the Scene Manager and + the GUI Environment draw their content. With the endScene() + call everything is presented on the screen. + */ + driver->beginScene(true, true, SColor(255,100,101,140)); + + smgr->drawAll(); + guienv->drawAll(); + + driver->endScene(); + } + + /* + After we are done with the render loop, we have to delete the Irrlicht + Device created before with createDevice(). In the Irrlicht Engine, you + have to delete all objects you created with a method or function which + starts with 'create'. The object is simply deleted by calling ->drop(). + See the documentation at irr::IReferenceCounted::drop() for more + information. + */ + device->drop(); + + return 0; +} + +/* +That's it. Compile and run. +**/ diff --git a/libraries/irrlicht-1.8/examples/01.HelloWorld/tutorial.html b/libraries/irrlicht-1.8/examples/01.HelloWorld/tutorial.html new file mode 100644 index 0000000..e46c954 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/01.HelloWorld/tutorial.html @@ -0,0 +1,394 @@ + + +Irrlicht Engine Tutorial + + + + +
+ + + + + + + + + +
Tutorial 1.HelloWorld
+

This Tutorial shows how to set up the IDE for using the + Irrlicht Engine and how to write a simple HelloWorld program + with it. The program will show how to use the basics of + the VideoDriver, the GUIEnvironment and the SceneManager.
+ The result of this example will look like this:

+


+

+
+
+ + + + + + +
Setting up the + IDE
+
+

To use the engine, we will have to include + the header file <irrlicht.h>, which can be found + in the Irrlicht Engine SDK directory \include. To let + the compiler find this header file, the directory where + it is located should be specified somewhere. This is different + for every IDE and compiler. I will explain how to do this + in Microsoft Visual Studio C++ 6.0 and .NET:

+ +
+
    +
  • +
    If you use Version 6.0, select the Menu + Extras -> Options. Select the directories tab, and + select the 'Include' Item in the combo box. Add the + \include directory of the Irrlicht Engine folder to + the list of directories. Now the compiler will find + the Irrlicht.h header file. We also need the location + of irrlicht.lib to be listed, so select the 'Libraries' + tab and add the \lib\VisualStudio directory.
    +
    +   
    +  
    + +
    +
  • +
  • If your IDE is Visual Studio .NET, select Tools -> + Options. Select the Projects entry and then select VC++ + directories. Select 'show directories for include files' + in the combo box, and add the \include directory of the + Irrlicht Engine folder to the list of directories so the + compiler will find the Irrlicht.h header file. We also + need the irrlicht.lib to be found, so select 'show directories + for Library files' and add the \lib\VisualStudio directory.
    +
    + +
    +
  • +
+ +

 

+
+
+ + + + + + + + +
Lets start!
+
+
+
+

After we have set up the IDE, the compiler will know + where to find the Irrlicht Engine header files so + we can include it now into our code.

+ + + + + +
#include <irrlicht.h>
+

In the Irrlicht Engine, everything can be found in + the namespace 'irr'. So if you want to use a class + of the engine, you'll have to type an irr:: before + the name of the class. For example, to use the IrrlichtDevice, + write: irr::IrrlichtDevice. To avoid having to put + irr:: before of the name of every class, we tell the + compiler that we use that namespace.

+ + + + + +
using namespace irr;
+

There are 5 sub-namespaces in the Irrlicht Engine. + Take a look at them: you can read a detailed description + of them in the documentation by clicking on the top + menu item 'Namespace + List'. To keep this example simple, we don't want + to have to specify the name spaces, Hence:

+ + + + + +
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
+

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 to make it easy we use + a pragma comment:

+ + + + + +
#pragma comment(lib, "Irrlicht.lib")
+

Now the main method: to keep this example simple + we use int main(), which can be used on any platform. + However, on Windows platforms, we could also use the + WinMain method if we would want to get rid of the + console window which pops up when starting a program + with main().

+ + + + + +
int main()
{
+

The most important function of the engine is the + 'createDevice' function. The Irrlicht Device, which + is the root object for doing everything with the engine, + can be created with it. createDevice() has 7 parameters:

+
+
    +
  • + +
    deviceType: Type of the device. This can currently + be the Null device, the Software device, Direct3D8, Direct3D9, + or OpenGL. In this example we use EDT_SOFTWARE, but, to try + them out, you might want to change it to EDT_NULL, EDT_DIRECT3D8, + EDT_DIRECT3D9 or EDT_OPENGL.
    +
  • +
  • +
    windowSize: Size of the window or + full screen mode to be created. In this example + we use 512x384.
    + +
  • +
  • +
    bits: Number of bits per pixel when + in full screen mode. This should be 16 or 32. This + parameter is ignored when running in windowed mode.
    +
  • +
  • +
    fullscreen: Specifies if we want + the device to run in full screen mode or not.
    +
  • +
  • stencilbuffer: Specifies if we want to use the stencil + buffer for drawing shadows.
  • + +
  • vsync: Specifies if we want to have vsync enabled. + This is only useful in full screen mode.
  • +
  • +
    eventReceiver: An object to receive + events. We do not want to use this parameter here, + and set it to 0.
    +
  • +
+ + + + + +
IrrlichtDevice *device =
createDevice(EDT_SOFTWARE, dimension2d<s32>(512, 384), 16,
false, false, false, 0);
+

Now we set the caption of the window to some nice text. + Note that there is a 'L' in front of the string: the + Irrlicht Engine uses wide character strings when displaying + text.

+ + + + + +
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
+

Now we store a pointer to the video driver, the SceneManager, + and the graphical user interface environment so that + we do not always have to write device->getVideoDriver(), + device->getSceneManager(), and device->getGUIEnvironment().

+ + + + + +
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
+

We add a hello world label to the window using the + GUI environment. The text is placed at the position + (10,10) as top left corner and (200,22) as lower right + corner.

+ + + + + +
guienv->addStaticText(L"Hello World! This is the Irrlicht Software engine!",
rect<s32>(10,10,200,22), true);
+

To display something interesting, we load a Quake 2 + model and display it. We only have to get the Mesh from + the Scene Manager with getMesh() and add a SceneNode + to display the mesh with addAnimatedMeshSceneNode(). + Instead of loading a Quake2 file (.md2), it is also + possible to load a Maya object file (.obj), a complete + Quake3 map (.bsp), or a Milshape file (.ms3d).
+ By the way, that cool Quake 2 model called sydney.md2 + was modelled by Brian Collins.

+ + + + + +
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
+

To make the mesh look a little bit nicer, we change + its material a little bit: we disable lighting because + we do not have a dynamic light in here and the mesh + would be totally black. Then we set the frame loop so + that the animation is looped between the frames 0 and + 310. Then, at last, we apply a texture to the mesh. + Without it the mesh would be drawn using only a solid + color.

+ + + + + +
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setFrameLoop(0, 310);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
}
+
+

To look at the mesh, we place a camera into 3d space + at the position (0, 10, -40). The camera looks from + there to (0,5,0).

+ + + + + +
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
+

Ok. Now that we have set up the scene, let's draw everything: + we run the device in a while() loop until the device + does not want to run any more. This would be when the + user closes the window or presses ALT+F4 in Windows.

+ + + + + +
while(device->run())
{
+

Everything must be drawn between a beginScene() and + an endScene() call. The beginScene clears the screen + with a color and also the depth buffer, if desired. + Then we let the Scene Manager and the GUI environment + draw their content. With the endScene() call, everything + is presented on the screen.

+ + + + + + +
	driver->beginScene(true, true, SColor(255,100,101,140));
+ smgr->drawAll(); + guienv->drawAll();
+
	driver->endScene();
+}
+

After we are finished, we have to delete the Irrlicht + Device created earlier with createDevice(). With the + Irrlicht Engine, you should delete all objects you created + with a method or function that starts with 'create'. + The object is deleted simply by calling ->drop(). + See the documentation + for more information.

+ + + + + +
	device->drop();
return 0; +}
+

That's it. Compile and run.

+

 

+
+
+
+
+ + + + + + + +
Possible Errors + or Problems
+
+
+

Visual Studio
+ + While trying to compile the tutorial, if you get the + error:

+ + + + +
fatal + error C1083: Cannot open include file: 'irrlicht.h': + No such file or directory
+

Solution: You may have set the include directory improperly + in the Visual Studio options. See above + for information on setting it.

+ + + + + +
LINK + : LNK6004: HelloWorld.exe not found or not built + by the last incremental link; performing full link
+ LINK : fatal error LNK1104: cannot open file "Irrlicht.lib"
+ Error executing link.exe
+

Solution: You may have set the library directory improperly. + See above for information on + setting it.
+ +
+

+

Compiler independent problems
+
If the tutorial compiles successfully but gives + the error:

+ + + + + +
This + application has failed to start because Irrlicht.dll + was not found. Re-installing the application may + fix this problem
+

Solution: You may have forgotten to copy the Irrlicht.dll + file from Irrlicht\bin\VisualStudio to the directory + the tutorial's project file is in.

+ If the tutorial compiles and runs successfully but produces + errors in the console like:
+
+ + + + + +
Could + not load mesh, because file could not be opened.: + ../media/sydney.md2
+

Or:

+ + + + + +
Could + not open file of texture: stones.jpg
+
Could not load texture: stones.jpg
+

Solution: The file listed in the error message cannot + be found. Ensure that the directory specified in the + main.cpp exists and is where the file is located.
+

+
+
+
+

 

+ + -- cgit v1.1