]> git.lizzy.rs Git - dragonfireclient.git/blob - src/drawscene.cpp
Cavegen: Fix copy & paste error (solves #2020)
[dragonfireclient.git] / src / drawscene.cpp
1 /*
2 Minetest
3 Copyright (C) 2010-2014 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "drawscene.h"
21 #include "main.h" // for g_settings
22 #include "settings.h"
23 #include "clouds.h"
24 #include "clientmap.h"
25 #include "util/timetaker.h"
26 #include "fontengine.h"
27
28 typedef enum {
29         LEFT = -1,
30         RIGHT = 1,
31         EYECOUNT = 2
32 } paralax_sign;
33
34
35 void draw_selectionbox(video::IVideoDriver* driver, Hud& hud,
36                 std::vector<aabb3f>& hilightboxes, bool show_hud)
37 {
38         static const s16 selectionbox_width = rangelim(g_settings->getS16("selectionbox_width"), 1, 5);
39
40         if (!show_hud)
41                 return;
42
43         video::SMaterial oldmaterial = driver->getMaterial2D();
44         video::SMaterial m;
45         m.Thickness = selectionbox_width;
46         m.Lighting = false;
47         driver->setMaterial(m);
48         hud.drawSelectionBoxes(hilightboxes);
49         driver->setMaterial(oldmaterial);
50 }
51
52 void draw_anaglyph_3d_mode(Camera& camera, bool show_hud, Hud& hud,
53                 std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
54                 scene::ISceneManager* smgr, bool draw_wield_tool, Client& client,
55                 gui::IGUIEnvironment* guienv )
56 {
57
58         /* preserve old setup*/
59         irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition();
60         irr::core::vector3df oldTarget   = camera.getCameraNode()->getTarget();
61
62         irr::core::matrix4 startMatrix =
63                         camera.getCameraNode()->getAbsoluteTransformation();
64         irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget()
65                         - camera.getCameraNode()->getAbsolutePosition()).setLength(1)
66                         + camera.getCameraNode()->getAbsolutePosition();
67
68
69         //Left eye...
70         irr::core::vector3df leftEye;
71         irr::core::matrix4 leftMove;
72         leftMove.setTranslation(
73                         irr::core::vector3df(-g_settings->getFloat("3d_paralax_strength"),
74                                         0.0f, 0.0f));
75         leftEye = (startMatrix * leftMove).getTranslation();
76
77         //clear the depth buffer, and color
78         driver->beginScene( true, true, irr::video::SColor(0, 200, 200, 255));
79         driver->getOverrideMaterial().Material.ColorMask = irr::video::ECP_RED;
80         driver->getOverrideMaterial().EnableFlags = irr::video::EMF_COLOR_MASK;
81         driver->getOverrideMaterial().EnablePasses = irr::scene::ESNRP_SKY_BOX
82                         + irr::scene::ESNRP_SOLID + irr::scene::ESNRP_TRANSPARENT
83                         + irr::scene::ESNRP_TRANSPARENT_EFFECT + irr::scene::ESNRP_SHADOW;
84         camera.getCameraNode()->setPosition(leftEye);
85         camera.getCameraNode()->setTarget(focusPoint);
86         smgr->drawAll();
87         driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
88         if (show_hud)
89         {
90                 draw_selectionbox(driver, hud, hilightboxes, show_hud);
91
92                 if (draw_wield_tool)
93                         camera.drawWieldedTool(&leftMove);
94         }
95
96         guienv->drawAll();
97
98         //Right eye...
99         irr::core::vector3df rightEye;
100         irr::core::matrix4 rightMove;
101         rightMove.setTranslation(
102                         irr::core::vector3df(g_settings->getFloat("3d_paralax_strength"),
103                                         0.0f, 0.0f));
104         rightEye = (startMatrix * rightMove).getTranslation();
105
106         //clear the depth buffer
107         driver->clearZBuffer();
108         driver->getOverrideMaterial().Material.ColorMask = irr::video::ECP_GREEN
109                         + irr::video::ECP_BLUE;
110         driver->getOverrideMaterial().EnableFlags = irr::video::EMF_COLOR_MASK;
111         driver->getOverrideMaterial().EnablePasses = irr::scene::ESNRP_SKY_BOX
112                         + irr::scene::ESNRP_SOLID + irr::scene::ESNRP_TRANSPARENT
113                         + irr::scene::ESNRP_TRANSPARENT_EFFECT + irr::scene::ESNRP_SHADOW;
114         camera.getCameraNode()->setPosition(rightEye);
115         camera.getCameraNode()->setTarget(focusPoint);
116         smgr->drawAll();
117         driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
118         if (show_hud)
119         {
120                 draw_selectionbox(driver, hud, hilightboxes, show_hud);
121
122                 if (draw_wield_tool)
123                         camera.drawWieldedTool(&rightMove);
124         }
125
126         guienv->drawAll();
127
128         driver->getOverrideMaterial().Material.ColorMask = irr::video::ECP_ALL;
129         driver->getOverrideMaterial().EnableFlags = 0;
130         driver->getOverrideMaterial().EnablePasses = 0;
131         camera.getCameraNode()->setPosition(oldPosition);
132         camera.getCameraNode()->setTarget(oldTarget);
133 }
134
135 void init_texture(video::IVideoDriver* driver, const v2u32& screensize,
136                 video::ITexture** texture, const char* name)
137 {
138         if (*texture != NULL)
139         {
140                 driver->removeTexture(*texture);
141         }
142         *texture = driver->addRenderTargetTexture(
143                         core::dimension2d<u32>(screensize.X, screensize.Y), name,
144                         irr::video::ECF_A8R8G8B8);
145 }
146
147 video::ITexture* draw_image(const v2u32& screensize,
148                 paralax_sign psign, const irr::core::matrix4& startMatrix,
149                 const irr::core::vector3df& focusPoint, bool show_hud,
150                 video::IVideoDriver* driver, Camera& camera, scene::ISceneManager* smgr,
151                 Hud& hud, std::vector<aabb3f>& hilightboxes,
152                 bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
153                 video::SColor skycolor )
154 {
155         static video::ITexture* images[2] = { NULL, NULL };
156         static v2u32 last_screensize = v2u32(0,0);
157
158         video::ITexture* image = NULL;
159
160         if (screensize != last_screensize) {
161                 init_texture(driver, screensize, &images[1], "mt_drawimage_img1");
162                 init_texture(driver, screensize, &images[0], "mt_drawimage_img2");
163                 last_screensize = screensize;
164         }
165
166         if (psign == RIGHT)
167                 image = images[1];
168         else
169                 image = images[0];
170         
171         driver->setRenderTarget(image, true, true,
172                         irr::video::SColor(255,
173                                         skycolor.getRed(), skycolor.getGreen(), skycolor.getBlue()));
174
175         irr::core::vector3df eye_pos;
176         irr::core::matrix4 movement;
177         movement.setTranslation(
178                         irr::core::vector3df((int) psign *
179                                         g_settings->getFloat("3d_paralax_strength"), 0.0f, 0.0f));
180         eye_pos = (startMatrix * movement).getTranslation();
181
182         //clear the depth buffer
183         driver->clearZBuffer();
184         camera.getCameraNode()->setPosition(eye_pos);
185         camera.getCameraNode()->setTarget(focusPoint);
186         smgr->drawAll();
187
188         driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
189
190         if (show_hud)
191         {
192                 draw_selectionbox(driver, hud, hilightboxes, show_hud);
193
194                 if (draw_wield_tool)
195                         camera.drawWieldedTool(&movement);
196         }
197
198         guienv->drawAll();
199
200         /* switch back to real renderer */
201         driver->setRenderTarget(0, true, true,
202                         irr::video::SColor(0,
203                                         skycolor.getRed(), skycolor.getGreen(), skycolor.getBlue()));
204
205         return image;
206 }
207
208 video::ITexture*  draw_hud(video::IVideoDriver* driver, const v2u32& screensize,
209                 bool show_hud, Hud& hud, Client& client, bool draw_crosshair,
210                 video::SColor skycolor, gui::IGUIEnvironment* guienv, Camera& camera )
211 {
212         static video::ITexture* image = NULL;
213         init_texture(driver, screensize, &image, "mt_drawimage_hud");
214         driver->setRenderTarget(image, true, true,
215                         irr::video::SColor(255,0,0,0));
216
217         if (show_hud)
218         {
219                 if (draw_crosshair)
220                         hud.drawCrosshair();
221                 hud.drawHotbar(client.getPlayerItem());
222                 hud.drawLuaElements(camera.getOffset());
223
224                 guienv->drawAll();
225         }
226
227         driver->setRenderTarget(0, true, true,
228                         irr::video::SColor(0,
229                                         skycolor.getRed(), skycolor.getGreen(), skycolor.getBlue()));
230
231         return image;
232 }
233
234 void draw_interlaced_3d_mode(Camera& camera, bool show_hud,
235                 Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
236                 scene::ISceneManager* smgr, const v2u32& screensize,
237                 bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
238                 video::SColor skycolor )
239 {
240         /* save current info */
241         irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition();
242         irr::core::vector3df oldTarget = camera.getCameraNode()->getTarget();
243         irr::core::matrix4 startMatrix =
244                         camera.getCameraNode()->getAbsoluteTransformation();
245         irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget()
246                         - camera.getCameraNode()->getAbsolutePosition()).setLength(1)
247                         + camera.getCameraNode()->getAbsolutePosition();
248
249         /* create left view */
250         video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix,
251                         focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
252                         draw_wield_tool, client, guienv, skycolor);
253
254         //Right eye...
255         irr::core::vector3df rightEye;
256         irr::core::matrix4 rightMove;
257         rightMove.setTranslation(
258                         irr::core::vector3df(g_settings->getFloat("3d_paralax_strength"),
259                                         0.0f, 0.0f));
260         rightEye = (startMatrix * rightMove).getTranslation();
261
262         //clear the depth buffer
263         driver->clearZBuffer();
264         camera.getCameraNode()->setPosition(rightEye);
265         camera.getCameraNode()->setTarget(focusPoint);
266         smgr->drawAll();
267
268         driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
269
270         if (show_hud)
271         {
272                 draw_selectionbox(driver, hud, hilightboxes, show_hud);
273
274                 if(draw_wield_tool)
275                         camera.drawWieldedTool(&rightMove);
276         }
277         guienv->drawAll();
278
279         for (unsigned int i = 0; i < screensize.Y; i+=2 ) {
280 #if (IRRLICHT_VERSION_MAJOR >= 1) && (IRRLICHT_VERSION_MINOR >= 8)
281                 driver->draw2DImage(left_image, irr::core::position2d<s32>(0, i),
282 #else
283                 driver->draw2DImage(left_image, irr::core::position2d<s32>(0, screensize.Y-i),
284 #endif
285                                 irr::core::rect<s32>(0, i,screensize.X, i+1), 0,
286                                 irr::video::SColor(255, 255, 255, 255),
287                                 false);
288         }
289
290         /* cleanup */
291         camera.getCameraNode()->setPosition(oldPosition);
292         camera.getCameraNode()->setTarget(oldTarget);
293 }
294
295 void draw_sidebyside_3d_mode(Camera& camera, bool show_hud,
296                 Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
297                 scene::ISceneManager* smgr, const v2u32& screensize,
298                 bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
299                 video::SColor skycolor )
300 {
301         /* save current info */
302         irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition();
303         irr::core::vector3df oldTarget = camera.getCameraNode()->getTarget();
304         irr::core::matrix4 startMatrix =
305                         camera.getCameraNode()->getAbsoluteTransformation();
306         irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget()
307                         - camera.getCameraNode()->getAbsolutePosition()).setLength(1)
308                         + camera.getCameraNode()->getAbsolutePosition();
309
310         /* create left view */
311         video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix,
312                         focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
313                         draw_wield_tool, client, guienv, skycolor);
314
315         /* create right view */
316         video::ITexture* right_image = draw_image(screensize, RIGHT, startMatrix,
317                         focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
318                         draw_wield_tool, client, guienv, skycolor);
319
320         /* create hud overlay */
321         video::ITexture* hudtexture = draw_hud(driver, screensize, show_hud, hud, client,
322                         false, skycolor, guienv, camera );
323         driver->makeColorKeyTexture(hudtexture, irr::video::SColor(255, 0, 0, 0));
324         //makeColorKeyTexture mirrors texture so we do it twice to get it right again
325         driver->makeColorKeyTexture(hudtexture, irr::video::SColor(255, 0, 0, 0));
326
327         driver->draw2DImage(left_image,
328                         irr::core::rect<s32>(0, 0, screensize.X/2, screensize.Y),
329                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, false);
330
331         driver->draw2DImage(hudtexture,
332                         irr::core::rect<s32>(0, 0, screensize.X/2, screensize.Y),
333                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, true);
334
335         driver->draw2DImage(right_image,
336                         irr::core::rect<s32>(screensize.X/2, 0, screensize.X, screensize.Y),
337                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, false);
338
339         driver->draw2DImage(hudtexture,
340                         irr::core::rect<s32>(screensize.X/2, 0, screensize.X, screensize.Y),
341                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, true);
342
343         left_image = NULL;
344         right_image = NULL;
345
346         /* cleanup */
347         camera.getCameraNode()->setPosition(oldPosition);
348         camera.getCameraNode()->setTarget(oldTarget);
349 }
350
351 void draw_top_bottom_3d_mode(Camera& camera, bool show_hud,
352                 Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
353                 scene::ISceneManager* smgr, const v2u32& screensize,
354                 bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
355                 video::SColor skycolor )
356 {
357         /* save current info */
358         irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition();
359         irr::core::vector3df oldTarget = camera.getCameraNode()->getTarget();
360         irr::core::matrix4 startMatrix =
361                         camera.getCameraNode()->getAbsoluteTransformation();
362         irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget()
363                         - camera.getCameraNode()->getAbsolutePosition()).setLength(1)
364                         + camera.getCameraNode()->getAbsolutePosition();
365
366         /* create left view */
367         video::ITexture* left_image = draw_image(screensize, LEFT, startMatrix,
368                         focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
369                         draw_wield_tool, client, guienv, skycolor);
370
371         /* create right view */
372         video::ITexture* right_image = draw_image(screensize, RIGHT, startMatrix,
373                         focusPoint, show_hud, driver, camera, smgr, hud, hilightboxes,
374                         draw_wield_tool, client, guienv, skycolor);
375
376         /* create hud overlay */
377         video::ITexture* hudtexture = draw_hud(driver, screensize, show_hud, hud, client,
378                         false, skycolor, guienv, camera );
379         driver->makeColorKeyTexture(hudtexture, irr::video::SColor(255, 0, 0, 0));
380         //makeColorKeyTexture mirrors texture so we do it twice to get it right again
381         driver->makeColorKeyTexture(hudtexture, irr::video::SColor(255, 0, 0, 0));
382
383         driver->draw2DImage(left_image,
384                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y/2),
385                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, false);
386
387         driver->draw2DImage(hudtexture,
388                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y/2),
389                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, true);
390
391         driver->draw2DImage(right_image,
392                         irr::core::rect<s32>(0, screensize.Y/2, screensize.X, screensize.Y),
393                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, false);
394
395         driver->draw2DImage(hudtexture,
396                         irr::core::rect<s32>(0, screensize.Y/2, screensize.X, screensize.Y),
397                         irr::core::rect<s32>(0, 0, screensize.X, screensize.Y), 0, 0, true);
398
399         left_image = NULL;
400         right_image = NULL;
401
402         /* cleanup */
403         camera.getCameraNode()->setPosition(oldPosition);
404         camera.getCameraNode()->setTarget(oldTarget);
405 }
406
407 void draw_plain(Camera& camera, bool show_hud, Hud& hud,
408                 std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
409                 bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv)
410 {
411         driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
412
413         draw_selectionbox(driver, hud, hilightboxes, show_hud);
414
415         if(draw_wield_tool)
416                 camera.drawWieldedTool();
417 }
418
419 void draw_scene(video::IVideoDriver* driver, scene::ISceneManager* smgr,
420                 Camera& camera, Client& client, LocalPlayer* player, Hud& hud,
421                 gui::IGUIEnvironment* guienv, std::vector<aabb3f> hilightboxes,
422                 const v2u32& screensize, video::SColor skycolor, bool show_hud)
423 {
424         //TODO check if usefull
425         u32 scenetime = 0;
426         {
427                 TimeTaker timer("smgr");
428
429                 bool draw_wield_tool = (show_hud &&
430                                 (player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE) &&
431                                 camera.getCameraMode() < CAMERA_MODE_THIRD );
432
433                 bool draw_crosshair = ((player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) &&
434                                 (camera.getCameraMode() != CAMERA_MODE_THIRD_FRONT));
435
436 #ifdef HAVE_TOUCHSCREENGUI
437                 try {
438                         draw_crosshair = !g_settings->getBool("touchtarget");
439                 }
440                 catch(SettingNotFoundException) {}
441 #endif
442
443                 std::string draw_mode = g_settings->get("3d_mode");
444
445                 smgr->drawAll();
446
447                 if (draw_mode == "anaglyph")
448                 {
449                         draw_anaglyph_3d_mode(camera, show_hud, hud, hilightboxes, driver,
450                                         smgr, draw_wield_tool, client, guienv);
451                         draw_crosshair = false;
452                 }
453                 else if (draw_mode == "interlaced")
454                 {
455                         draw_interlaced_3d_mode(camera, show_hud, hud, hilightboxes, driver,
456                                         smgr, screensize, draw_wield_tool, client, guienv, skycolor);
457                         draw_crosshair = false;
458                 }
459                 else if (draw_mode == "sidebyside")
460                 {
461                         draw_sidebyside_3d_mode(camera, show_hud, hud, hilightboxes, driver,
462                                         smgr, screensize, draw_wield_tool, client, guienv, skycolor);
463                         show_hud = false;
464                 }
465                 else if (draw_mode == "topbottom")
466                 {
467                         draw_top_bottom_3d_mode(camera, show_hud, hud, hilightboxes, driver,
468                                         smgr, screensize, draw_wield_tool, client, guienv, skycolor);
469                         show_hud = false;
470                 }
471                 else {
472                         draw_plain(camera, show_hud, hud, hilightboxes, driver,
473                                         draw_wield_tool, client, guienv);
474                 }
475
476                 /*
477                         Post effects
478                 */
479                 {
480                         client.getEnv().getClientMap().renderPostFx(camera.getCameraMode());
481                 }
482
483                 //TODO how to make those 3d too
484                 if (show_hud)
485                 {
486                         if (draw_crosshair)
487                                 hud.drawCrosshair();
488                         hud.drawHotbar(client.getPlayerItem());
489                         hud.drawLuaElements(camera.getOffset());
490                 }
491
492                 guienv->drawAll();
493
494                 scenetime = timer.stop(true);
495         }
496
497 }
498
499 /*
500         Draws a screen with a single text on it.
501         Text will be removed when the screen is drawn the next time.
502         Additionally, a progressbar can be drawn when percent is set between 0 and 100.
503 */
504 void draw_load_screen(const std::wstring &text, IrrlichtDevice* device,
505                 gui::IGUIEnvironment* guienv, float dtime, int percent, bool clouds )
506 {
507         video::IVideoDriver* driver    = device->getVideoDriver();
508         v2u32 screensize               = porting::getWindowSize();
509
510         v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight());
511         v2s32 center(screensize.X / 2, screensize.Y / 2);
512         core::rect<s32> textrect(center - textsize / 2, center + textsize / 2);
513
514         gui::IGUIStaticText *guitext = guienv->addStaticText(
515                         text.c_str(), textrect, false, false);
516         guitext->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
517
518         bool cloud_menu_background = clouds && g_settings->getBool("menu_clouds");
519         if (cloud_menu_background)
520         {
521                 g_menuclouds->step(dtime*3);
522                 g_menuclouds->render();
523                 driver->beginScene(true, true, video::SColor(255, 140, 186, 250));
524                 g_menucloudsmgr->drawAll();
525         }
526         else
527                 driver->beginScene(true, true, video::SColor(255, 0, 0, 0));
528
529         // draw progress bar
530         if ((percent >= 0) && (percent <= 100))
531         {
532                 v2s32 barsize(
533                                 // 342 is (approximately) 256/0.75 to keep bar on same size as
534                                 // before with default settings
535                                 342 * porting::getDisplayDensity() *
536                                 g_settings->getFloat("gui_scaling"),
537                                 g_fontengine->getTextHeight() * 2);
538
539                 core::rect<s32> barrect(center - barsize / 2, center + barsize / 2);
540                 driver->draw2DRectangle(video::SColor(255, 255, 255, 255),barrect, NULL); // border
541                 driver->draw2DRectangle(video::SColor(255, 64, 64, 64), core::rect<s32> (
542                                 barrect.UpperLeftCorner + 1,
543                                 barrect.LowerRightCorner-1), NULL); // black inside the bar
544                 driver->draw2DRectangle(video::SColor(255, 128, 128, 128), core::rect<s32> (
545                                 barrect.UpperLeftCorner + 1,
546                                 core::vector2d<s32>(
547                                                 barrect.LowerRightCorner.X -
548                                                 (barsize.X - 1) + percent * (barsize.X - 2) / 100,
549                                                 barrect.LowerRightCorner.Y - 1)), NULL); // the actual progress
550         }
551         guienv->drawAll();
552         driver->endScene();
553
554         guitext->remove();
555
556         //return guitext;
557 }