116 changes: 116 additions & 0 deletions src/client/render/interlaced.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "interlaced.h"
#include "client.h"
#include "shader.h"
#include "client/tile.h"

RenderingCoreInterlaced::RenderingCoreInterlaced(
IrrlichtDevice *_device, Client *_client, Hud *_hud)
: RenderingCoreStereo(_device, _client, _hud)
{
initMaterial();
}

void RenderingCoreInterlaced::initMaterial()
{
IShaderSource *s = client->getShaderSource();
mat.UseMipMaps = false;
mat.ZBuffer = false;
mat.ZWriteEnable = false;
u32 shader = s->getShader("3d_interlaced_merge", TILE_MATERIAL_BASIC, 0);
mat.MaterialType = s->getShaderInfo(shader).material;
for (int k = 0; k < 3; ++k) {
mat.TextureLayer[k].AnisotropicFilter = false;
mat.TextureLayer[k].BilinearFilter = false;
mat.TextureLayer[k].TrilinearFilter = false;
mat.TextureLayer[k].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
mat.TextureLayer[k].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
}
}

void RenderingCoreInterlaced::initTextures()
{
v2u32 image_size{screensize.X, screensize.Y / 2};
left = driver->addRenderTargetTexture(
image_size, "3d_render_left", video::ECF_A8R8G8B8);
right = driver->addRenderTargetTexture(
image_size, "3d_render_right", video::ECF_A8R8G8B8);
mask = driver->addTexture(screensize, "3d_render_mask", video::ECF_A8R8G8B8);
initMask();
mat.TextureLayer[0].Texture = left;
mat.TextureLayer[1].Texture = right;
mat.TextureLayer[2].Texture = mask;
}

void RenderingCoreInterlaced::clearTextures()
{
driver->removeTexture(left);
driver->removeTexture(right);
driver->removeTexture(mask);
}

void RenderingCoreInterlaced::initMask()
{
u8 *data = reinterpret_cast<u8 *>(mask->lock());
for (u32 j = 0; j < screensize.Y; j++) {
u8 val = j % 2 ? 0xff : 0x00;
memset(data, val, 4 * screensize.X);
data += 4 * screensize.X;
}
mask->unlock();
}

void RenderingCoreInterlaced::drawAll()
{
renderBothImages();
merge();
drawHUD();
}

void RenderingCoreInterlaced::merge()
{
static const video::S3DVertex vertices[4] = {
video::S3DVertex(1.0, -1.0, 0.0, 0.0, 0.0, -1.0,
video::SColor(255, 0, 255, 255), 1.0, 0.0),
video::S3DVertex(-1.0, -1.0, 0.0, 0.0, 0.0, -1.0,
video::SColor(255, 255, 0, 255), 0.0, 0.0),
video::S3DVertex(-1.0, 1.0, 0.0, 0.0, 0.0, -1.0,
video::SColor(255, 255, 255, 0), 0.0, 1.0),
video::S3DVertex(1.0, 1.0, 0.0, 0.0, 0.0, -1.0,
video::SColor(255, 255, 255, 255), 1.0, 1.0),
};
static const u16 indices[6] = {0, 1, 2, 2, 3, 0};
driver->setMaterial(mat);
driver->drawVertexPrimitiveList(&vertices, 4, &indices, 2);
}

void RenderingCoreInterlaced::useEye(bool _right)
{
driver->setRenderTarget(_right ? right : left, true, true, skycolor);
RenderingCoreStereo::useEye(_right);
}

void RenderingCoreInterlaced::resetEye()
{
driver->setRenderTarget(nullptr, false, false, skycolor);
RenderingCoreStereo::resetEye();
}
43 changes: 43 additions & 0 deletions src/client/render/interlaced.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#pragma once
#include "stereo.h"

class RenderingCoreInterlaced : public RenderingCoreStereo
{
protected:
video::ITexture *left = nullptr;
video::ITexture *right = nullptr;
video::ITexture *mask = nullptr;
video::SMaterial mat;

void initMaterial();
void initTextures() override;
void clearTextures() override;
void initMask();
void useEye(bool right) override;
void resetEye() override;
void merge();

public:
RenderingCoreInterlaced(IrrlichtDevice *_device, Client *_client, Hud *_hud);
void drawAll() override;
};
55 changes: 55 additions & 0 deletions src/client/render/pageflip.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "pageflip.h"

void RenderingCorePageflip::initTextures()
{
hud = driver->addRenderTargetTexture(
screensize, "3d_render_hud", video::ECF_A8R8G8B8);
}

void RenderingCorePageflip::clearTextures()
{
driver->removeTexture(hud);
}

void RenderingCorePageflip::drawAll()
{
driver->setRenderTarget(hud, true, true, video::SColor(0, 0, 0, 0));
drawHUD();
driver->setRenderTarget(nullptr, false, false, skycolor);
renderBothImages();
}

void RenderingCorePageflip::useEye(bool _right)
{
driver->setRenderTarget(_right ? video::ERT_STEREO_RIGHT_BUFFER
: video::ERT_STEREO_LEFT_BUFFER,
true, true, skycolor);
RenderingCoreStereo::useEye(_right);
}

void RenderingCorePageflip::resetEye()
{
driver->draw2DImage(hud, v2s32(0, 0));
driver->setRenderTarget(video::ERT_FRAME_BUFFER, false, false, skycolor);
RenderingCoreStereo::resetEye();
}
37 changes: 37 additions & 0 deletions src/client/render/pageflip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#pragma once
#include "stereo.h"

class RenderingCorePageflip : public RenderingCoreStereo
{
protected:
video::ITexture *hud = nullptr;

void initTextures() override;
void clearTextures() override;
void useEye(bool right) override;
void resetEye() override;

public:
using RenderingCoreStereo::RenderingCoreStereo;
void drawAll() override;
};
76 changes: 76 additions & 0 deletions src/client/render/plain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "plain.h"
#include "settings.h"

inline u32 scaledown(u32 coef, u32 size)
{
return (size + coef - 1) / coef;
}

RenderingCorePlain::RenderingCorePlain(
IrrlichtDevice *_device, Client *_client, Hud *_hud)
: RenderingCore(_device, _client, _hud)
{
scale = g_settings->getU16("undersampling");
}

void RenderingCorePlain::initTextures()
{
if (!scale)
return;
v2u32 size{scaledown(scale, screensize.X), scaledown(scale, screensize.Y)};
lowres = driver->addRenderTargetTexture(
size, "render_lowres", video::ECF_A8R8G8B8);
}

void RenderingCorePlain::clearTextures()
{
if (!scale)
return;
driver->removeTexture(lowres);
}

void RenderingCorePlain::beforeDraw()
{
if (!scale)
return;
driver->setRenderTarget(lowres, true, true, skycolor);
}

void RenderingCorePlain::upscale()
{
if (!scale)
return;
driver->setRenderTarget(0, true, true);
v2u32 size{scaledown(scale, screensize.X), scaledown(scale, screensize.Y)};
v2u32 dest_size{scale * size.X, scale * size.Y};
driver->draw2DImage(lowres, core::rect<s32>(0, 0, dest_size.X, dest_size.Y),
core::rect<s32>(0, 0, size.X, size.Y));
}

void RenderingCorePlain::drawAll()
{
draw3D();
drawPostFx();
upscale();
drawHUD();
}
38 changes: 38 additions & 0 deletions src/client/render/plain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#pragma once
#include "core.h"

class RenderingCorePlain : public RenderingCore
{
protected:
int scale = 0;
video::ITexture *lowres = nullptr;

void initTextures() override;
void clearTextures() override;
void beforeDraw() override;
void upscale();

public:
RenderingCorePlain(IrrlichtDevice *_device, Client *_client, Hud *_hud);
void drawAll() override;
};
74 changes: 74 additions & 0 deletions src/client/render/sidebyside.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "sidebyside.h"
#include <ICameraSceneNode.h>
#include "hud.h"

RenderingCoreSideBySide::RenderingCoreSideBySide(
IrrlichtDevice *_device, Client *_client, Hud *_hud, bool _horizontal)
: RenderingCoreStereo(_device, _client, _hud), horizontal(_horizontal)
{
}

void RenderingCoreSideBySide::initTextures()
{
if (horizontal) {
image_size = {screensize.X, screensize.Y / 2};
rpos = v2s32(0, screensize.Y / 2);
} else {
image_size = {screensize.X / 2, screensize.Y};
rpos = v2s32(screensize.X / 2, 0);
}
virtual_size = image_size;
left = driver->addRenderTargetTexture(
image_size, "3d_render_left", video::ECF_A8R8G8B8);
right = driver->addRenderTargetTexture(
image_size, "3d_render_right", video::ECF_A8R8G8B8);
}

void RenderingCoreSideBySide::clearTextures()
{
driver->removeTexture(left);
driver->removeTexture(right);
}

void RenderingCoreSideBySide::drawAll()
{
driver->OnResize(image_size); // HACK to make GUI smaller
renderBothImages();
driver->OnResize(screensize);
driver->draw2DImage(left, {});
driver->draw2DImage(right, rpos);
}

void RenderingCoreSideBySide::useEye(bool _right)
{
driver->setRenderTarget(_right ? right : left, true, true, skycolor);
RenderingCoreStereo::useEye(_right);
}

void RenderingCoreSideBySide::resetEye()
{
hud->resizeHotbar();
drawHUD();
driver->setRenderTarget(nullptr, false, false, skycolor);
RenderingCoreStereo::resetEye();
}
42 changes: 42 additions & 0 deletions src/client/render/sidebyside.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#pragma once
#include "stereo.h"

class RenderingCoreSideBySide : public RenderingCoreStereo
{
protected:
video::ITexture *left = nullptr;
video::ITexture *right = nullptr;
bool horizontal = false;
core::dimension2du image_size;
v2s32 rpos;

void initTextures() override;
void clearTextures() override;
void useEye(bool right) override;
void resetEye() override;

public:
RenderingCoreSideBySide(IrrlichtDevice *_device, Client *_client, Hud *_hud,
bool _horizontal = false);
void drawAll() override;
};
60 changes: 60 additions & 0 deletions src/client/render/stereo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "stereo.h"
#include "camera.h"
#include "constants.h"
#include "settings.h"

RenderingCoreStereo::RenderingCoreStereo(
IrrlichtDevice *_device, Client *_client, Hud *_hud)
: RenderingCore(_device, _client, _hud)
{
eye_offset = BS * g_settings->getFloat("3d_paralax_strength");
}

void RenderingCoreStereo::beforeDraw()
{
cam = camera->getCameraNode();
base_transform = cam->getRelativeTransformation();
}

void RenderingCoreStereo::useEye(bool right)
{
core::matrix4 move;
move.setTranslation(
core::vector3df(right ? eye_offset : -eye_offset, 0.0f, 0.0f));
cam->setPosition((base_transform * move).getTranslation());
}

void RenderingCoreStereo::resetEye()
{
cam->setPosition(base_transform.getTranslation());
}

void RenderingCoreStereo::renderBothImages()
{
useEye(false);
draw3D();
resetEye();
useEye(true);
draw3D();
resetEye();
}
38 changes: 38 additions & 0 deletions src/client/render/stereo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2017 numzero, Lobachesky Vitaly <numzer0@yandex.ru>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#pragma once
#include "core.h"

class RenderingCoreStereo : public RenderingCore
{
protected:
scene::ICameraSceneNode *cam;
core::matrix4 base_transform;
float eye_offset;

void beforeDraw() override;
virtual void useEye(bool right);
virtual void resetEye();
void renderBothImages();

public:
RenderingCoreStereo(IrrlichtDevice *_device, Client *_client, Hud *_hud);
};
579 changes: 21 additions & 558 deletions src/client/renderingengine.cpp

Large diffs are not rendered by default.

75 changes: 21 additions & 54 deletions src/client/renderingengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once

#include <vector>
#include <memory>
#include <string>
#include "irrlichttypes_extrabloated.h"
#include "debug.h"
Expand All @@ -32,6 +33,8 @@ class LocalPlayer;
class Hud;
class Minimap;

class RenderingCore;

class RenderingEngine
{
public:
Expand All @@ -41,7 +44,7 @@ class RenderingEngine
v2u32 getWindowSize() const;
void setResizable(bool resize);

video::IVideoDriver *getVideoDriver();
video::IVideoDriver *getVideoDriver() { return driver; }

static const char *getVideoDriverName(irr::video::E_DRIVER_TYPE type);
static const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type);
Expand Down Expand Up @@ -107,15 +110,20 @@ class RenderingEngine
text, guienv, tsrc, dtime, percent, clouds);
}

inline static void draw_scene(Camera *camera, Client *client, LocalPlayer *player,
Hud *hud, Minimap *mapper, gui::IGUIEnvironment *guienv,
const v2u32 &screensize, const video::SColor &skycolor,
bool show_hud, bool show_minimap)
inline static void draw_scene(video::SColor skycolor, bool show_hud,
bool show_minimap, bool draw_wield_tool, bool draw_crosshair)
{
s_singleton->_draw_scene(skycolor, show_hud, show_minimap,
draw_wield_tool, draw_crosshair);
}

inline static void initialize(Client *client, Hud *hud)
{
s_singleton->_draw_scene(camera, client, player, hud, mapper, guienv,
screensize, skycolor, show_hud, show_minimap);
s_singleton->_initialize(client, hud);
}

inline static void finalize() { s_singleton->_finalize(); }

static bool run()
{
sanity_check(s_singleton && s_singleton->m_device);
Expand All @@ -126,60 +134,19 @@ class RenderingEngine
static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();

private:
enum parallax_sign
{
LEFT = -1,
RIGHT = 1,
EYECOUNT = 2
};

void _draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv,
ITextureSource *tsrc, float dtime = 0, int percent = 0,
bool clouds = true);

void _draw_scene(Camera *camera, Client *client, LocalPlayer *player, Hud *hud,
Minimap *mapper, gui::IGUIEnvironment *guienv,
const v2u32 &screensize, const video::SColor &skycolor,
bool show_hud, bool show_minimap);

void draw_anaglyph_3d_mode(Camera *camera, bool show_hud, Hud *hud,
bool draw_wield_tool, Client *client,
gui::IGUIEnvironment *guienv);

void draw_interlaced_3d_mode(Camera *camera, bool show_hud, Hud *hud,
const v2u32 &screensize, bool draw_wield_tool, Client *client,
gui::IGUIEnvironment *guienv, const video::SColor &skycolor);

void draw_sidebyside_3d_mode(Camera *camera, bool show_hud, Hud *hud,
const v2u32 &screensize, bool draw_wield_tool, Client *client,
gui::IGUIEnvironment *guienv, const video::SColor &skycolor);

void draw_top_bottom_3d_mode(Camera *camera, bool show_hud, Hud *hud,
const v2u32 &screensize, bool draw_wield_tool, Client *client,
gui::IGUIEnvironment *guienv, const video::SColor &skycolor);

void draw_pageflip_3d_mode(Camera *camera, bool show_hud, Hud *hud,
const v2u32 &screensize, bool draw_wield_tool, Client *client,
gui::IGUIEnvironment *guienv, const video::SColor &skycolor);

void draw_plain(Camera *camera, bool show_hud, Hud *hud, const v2u32 &screensize,
bool draw_wield_tool, Client *client,
gui::IGUIEnvironment *guienv, const video::SColor &skycolor);

void init_texture(const v2u32 &screensize, video::ITexture **texture,
const char *name);
void _draw_scene(video::SColor skycolor, bool show_hud, bool show_minimap,
bool draw_wield_tool, bool draw_crosshair);

video::ITexture *draw_image(const v2u32 &screensize, parallax_sign psign,
const irr::core::matrix4 &startMatrix,
const irr::core::vector3df &focusPoint, bool show_hud,
Camera *camera, Hud *hud, bool draw_wield_tool, Client *client,
gui::IGUIEnvironment *guienv, const video::SColor &skycolor);
void _initialize(Client *client, Hud *hud);

video::ITexture *draw_hud(const v2u32 &screensize, bool show_hud, Hud *hud,
Client *client, bool draw_crosshair,
const video::SColor &skycolor, gui::IGUIEnvironment *guienv,
Camera *camera);
void _finalize();

std::unique_ptr<RenderingCore> core;
irr::IrrlichtDevice *m_device = nullptr;
irr::video::IVideoDriver *driver;
static RenderingEngine *s_singleton;
};
22 changes: 18 additions & 4 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,8 @@ bool Game::startup(bool *kill,
if (!createClient(playername, password, address, port))
return false;

RenderingEngine::initialize(client, hud);

return true;
}

Expand Down Expand Up @@ -1745,6 +1747,7 @@ void Game::run()

void Game::shutdown()
{
RenderingEngine::finalize();
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8
if (g_settings->get("3d_mode") == "pageflip") {
driver->setRenderTarget(irr::video::ERT_STEREO_BOTH_BUFFERS);
Expand Down Expand Up @@ -4339,9 +4342,20 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
TimeTaker tt_draw("mainloop: draw");
driver->beginScene(true, true, skycolor);

RenderingEngine::draw_scene(camera, client, player, hud, mapper,
guienv, screensize, skycolor, flags.show_hud,
flags.show_minimap);
bool draw_wield_tool = (flags.show_hud &&
(player->hud_flags & HUD_FLAG_WIELDITEM_VISIBLE) &&
(camera->getCameraMode() == CAMERA_MODE_FIRST));
bool draw_crosshair = (
(player->hud_flags & HUD_FLAG_CROSSHAIR_VISIBLE) &&
(camera->getCameraMode() != CAMERA_MODE_THIRD_FRONT));
#ifdef HAVE_TOUCHSCREENGUI
try {
draw_crosshair = !g_settings->getBool("touchtarget");
} catch (SettingNotFoundException) {
}
#endif
RenderingEngine::draw_scene(skycolor, flags.show_hud, flags.show_minimap,
draw_wield_tool, draw_crosshair);

/*
Profiler graph
Expand Down Expand Up @@ -4402,7 +4416,7 @@ inline static const char *yawToDirectionString(int yaw)

void Game::updateGui(const RunStats &stats, f32 dtime, const CameraOrientation &cam)
{
v2u32 screensize = driver->getScreenSize();
v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
LocalPlayer *player = client->getEnv().getLocalPlayer();
v3f player_position = player->getPosition();

Expand Down
2 changes: 1 addition & 1 deletion src/settings_translation_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ fake_function() {
gettext("Fall bobbing factor");
gettext("Multiplier for fall bobbing.\nFor example: 0 for no view bobbing; 1.0 for normal; 2.0 for double.");
gettext("3D mode");
gettext("3D support.\nCurrently supported:\n- none: no 3d output.\n- anaglyph: cyan/magenta color 3d.\n- interlaced: odd/even line based polarisation screen support.\n- topbottom: split screen top/bottom.\n- sidebyside: split screen side by side.\n- pageflip: quadbuffer based 3d.");
gettext("3D support.\nCurrently supported:\n- none: no 3d output.\n- anaglyph: cyan/magenta color 3d.\n- interlaced: odd/even line based polarisation screen support.\n- topbottom: split screen top/bottom.\n- sidebyside: split screen side by side.\n- pageflip: quadbuffer based 3d.\nNote that the interlaced mode requires shaders to be enabled.");
gettext("Console height");
gettext("In-game chat console height, between 0.1 (10%) and 1.0 (100%).");
gettext("Console color");
Expand Down