From f9158592e1478b2013afc7041d9ed041cf2d2f4a Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 13 Jan 2014 19:47:58 +1000 Subject: Update Irrlicht to 1.8.1. Include actual change markers this time. lol --- .../examples/18.SplitScreen/Makefile | 38 ++++ .../examples/18.SplitScreen/SplitScreen.cbp | 55 +++++ .../examples/18.SplitScreen/SplitScreen.dev | 59 +++++ .../examples/18.SplitScreen/SplitScreen.vcproj | 132 +++++++++++ .../18.SplitScreen/SplitScreen_vc10.vcxproj | 190 ++++++++++++++++ .../18.SplitScreen/SplitScreen_vc11.vcxproj | 194 ++++++++++++++++ .../examples/18.SplitScreen/SplitScreen_vc8.vcproj | 189 ++++++++++++++++ .../examples/18.SplitScreen/SplitScreen_vc9.vcproj | 188 ++++++++++++++++ .../examples/18.SplitScreen/main.cpp | 244 +++++++++++++++++++++ 9 files changed, 1289 insertions(+) create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/Makefile create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.cbp create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.dev create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.vcproj create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc10.vcxproj create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc11.vcxproj create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc8.vcproj create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc9.vcproj create mode 100644 libraries/irrlicht-1.8.1/examples/18.SplitScreen/main.cpp (limited to 'libraries/irrlicht-1.8.1/examples/18.SplitScreen') diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/Makefile b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/Makefile new file mode 100644 index 0000000..5ad6913 --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/Makefile @@ -0,0 +1,38 @@ +# 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 = 18.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 -lXcursor +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 diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.cbp b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.cbp new file mode 100644 index 0000000..93ff1d8 --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.cbp @@ -0,0 +1,55 @@ + + + + + + diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.dev b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.dev new file mode 100644 index 0000000..cd843c6 --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.dev @@ -0,0 +1,59 @@ +[Project] +FileName=example.dev +Name=Irrlicht Example 18 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=18.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 + diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.vcproj b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.vcproj new file mode 100644 index 0000000..46cb6b7 --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen.vcproj @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc10.vcxproj b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc10.vcxproj new file mode 100644 index 0000000..7db11fe --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc10.vcxproj @@ -0,0 +1,190 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 18.SplitScreen + {1AB9413E-4F53-42A3-8CB2-CB4BE22336D0} + 18.SplitScreen + Win32Proj + + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + true + true + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + ..\..\bin\Win32-VisualStudio\18.SplitScreen.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + $(OutDir)SplitScreen.pdb + Console + + + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + ..\..\bin\Win64-VisualStudio\18.SplitScreen.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + $(OutDir)SplitScreen.pdb + Console + + + + + + + true + Speed + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + + + Cdecl + + + ..\..\bin\Win32-VisualStudio\18.SplitScreen.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + false + Console + true + true + + + + + + + true + Speed + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + + + Cdecl + + + ..\..\bin\Win64-VisualStudio\18.SplitScreen.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + false + Console + true + true + + + + + + + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc11.vcxproj b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc11.vcxproj new file mode 100644 index 0000000..954ace3 --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc11.vcxproj @@ -0,0 +1,194 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 18.SplitScreen + {1AB9413E-4F53-42A3-8CB2-CB4BE22336D0} + 18.SplitScreen + Win32Proj + + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + true + true + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + ..\..\bin\Win32-VisualStudio\18.SplitScreen.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + $(OutDir)SplitScreen.pdb + Console + + + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + ..\..\bin\Win64-VisualStudio\18.SplitScreen.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + $(OutDir)SplitScreen.pdb + Console + + + + + + + true + Speed + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + + + Cdecl + + + ..\..\bin\Win32-VisualStudio\18.SplitScreen.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + false + Console + true + true + + + + + + + true + Speed + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + false + + + Level3 + + + Cdecl + + + ..\..\bin\Win64-VisualStudio\18.SplitScreen.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + false + Console + true + true + + + + + + + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc8.vcproj b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc8.vcproj new file mode 100644 index 0000000..906b950 --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc8.vcproj @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc9.vcproj b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc9.vcproj new file mode 100644 index 0000000..86f6552 --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/SplitScreen_vc9.vcproj @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8.1/examples/18.SplitScreen/main.cpp b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/main.cpp new file mode 100644 index 0000000..32266c5 --- /dev/null +++ b/libraries/irrlicht-1.8.1/examples/18.SplitScreen/main.cpp @@ -0,0 +1,244 @@ +/** Example 018 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, with 3 fixed cameras and one user-controlled. + +Ok, let's start with the headers (I think there's +nothing to say about it) +*/ + +#include +#include "driverChoice.h" + +#ifdef _MSC_VER +#pragma comment(lib, "Irrlicht.lib") +#endif + +//Namespaces for the engine +using namespace irr; +using namespace core; +using namespace video; +using namespace scene; + +/* +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() +{ + // ask user for driver + video::E_DRIVER_TYPE driverType=driverChoiceConsole(); + if (driverType==video::EDT_COUNT) + return 1; + + //Instance of the EventReceiver + MyEventReceiver receiver; + + //Initialise the engine + IrrlichtDevice *device = createDevice(driverType, + dimension2du(ResX,ResY), 32, fullScreen, + false, false, &receiver); + if (!device) + return 1; + + 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 + if (model_node) + { + ITexture *texture = driver->getTexture("../../media/sydney.bmp"); + model_node->setMaterialTexture(0,texture); + model_node->setMD2Animation(scene::EMAT_RUN); + //Disable lighting (we've got no light) + model_node->setMaterialFlag(EMF_LIGHTING,false); + } + + //Load map + device->getFileSystem()->addFileArchive("../../media/map-20kdm2.pk3"); + IAnimatedMesh *map = smgr->getMesh("20kdm2.bsp"); + if (map) + { + ISceneNode *map_node = smgr->addOctreeSceneNode(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(); + // don't start at sydney's position + if (camera[3]) + camera[3]->setPosition(core::vector3df(-50,0,-50)); + +/* +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(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(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(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(0,ResY/2,ResX/2,ResY)); + //Draw scene + smgr->drawAll(); + //Set viewport the last quarter (right bottom) + driver->setViewPort(rect(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 separately. That means, that you'll loose much performance. + Ok, if you're asking "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 around 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(); + core::stringw tmp = L"Irrlicht SplitScreen-Example (FPS: "; + tmp += lastFPS; + tmp += ")"; + device->setWindowCaption(tmp.c_str()); + } + } + //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. +**/ + -- cgit v1.1