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.
21 #include "sidebyside.h"
22 #include <ICameraSceneNode.h>
23 #include "client/hud.h"
25 RenderingCoreSideBySide::RenderingCoreSideBySide(
26 IrrlichtDevice *_device, Client *_client, Hud *_hud, bool _horizontal)
27 : RenderingCoreStereo(_device, _client, _hud), horizontal(_horizontal)
31 void RenderingCoreSideBySide::initTextures()
34 image_size = {screensize.X, screensize.Y / 2};
35 rpos = v2s32(0, screensize.Y / 2);
37 image_size = {screensize.X / 2, screensize.Y};
38 rpos = v2s32(screensize.X / 2, 0);
40 virtual_size = image_size;
41 left = driver->addRenderTargetTexture(
42 image_size, "3d_render_left", video::ECF_A8R8G8B8);
43 right = driver->addRenderTargetTexture(
44 image_size, "3d_render_right", video::ECF_A8R8G8B8);
47 void RenderingCoreSideBySide::clearTextures()
49 driver->removeTexture(left);
50 driver->removeTexture(right);
53 void RenderingCoreSideBySide::drawAll()
55 driver->OnResize(image_size); // HACK to make GUI smaller
57 driver->OnResize(screensize);
58 driver->draw2DImage(left, {});
59 driver->draw2DImage(right, rpos);
62 void RenderingCoreSideBySide::useEye(bool _right)
64 driver->setRenderTarget(_right ? right : left, true, true, skycolor);
65 RenderingCoreStereo::useEye(_right);
68 void RenderingCoreSideBySide::resetEye()
72 driver->setRenderTarget(nullptr, false, false, skycolor);
73 RenderingCoreStereo::resetEye();