From 7028cbe09c688437910a25623098762bf0fa592d Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 28 Mar 2016 22:28:34 +1000 Subject: Move Irrlicht to src/others. --- .../examples/14.Win32Window/Makefile | 38 ++++ .../examples/14.Win32Window/Win32Window.cbp | 43 ++++ .../examples/14.Win32Window/Win32Window.dev | 59 +++++ .../examples/14.Win32Window/Win32Window.vcproj | 165 ++++++++++++++ .../14.Win32Window/Win32Window_vc10.vcxproj | 235 +++++++++++++++++++ .../14.Win32Window/Win32Window_vc11.vcxproj | 239 ++++++++++++++++++++ .../examples/14.Win32Window/Win32Window_vc8.vcproj | 232 +++++++++++++++++++ .../examples/14.Win32Window/Win32Window_vc9.vcproj | 232 +++++++++++++++++++ .../examples/14.Win32Window/main.cpp | 251 +++++++++++++++++++++ .../examples/14.Win32Window/tutorial.html | 247 ++++++++++++++++++++ 10 files changed, 1741 insertions(+) create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/Makefile create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.cbp create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.dev create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.vcproj create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc10.vcxproj create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc11.vcxproj create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc8.vcproj create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc9.vcproj create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/main.cpp create mode 100644 src/others/irrlicht-1.8.1/examples/14.Win32Window/tutorial.html (limited to 'src/others/irrlicht-1.8.1/examples/14.Win32Window') diff --git a/src/others/irrlicht-1.8.1/examples/14.Win32Window/Makefile b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Makefile new file mode 100644 index 0000000..e76f2ff --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/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 = 14.Win32Window +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/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.cbp b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.cbp new file mode 100644 index 0000000..06f310b --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.cbp @@ -0,0 +1,43 @@ + + + + + + diff --git a/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.dev b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.dev new file mode 100644 index 0000000..6192563 --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.dev @@ -0,0 +1,59 @@ +[Project] +FileName=example.dev +Name=Irrlicht Example 14 Win32 Window +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=14.Win32Window.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/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.vcproj b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.vcproj new file mode 100644 index 0000000..c8576c7 --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window.vcproj @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc10.vcxproj b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc10.vcxproj new file mode 100644 index 0000000..f18c583 --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc10.vcxproj @@ -0,0 +1,235 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 14.Win32Window + {772FBE05-D05A-467B-9842-BEC409EEA8D0} + Win32Window + + + + 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/Win32Window.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + opengl32.lib;%(AdditionalDependencies) + ..\..\bin\Win32-VisualStudio\14.Win32Window.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Debug/Win32Window.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + opengl32.lib;%(AdditionalDependencies) + ..\..\bin\Win64-VisualStudio\14.Win32Window.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Release/Win32Window.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + opengl32.lib;%(AdditionalDependencies) + ..\..\bin\Win32-VisualStudio\14.Win32Window.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Release/Win32Window.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + opengl32.lib;%(AdditionalDependencies) + ..\..\bin\Win64-VisualStudio\14.Win32Window.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/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc11.vcxproj b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc11.vcxproj new file mode 100644 index 0000000..07a2fce --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc11.vcxproj @@ -0,0 +1,239 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 14.Win32Window + {772FBE05-D05A-467B-9842-BEC409EEA8D0} + Win32Window + + + + 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/Win32Window.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + opengl32.lib;%(AdditionalDependencies) + ..\..\bin\Win32-VisualStudio\14.Win32Window.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Debug/Win32Window.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + opengl32.lib;%(AdditionalDependencies) + ..\..\bin\Win64-VisualStudio\14.Win32Window.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Release/Win32Window.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + opengl32.lib;%(AdditionalDependencies) + ..\..\bin\Win32-VisualStudio\14.Win32Window.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Release/Win32Window.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + opengl32.lib;%(AdditionalDependencies) + ..\..\bin\Win64-VisualStudio\14.Win32Window.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/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc8.vcproj b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc8.vcproj new file mode 100644 index 0000000..efbf43d --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc8.vcproj @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc9.vcproj b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc9.vcproj new file mode 100644 index 0000000..2902fba --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/Win32Window_vc9.vcproj @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/others/irrlicht-1.8.1/examples/14.Win32Window/main.cpp b/src/others/irrlicht-1.8.1/examples/14.Win32Window/main.cpp new file mode 100644 index 0000000..33d111e --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/main.cpp @@ -0,0 +1,251 @@ +/** Example 014 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 beginning, 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 +#ifndef _IRR_WINDOWS_ +#error Windows only example +#else +#include // this example only runs with windows +#include +#include "driverChoice.h" + +using namespace irr; + +#pragma comment(lib, "irrlicht.lib") + +HWND hOKButton; +HWND hWnd; + +static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message, + WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COMMAND: + { + HWND hwndCtl = (HWND)lParam; + int code = HIWORD(wParam); + + if (hwndCtl == hOKButton) + { + DestroyWindow(hWnd); + PostQuitMessage(0); + return 0; + } + } + break; + case WM_DESTROY: + PostQuitMessage(0); + return 0; + + } + + return DefWindowProc(hWnd, message, wParam, lParam); +} + + +/* + Now ask for the driver and create the Windows specific window. +*/ +int main() +{ + // ask user for driver + video::E_DRIVER_TYPE driverType=driverChoiceConsole(); + if (driverType==video::EDT_COUNT) + return 1; + + printf("Select the render window (some dead window may exist too):\n"\ + " (a) Window with button (via CreationParam)\n"\ + " (b) Window with button (via beginScene)\n"\ + " (c) Own Irrlicht window (default behavior)\n"\ + " (otherKey) exit\n\n"); + + char key; + std::cin >> key; + if (key != 'a' && key != 'b' && key != 'c') + return 1; + + HINSTANCE hInstance = 0; + // create dialog + + const char* Win32ClassName = "CIrrlichtWindowsTestDialog"; + + WNDCLASSEX wcex; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = (WNDPROC)CustomWndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = DLGWINDOWEXTRA; + wcex.hInstance = hInstance; + wcex.hIcon = NULL; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW); + wcex.lpszMenuName = 0; + wcex.lpszClassName = Win32ClassName; + wcex.hIconSm = 0; + + RegisterClassEx(&wcex); + + DWORD style = WS_SYSMENU | WS_BORDER | WS_CAPTION | + WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX; + + int windowWidth = 440; + int windowHeight = 380; + + hWnd = CreateWindow( Win32ClassName, "Irrlicht Win32 window example", + style, 100, 100, windowWidth, windowHeight, + NULL, NULL, hInstance, NULL); + + RECT clientRect; + GetClientRect(hWnd, &clientRect); + windowWidth = clientRect.right; + windowHeight = clientRect.bottom; + + // create ok button + + hOKButton = CreateWindow("BUTTON", "OK - Close", WS_CHILD | WS_VISIBLE | BS_TEXT, + windowWidth - 160, windowHeight - 40, 150, 30, hWnd, NULL, hInstance, NULL); + + // create some text + + CreateWindow("STATIC", "This is Irrlicht running inside a standard Win32 window.\n"\ + "Also mixing with MFC and .NET Windows.Forms is possible.", + WS_CHILD | WS_VISIBLE, 20, 20, 400, 40, hWnd, NULL, hInstance, NULL); + + // create window to put irrlicht in + + HWND hIrrlichtWindow = CreateWindow("BUTTON", "", + WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 50, 80, 320, 220, hWnd, NULL, hInstance, NULL); + video::SExposedVideoData videodata((key=='b')?hIrrlichtWindow:0); + + /* + 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 + + irr::SIrrlichtCreationParameters param; + param.DriverType = driverType; + if (key=='a') + param.WindowId = reinterpret_cast(hIrrlichtWindow); + + irr::IrrlichtDevice* device = irr::createDeviceEx(param); + if (!device) + return 1; + + // setup a simple 3d scene + + irr::scene::ISceneManager* smgr = device->getSceneManager(); + video::IVideoDriver* driver = device->getVideoDriver(); + + if (driverType==video::EDT_OPENGL) + { + HDC HDc=GetDC(hIrrlichtWindow); + PIXELFORMATDESCRIPTOR pfd={0}; + pfd.nSize=sizeof(PIXELFORMATDESCRIPTOR); + int pf = GetPixelFormat(HDc); + DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); + pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; + pfd.cDepthBits=16; + pf = ChoosePixelFormat(HDc, &pfd); + SetPixelFormat(HDc, pf, &pfd); + videodata.OpenGLWin32.HDc = HDc; + videodata.OpenGLWin32.HRc=wglCreateContext(HDc); + wglShareLists((HGLRC)driver->getExposedVideoData().OpenGLWin32.HRc, (HGLRC)videodata.OpenGLWin32.HRc); + } + scene::ICameraSceneNode* cam = smgr->addCameraSceneNode(); + cam->setTarget(core::vector3df(0,0,0)); + + scene::ISceneNodeAnimator* anim = + smgr->createFlyCircleAnimator(core::vector3df(0,15,0), 30.0f); + cam->addAnimator(anim); + anim->drop(); + + scene::ISceneNode* cube = smgr->addCubeSceneNode(20); + + cube->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp")); + cube->setMaterialTexture(1, driver->getTexture("../../media/water.jpg")); + cube->setMaterialFlag( video::EMF_LIGHTING, false ); + cube->setMaterialType( video::EMT_REFLECTION_2_LAYER ); + + smgr->addSkyBoxSceneNode( + driver->getTexture("../../media/irrlicht2_up.jpg"), + driver->getTexture("../../media/irrlicht2_dn.jpg"), + driver->getTexture("../../media/irrlicht2_lf.jpg"), + driver->getTexture("../../media/irrlicht2_rt.jpg"), + driver->getTexture("../../media/irrlicht2_ft.jpg"), + driver->getTexture("../../media/irrlicht2_bk.jpg")); + + // show and execute dialog + + ShowWindow(hWnd , SW_SHOW); + UpdateWindow(hWnd); + + // do message queue + + /* + Now the only thing missing is the drawing loop using + IrrlichtDevice::run(). We do this as usual. But instead of this, there + is another possibility: You can also simply use your own message loop + using GetMessage, DispatchMessage and whatever. Calling + Device->run() will cause Irrlicht to dispatch messages internally too. + 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()) + { + driver->beginScene(true, true, 0, videodata); + smgr->drawAll(); + driver->endScene(); + } + + /* + The alternative, own message dispatching loop without Device->run() + would look like this: + */ + + /*MSG msg; + while (true) + { + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + + if (msg.message == WM_QUIT) + break; + } + + // advance virtual time + device->getTimer()->tick(); + + // draw engine picture + driver->beginScene(true, true, 0, (key=='c')?hIrrlichtWindow:0); + smgr->drawAll(); + driver->endScene(); + }*/ + + device->closeDevice(); + device->drop(); + + return 0; +} +#endif // if windows + +/* +That's it, Irrlicht now runs in your own windows window. +**/ diff --git a/src/others/irrlicht-1.8.1/examples/14.Win32Window/tutorial.html b/src/others/irrlicht-1.8.1/examples/14.Win32Window/tutorial.html new file mode 100644 index 0000000..6c5d5ba --- /dev/null +++ b/src/others/irrlicht-1.8.1/examples/14.Win32Window/tutorial.html @@ -0,0 +1,247 @@ + + +Irrlicht Engine Tutorial + + + + +
+ + + + + + + + +
+
+
Tutorial 14. Win32 Window
+
+
+
+

This example only runs in Windows and demonstrates that Irrlicht can + run inside a win32 window. MFC and .NET Windows.Forms windows are possible + too.

+

The program which is described here will look like this:

+


+

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

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 <windows.h> // this example only runs with windows
+
+using namespace irr;
+
+#pragma comment(lib, "irrlicht.lib")
+
+HWND hOKButton;
+HWND hWnd;
+
+static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message,
+    WPARAM wParam, LPARAM lParam)
+{
+	switch (message) 
+	{
+	case WM_COMMAND:
+		{
+			HWND hwndCtl = (HWND)lParam;
+			int code = HIWORD(wParam);
+
+			if (hwndCtl == hOKButton)
+			{
+				DestroyWindow(hWnd);
+				PostQuitMessage(0);
+				return 0;
+			}		
+		}
+		break;
+	case WM_DESTROY:
+		PostQuitMessage(0);
+		return 0;
+
+	}
+
+	return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+int main()
+//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpre, LPSTR cmd, int cc)
+{
+	HINSTANCE hInstance = 0;
+	// create dialog
+
+	const char* Win32ClassName = "CIrrlichtWindowsTestDialog";
+
+	WNDCLASSEX wcex;
+	wcex.cbSize			= sizeof(WNDCLASSEX); 
+	wcex.style			= CS_HREDRAW | CS_VREDRAW;
+	wcex.lpfnWndProc	= (WNDPROC)CustomWndProc;
+	wcex.cbClsExtra		= 0;
+	wcex.cbWndExtra		= DLGWINDOWEXTRA; 
+	wcex.hInstance		= hInstance;
+	wcex.hIcon			= NULL;
+	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
+	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW);
+	wcex.lpszMenuName	= 0;
+	wcex.lpszClassName	= Win32ClassName;
+	wcex.hIconSm		= 0;
+
+	RegisterClassEx(&wcex);
+
+	DWORD style = WS_SYSMENU | WS_BORDER | WS_CAPTION | 
+		WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX
+		| WS_MINIMIZEBOX | WS_SIZEBOX;
+
+	int windowWidth = 440;
+	int windowHeight = 380;
+
+	hWnd = CreateWindow( Win32ClassName, "Irrlicht Win32 window example",
+		style, 100, 100, windowWidth, windowHeight,
+		NULL, NULL, hInstance, NULL);
+
+	RECT clientRect;
+	GetClientRect(hWnd, &clientRect);
+	windowWidth = clientRect.right;
+	windowHeight = clientRect.bottom;
+
+	// create ok button
+
+	hOKButton = CreateWindow(
+	    "BUTTON", "OK - Close", WS_CHILD | WS_VISIBLE | BS_TEXT, 
+		windowWidth - 160, windowHeight - 40, 150, 30, hWnd, NULL, 
+		hInstance, NULL);
+
+	// create some text
+	
+	CreateWindow("STATIC", 
+        "This is Irrlicht running inside a standard Win32 window.\n"\
+		"Also mixing with MFC and .NET Windows.Forms is possible.",
+		WS_CHILD | WS_VISIBLE, 20, 20, 400, 40, hWnd, NULL, hInstance, NULL);
+
+	// create window to put irrlicht in
+
+	HWND hIrrlichtWindow =
CreateWindow("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 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
+
+	irr::SIrrlichtCreationParameters param;
+	param.WindowId = reinterpret_cast(hIrrlichtWindow); // hColorButton
+	param.DriverType = video::EDT_OPENGL;
+
+	irr::IrrlichtDevice* device = irr::createDeviceEx(param);
+	
+	// setup a simple 3d scene
+
+	irr::scene::ISceneManager* smgr = device->getSceneManager();
+	video::IVideoDriver* driver = device->getVideoDriver();
+
+	scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
+	cam->setTarget(core::vector3df(0,0,0));
+
+	scene::ISceneNodeAnimator* anim =
+	   smgr->createFlyCircleAnimator(core::vector3df(0,10,0), 30.0f);
+	cam->addAnimator(anim);
+	anim->drop();
+
+	scene::ISceneNode* cube = smgr->addCubeSceneNode(25);
+	cube->setMaterialFlag(video::EMF_LIGHTING, false);
+	
+	cube->setMaterialTexture(0, driver->getTexture("../../media/rockwall.bmp"));
+
+	smgr->addSkyBoxSceneNode(
+	driver->getTexture("../../media/irrlicht2_up.jpg"),
+	driver->getTexture("../../media/irrlicht2_dn.jpg"),
+	driver->getTexture("../../media/irrlicht2_lf.jpg"),
+	driver->getTexture("../../media/irrlicht2_rt.jpg"),
+	driver->getTexture("../../media/irrlicht2_ft.jpg"),
+	driver->getTexture("../../media/irrlicht2_bk.jpg"));
+
+	// show and execute dialog
+
+	ShowWindow(hWnd , SW_SHOW);
+	UpdateWindow(hWnd);
+
+

Now the only thing missing is the drawing loop using IrrlichtDevice::run(). + We do this as usual. But instead of this, there is another possibility: + You can also simply use your own message loop using GetMessage, DispatchMessage + and whatever. Calling
+ Device->run() will cause Irrlicht to dispatch messages internally + too. 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())
+	{
+		driver->beginScene(true, true, 0);
+		smgr->drawAll();
+		driver->endScene();
+	}
+
+	// the alternative, own message dispatching loop without Device->run() would
+	// look like this:
+
+	/*MSG msg;
+	while (true)
+	{
+		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+		{
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+
+			if (msg.message == WM_QUIT)
+				break;
+		}
+		
+		// advance virtual time
+		device->getTimer()->tick();
+
+		// draw engine picture
+		driver->beginScene(true, true, 0);
+		smgr->drawAll();
+		driver->endScene();
+	}*/
+
+	device->closeDevice();
+	device->drop();
+
+	return 0;
+}
+

That's it, Irrlicht now runs in your own windows window.

+
+
+
+

 

+ + -- cgit v1.1