aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/examples/14.Win32Window/tutorial.html
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/examples/14.Win32Window/tutorial.html')
-rw-r--r--src/others/irrlicht-1.8.1/examples/14.Win32Window/tutorial.html247
1 files changed, 247 insertions, 0 deletions
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 @@
1<html>
2<head>
3<title>Irrlicht Engine Tutorial</title>
4<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5</head>
6
7<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
8<br>
9<table width="95%" border="0" cellspacing="0" cellpadding="2" align="center">
10 <tr>
11 <td bgcolor="#666699" width="10"><b><a href="http://irrlicht.sourceforge.net" target="_blank"><img src="../../media/irrlichtlogo.jpg" width="88" height="31" border="0"></a></b></td>
12 <td bgcolor="#666699" width="100%">
13<div align="center">
14 <div align="left"><b><font color="#FFFFFF">Tutorial 14. Win32 Window</font></b></div>
15 </div>
16 </td>
17 </tr>
18 <tr bgcolor="#eeeeff">
19 <td height="90" colspan="2">
20 <div align="left">
21 <p> This example only runs in Windows and demonstrates that Irrlicht can
22 run inside a win32 window. MFC and .NET Windows.Forms windows are possible
23 too. </p>
24 <p>The program which is described here will look like this:</p>
25 <p align="center"><img src="../../media/014shot.jpg" width="256" height="200"><br>
26 </p>
27 </div>
28 </td>
29 </tr>
30</table>
31<br>
32<table width="95%" border="0" cellspacing="0" cellpadding="2" align="center">
33 <tr>
34 <td bgcolor="#666699"> <b><font color="#FFFFFF">Lets start!</font></b></td>
35 </tr>
36 <tr>
37 <td height="90" bgcolor="#eeeeff" valign="top"> <div align="left">
38 <div align="left">
39 <p> In the begining, we create a windows window using the windows API.
40 I'm not going to explain this code, because it is windows specific.
41 See the MSDN or a windows book for details.</p>
42 <table width="95%" border="0" cellspacing="2" cellpadding="0" bgcolor="#CCCCCC" align="center">
43 <tr>
44 <td><pre>#include &lt;irrlicht.h&gt;
45#include &lt;windows.h&gt; <font color="#006600">// this example only runs with windows</font>
46
47using namespace irr;
48
49#pragma comment(lib, "irrlicht.lib")
50
51HWND hOKButton;
52HWND hWnd;
53
54static LRESULT CALLBACK CustomWndProc(HWND hWnd, UINT message,
55 WPARAM wParam, LPARAM lParam)
56{
57 switch (message)
58 {
59 case WM_COMMAND:
60 {
61 HWND hwndCtl = (HWND)lParam;
62 int code = HIWORD(wParam);
63
64 if (hwndCtl == hOKButton)
65 {
66 DestroyWindow(hWnd);
67 PostQuitMessage(0);
68 return 0;
69 }
70 }
71 break;
72 case WM_DESTROY:
73 PostQuitMessage(0);
74 return 0;
75
76 }
77
78 return DefWindowProc(hWnd, message, wParam, lParam);
79}
80
81int main()
82<font color="#006600">//int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpre, LPSTR cmd, int cc)</font>
83{
84 HINSTANCE hInstance = 0;
85<font color="#006600"> // create dialog</font>
86
87 const char* Win32ClassName = "CIrrlichtWindowsTestDialog";
88
89 WNDCLASSEX wcex;
90 wcex.cbSize = sizeof(WNDCLASSEX);
91 wcex.style = CS_HREDRAW | CS_VREDRAW;
92 wcex.lpfnWndProc = (WNDPROC)CustomWndProc;
93 wcex.cbClsExtra = 0;
94 wcex.cbWndExtra = DLGWINDOWEXTRA;
95 wcex.hInstance = hInstance;
96 wcex.hIcon = NULL;
97 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
98 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW);
99 wcex.lpszMenuName = 0;
100 wcex.lpszClassName = Win32ClassName;
101 wcex.hIconSm = 0;
102
103 RegisterClassEx(&wcex);
104
105 DWORD style = WS_SYSMENU | WS_BORDER | WS_CAPTION |
106 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX
107 | WS_MINIMIZEBOX | WS_SIZEBOX;
108
109 int windowWidth = 440;
110 int windowHeight = 380;
111
112 hWnd = CreateWindow( Win32ClassName, "Irrlicht Win32 window example",
113 style, 100, 100, windowWidth, windowHeight,
114 NULL, NULL, hInstance, NULL);
115
116 RECT clientRect;
117 GetClientRect(hWnd, &clientRect);
118 windowWidth = clientRect.right;
119 windowHeight = clientRect.bottom;
120
121<font color="#006600"> // create ok butt</font>on
122
123 hOKButton = CreateWindow(
124 "BUTTON", "OK - Close", WS_CHILD | WS_VISIBLE | BS_TEXT,
125 windowWidth - 160, windowHeight - 40, 150, 30, hWnd, NULL,
126 hInstance, NULL);
127
128<font color="#006600"> // create some text</font>
129
130 CreateWindow("STATIC",
131 "This is Irrlicht running inside a standard Win32 window.\n"\
132 "Also mixing with MFC and .NET Windows.Forms is possible.",
133 WS_CHILD | WS_VISIBLE, 20, 20, 400, 40, hWnd, NULL, hInstance, NULL);
134
135<font color="#006600"> // create window to put irrlicht in</font>
136
137 HWND hIrrlichtWindow =<br /> CreateWindow("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
138 50, 80, 320, 220, hWnd, NULL, hInstance, NULL);
139
140</pre></td>
141 </tr>
142 </table>
143 <p>So now that we have some window, we can create an Irrlicht device
144 inside of it. We use Irrlicht createEx() function for this. We only
145 need the handle (HWND) to that window, set it as windowsID parameter
146 and start up the engine as usual. That's it.</p>
147 <table width="95%" border="0" cellspacing="2" cellpadding="0" bgcolor="#CCCCCC" align="center">
148 <tr>
149 <td><pre><font color="#006600"> // create irrlicht device in the button window</font>
150
151 irr::SIrrlichtCreationParameters param;
152 param.WindowId = reinterpret_cast<s32>(hIrrlichtWindow); // hColorButton
153 param.DriverType = video::EDT_OPENGL;
154
155 irr::IrrlichtDevice* device = irr::createDeviceEx(param);
156
157<font color="#006600"> // setup a simple 3d scene</font>
158
159 irr::scene::ISceneManager* smgr = device->getSceneManager();
160 video::IVideoDriver* driver = device->getVideoDriver();
161
162 scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
163 cam->setTarget(core::vector3df(0,0,0));
164
165 scene::ISceneNodeAnimator* anim =
166 smgr->createFlyCircleAnimator(core::vector3df(0,10,0), 30.0f);
167 cam->addAnimator(anim);
168 anim->drop();
169
170 scene::ISceneNode* cube = smgr->addCubeSceneNode(25);
171 cube->setMaterialFlag(video::EMF_LIGHTING, false);
172
173 cube->setMaterialTexture(0, driver->getTexture("../../media/rockwall.bmp"));
174
175 smgr->addSkyBoxSceneNode(
176 driver->getTexture("../../media/irrlicht2_up.jpg"),
177 driver->getTexture("../../media/irrlicht2_dn.jpg"),
178 driver->getTexture("../../media/irrlicht2_lf.jpg"),
179 driver->getTexture("../../media/irrlicht2_rt.jpg"),
180 driver->getTexture("../../media/irrlicht2_ft.jpg"),
181 driver->getTexture("../../media/irrlicht2_bk.jpg"));
182
183<font color="#006600"> // show and execute dialog</font>
184
185 ShowWindow(hWnd , SW_SHOW);
186 UpdateWindow(hWnd);
187</pre></td>
188 </tr>
189 </table>
190 <p>Now the only thing missing is the drawing loop using IrrlichtDevice::run().
191 We do this as usual. But instead of this, there is another possibility:
192 You can also simply use your own message loop using GetMessage, DispatchMessage
193 and whatever. Calling<br />
194 Device-&gt;run() will cause Irrlicht to dispatch messages internally
195 too. You need not call Device-&gt;run() if you want to do your own
196 message dispatching loop, but Irrlicht will not be able to fetch user
197 input then and you have to do it on your own using the window messages,
198 DirectInput, or whatever.</p>
199 <table width="95%" border="0" cellspacing="2" cellpadding="0" bgcolor="#CCCCCC" align="center">
200 <tr>
201 <td><pre> while (device->run())
202 {
203 driver->beginScene(true, true, 0);
204 smgr->drawAll();
205 driver->endScene();
206 }
207
208<font color="#006600"> // the alternative, own message dispatching loop without Device->run() would
209 // look like this:</font>
210
211 <font color="#006600">/*MSG msg;
212 while (true)
213 {
214 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
215 {
216 TranslateMessage(&msg);
217 DispatchMessage(&msg);
218
219 if (msg.message == WM_QUIT)
220 break;
221 }
222
223 // advance virtual time
224 device->getTimer()->tick();
225
226 // draw engine picture
227 driver->beginScene(true, true, 0);
228 smgr->drawAll();
229 driver->endScene();
230 }*/</font>
231
232 device->closeDevice();
233 device->drop();
234
235 return 0;
236}</pre></td>
237 </tr>
238 </table>
239 <p> That's it, Irrlicht now runs in your own windows window.</p>
240 </div>
241 </div>
242 </td>
243 </tr>
244</table>
245<p>&nbsp;</p>
246 </body>
247</html>