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/26.OcclusionQuery/Makefile | 39 ++++ .../examples/26.OcclusionQuery/OcclusionQuery.cbp | 55 +++++ .../examples/26.OcclusionQuery/OcclusionQuery.dev | 59 ++++++ .../26.OcclusionQuery/OcclusionQuery.vcproj | 163 ++++++++++++++ .../26.OcclusionQuery/OcclusionQuery_vc10.vcxproj | 231 ++++++++++++++++++++ .../26.OcclusionQuery/OcclusionQuery_vc11.vcxproj | 235 +++++++++++++++++++++ .../26.OcclusionQuery/OcclusionQuery_vc8.vcproj | 231 ++++++++++++++++++++ .../26.OcclusionQuery/OcclusionQuery_vc9.vcproj | 230 ++++++++++++++++++++ .../examples/26.OcclusionQuery/main.cpp | 213 +++++++++++++++++++ 9 files changed, 1456 insertions(+) create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/Makefile create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.cbp create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.dev create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.vcproj create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc10.vcxproj create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc11.vcxproj create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc8.vcproj create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc9.vcproj create mode 100644 libraries/irrlicht-1.8/examples/26.OcclusionQuery/main.cpp (limited to 'libraries/irrlicht-1.8/examples/26.OcclusionQuery') diff --git a/libraries/irrlicht-1.8/examples/26.OcclusionQuery/Makefile b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/Makefile new file mode 100644 index 0000000..87e37e4 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/Makefile @@ -0,0 +1,39 @@ +# 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 = 26.OcclusionQuery +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: CPPFLAGS += -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL +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/examples/26.OcclusionQuery/OcclusionQuery.cbp b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.cbp new file mode 100644 index 0000000..8872705 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.cbp @@ -0,0 +1,55 @@ + + + + + + diff --git a/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.dev b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.dev new file mode 100644 index 0000000..e9d7c04 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.dev @@ -0,0 +1,59 @@ +[Project] +FileName=example.dev +Name=Irrlicht Example 26 OcclusionQuery +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=26.OcclusionQuery.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/26.OcclusionQuery/OcclusionQuery.vcproj b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.vcproj new file mode 100644 index 0000000..602f2d3 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery.vcproj @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc10.vcxproj b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc10.vcxproj new file mode 100644 index 0000000..d56f995 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc10.vcxproj @@ -0,0 +1,231 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 26.OcclusionQuery + {5CE0E2E7-879D-4152-B61D-24E7D0707B45} + OcclusionQuery + + + + 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\Win64-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + .\Debug\OcclusionQuery.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\26.OcclusionQuery.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Debug\OcclusionQuery.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\26.OcclusionQuery.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Release\OcclusionQuery.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\26.OcclusionQuery.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Release\OcclusionQuery.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\26.OcclusionQuery.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/26.OcclusionQuery/OcclusionQuery_vc11.vcxproj b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc11.vcxproj new file mode 100644 index 0000000..fb8b7a9 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc11.vcxproj @@ -0,0 +1,235 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 26.OcclusionQuery + {5CE0E2E7-879D-4152-B61D-24E7D0707B45} + OcclusionQuery + + + + 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\Win64-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + .\Debug\OcclusionQuery.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\26.OcclusionQuery.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Debug\OcclusionQuery.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\26.OcclusionQuery.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Release\OcclusionQuery.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\26.OcclusionQuery.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Release\OcclusionQuery.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\26.OcclusionQuery.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/26.OcclusionQuery/OcclusionQuery_vc8.vcproj b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc8.vcproj new file mode 100644 index 0000000..faa137f --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc8.vcproj @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc9.vcproj b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc9.vcproj new file mode 100644 index 0000000..c15a527 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/OcclusionQuery_vc9.vcproj @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/26.OcclusionQuery/main.cpp b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/main.cpp new file mode 100644 index 0000000..17f64b2 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/26.OcclusionQuery/main.cpp @@ -0,0 +1,213 @@ +/** Example 026 OcclusionQuery + +This Tutorial shows how to speed up rendering by use of the +OcclusionQuery feature. The usual rendering tries to avoid rendering of +scene nodes by culling those nodes which are outside the visible area, the +view frustum. However, this technique does not cope with occluded objects +which are still in the line of sight, but occluded by some larger object +between the object and the eye (camera). Occlusion queries check exactly that. +The queries basically measure the number of pixels that a previous render +left on the screen. +Since those pixels cannot be recognized at the end of a rendering anymore, +the pixel count is measured directly when rendering. Thus, one needs to render +the occluder (the object in front) first. This object needs to write to the +z-buffer in order to become a real occluder. Then the node is rendered and in +case a z-pass happens, i.e. the pixel is written to the framebuffer, the pixel +is counted in the query. +The result of a query is the number of pixels which got through. One can, based +on this number, judge if the scene node is visible enough to be rendered, or if +the node should be removed in the next round. Also note that the number of +pixels is a safe over approximation in general. The pixels might be overdrawn +later on, and the GPU tries to avoid inaccuracies which could lead to false +negatives in the queries. + +As you might have recognized already, we had to render the node to get the +numbers. So where's the benefit, you might say. There are several ways where +occlusion queries can help. It is often a good idea to just render the bbox +of the node instead of the actual mesh. This is really fast and is a safe over +approximation. If you need a more exact render with the actual geometry, it's +a good idea to render with just basic solid material. Avoid complex shaders +and state changes through textures. There's no need while just doing the +occlusion query. At least if the render is not used for the actual scene. This +is the third way to optimize occlusion queries. Just check the queries every +5th or 10th frame, or even less frequent. This depends on the movement speed +of the objects and camera. +*/ + +#ifdef _MSC_VER +// We'll also define this to stop MSVC complaining about sprintf(). +#define _CRT_SECURE_NO_WARNINGS +#pragma comment(lib, "Irrlicht.lib") +#endif + +#include +#include "driverChoice.h" + +using namespace irr; + +/* +We need keyboard input events to switch some parameters +*/ +class MyEventReceiver : public IEventReceiver +{ +public: + // This is the one method that we have to implement + virtual bool OnEvent(const SEvent& event) + { + // Remember whether each key is down or up + if (event.EventType == irr::EET_KEY_INPUT_EVENT) + KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown; + + return false; + } + + // This is used to check whether a key is being held down + virtual bool IsKeyDown(EKEY_CODE keyCode) const + { + return KeyIsDown[keyCode]; + } + + MyEventReceiver() + { + for (u32 i=0; i(640, 480), 16, false, false, false, &receiver); + + if (device == 0) + return 1; // could not create selected driver. + + video::IVideoDriver* driver = device->getVideoDriver(); + scene::ISceneManager* smgr = device->getSceneManager(); + + smgr->getGUIEnvironment()->addStaticText(L"Press Space to hide occluder.", core::recti(10,10, 200,50)); + + /* + Create the node to be occluded. We create a sphere node with high poly count. + */ + scene::ISceneNode * node = smgr->addSphereSceneNode(10, 64); + if (node) + { + node->setPosition(core::vector3df(0,0,60)); + node->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp")); + node->setMaterialFlag(video::EMF_LIGHTING, false); + } + + /* + Now we create another node, the occluder. It's a simple plane. + */ + scene::ISceneNode* plane = smgr->addMeshSceneNode(smgr->addHillPlaneMesh( + "plane", core::dimension2df(10,10), core::dimension2du(2,2)), 0, -1, + core::vector3df(0,0,20), core::vector3df(270,0,0)); + + if (plane) + { + plane->setMaterialTexture(0, driver->getTexture("../../media/t351sml.jpg")); + plane->setMaterialFlag(video::EMF_LIGHTING, false); + plane->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true); + } + + /* + Here we create the occlusion query. Because we don't have a plain mesh scene node + (ESNT_MESH or ESNT_ANIMATED_MESH), we pass the base geometry as well. Instead, + we could also pass a simpler mesh or the bounding box. But we will use a time + based method, where the occlusion query renders to the frame buffer and in case + of success (occlusion), the mesh is not drawn for several frames. + */ + driver->addOcclusionQuery(node, ((scene::IMeshSceneNode*)node)->getMesh()); + + /* + We have done everything, just a camera and draw it. We also write the + current frames per second and the name of the driver to the caption of the + window to examine the render speedup. + We also store the time for measuring the time since the last occlusion query ran + and store whether the node should be visible in the next frames. + */ + smgr->addCameraSceneNode(); + int lastFPS = -1; + u32 timeNow = device->getTimer()->getTime(); + bool nodeVisible=true; + + while(device->run()) + { + plane->setVisible(!receiver.IsKeyDown(irr::KEY_SPACE)); + + driver->beginScene(true, true, video::SColor(255,113,113,133)); + /* + First, we draw the scene, possibly without the occluded element. This is necessary + because we need the occluder to be drawn first. You can also use several scene + managers to collect a number of possible occluders in a separately rendered + scene. + */ + node->setVisible(nodeVisible); + smgr->drawAll(); + smgr->getGUIEnvironment()->drawAll(); + + /* + Once in a while, here every 100 ms, we check the visibility. We run the queries, + update the pixel value, and query the result. Since we already rendered the node + we render the query invisible. The update is made blocking, as we need the result + immediately. If you don't need the result immediately, e.g. because you have other + things to render, you can call the update non-blocking. This gives the GPU more + time to pass back the results without flushing the render pipeline. + If the update was called non-blocking, the result from getOcclusionQueryResult is + either the previous value, or 0xffffffff if no value has been generated at all, yet. + The result is taken immediately as visibility flag for the node. + */ + if (device->getTimer()->getTime()-timeNow>100) + { + driver->runAllOcclusionQueries(false); + driver->updateAllOcclusionQueries(); + nodeVisible=driver->getOcclusionQueryResult(node)>0; + timeNow=device->getTimer()->getTime(); + } + + driver->endScene(); + + int fps = driver->getFPS(); + + if (lastFPS != fps) + { + core::stringw tmp(L"OcclusionQuery Example ["); + tmp += driver->getName(); + tmp += L"] fps: "; + tmp += fps; + + device->setWindowCaption(tmp.c_str()); + lastFPS = fps; + } + } + + /* + In the end, delete the Irrlicht device. + */ + device->drop(); + + return 0; +} + +/* +That's it. Compile and play around with the program. +**/ -- cgit v1.1