3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 inline u32 scaledown(u32 coef, u32 size)
26 return (size + coef - 1) / coef;
29 RenderingCorePlain::RenderingCorePlain(
30 IrrlichtDevice *_device, Client *_client, Hud *_hud)
31 : RenderingCore(_device, _client, _hud)
33 scale = g_settings->getU16("undersampling");
36 void RenderingCorePlain::initTextures()
40 v2u32 size{scaledown(scale, screensize.X), scaledown(scale, screensize.Y)};
41 lowres = driver->addRenderTargetTexture(
42 size, "render_lowres", video::ECF_A8R8G8B8);
45 void RenderingCorePlain::clearTextures()
49 driver->removeTexture(lowres);
52 void RenderingCorePlain::beforeDraw()
56 driver->setRenderTarget(lowres, true, true, skycolor);
59 void RenderingCorePlain::upscale()
63 driver->setRenderTarget(0, true, true);
64 v2u32 size{scaledown(scale, screensize.X), scaledown(scale, screensize.Y)};
65 v2u32 dest_size{scale * size.X, scale * size.Y};
66 driver->draw2DImage(lowres, core::rect<s32>(0, 0, dest_size.X, dest_size.Y),
67 core::rect<s32>(0, 0, size.X, size.Y));
70 void RenderingCorePlain::drawAll()