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