]> git.lizzy.rs Git - minetest.git/blob - src/client/render/factory.cpp
Add keybind to swap items between hands
[minetest.git] / src / client / render / factory.cpp
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2017 numzero, Lobachevskiy Vitaliy <numzer0@yandex.ru>
5
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.
10
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.
15
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.
19 */
20
21 #include "factory.h"
22 #include "log.h"
23 #include "plain.h"
24 #include "anaglyph.h"
25 #include "interlaced.h"
26 #include "sidebyside.h"
27 #include "secondstage.h"
28 #include "client/shadows/dynamicshadowsrender.h"
29
30 struct CreatePipelineResult
31 {
32         v2f virtual_size_scale;
33         ShadowRenderer *shadow_renderer { nullptr };
34         RenderPipeline *pipeline { nullptr };
35 };
36
37 void createPipeline(const std::string &stereo_mode, IrrlichtDevice *device, Client *client, Hud *hud, CreatePipelineResult &result);
38
39 RenderingCore *createRenderingCore(const std::string &stereo_mode, IrrlichtDevice *device,
40                 Client *client, Hud *hud)
41 {
42         CreatePipelineResult created_pipeline;
43         createPipeline(stereo_mode, device, client, hud, created_pipeline);
44         return new RenderingCore(device, client, hud, 
45                         created_pipeline.shadow_renderer, created_pipeline.pipeline, created_pipeline.virtual_size_scale);
46 }
47
48 void createPipeline(const std::string &stereo_mode, IrrlichtDevice *device, Client *client, Hud *hud, CreatePipelineResult &result)
49 {
50         result.shadow_renderer = createShadowRenderer(device, client);
51         result.virtual_size_scale = v2f(1.0f);
52         result.pipeline = new RenderPipeline();
53
54         if (result.shadow_renderer)
55                 result.pipeline->addStep<RenderShadowMapStep>();
56
57         if (stereo_mode == "none") {
58                 populatePlainPipeline(result.pipeline, client);
59                 return;
60         }
61         if (stereo_mode == "anaglyph") {
62                 populateAnaglyphPipeline(result.pipeline, client);
63                 return;
64         }
65         if (stereo_mode == "interlaced") {
66                 populateInterlacedPipeline(result.pipeline, client);
67                 return;
68         }
69         if (stereo_mode == "sidebyside") {
70                 populateSideBySidePipeline(result.pipeline, client, false, false, result.virtual_size_scale);
71                 return;
72         }
73         if (stereo_mode == "topbottom") {
74                 populateSideBySidePipeline(result.pipeline, client, true, false, result.virtual_size_scale);
75                 return;
76         }
77         if (stereo_mode == "crossview") {
78                 populateSideBySidePipeline(result.pipeline, client, false, true, result.virtual_size_scale);
79                 return;
80         }
81
82         // fallback to plain renderer
83         errorstream << "Invalid rendering mode: " << stereo_mode << std::endl;
84         populatePlainPipeline(result.pipeline, client);
85 }