]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client/renderingengine.h
Cap damage overlay duration to 1 second (#11871)
[dragonfireclient.git] / src / client / renderingengine.h
index 40fbaa87dc97de5860886c277003a4c82a1734d9..6f104bba98e2ee09eb0e8963f0a39082a712752e 100644 (file)
@@ -21,9 +21,18 @@ 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"
+#include "client/render/core.h"
+// include the shadow mapper classes too
+#include "client/shadows/dynamicshadowsrender.h"
+
+struct VideoDriverInfo {
+       std::string name;
+       std::string friendly_name;
+};
 
 class ITextureSource;
 class Camera;
@@ -32,52 +41,51 @@ class LocalPlayer;
 class Hud;
 class Minimap;
 
+class RenderingCore;
+
 class RenderingEngine
 {
 public:
        RenderingEngine(IEventReceiver *eventReceiver);
        ~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);
+       static const VideoDriverInfo &getVideoDriverInfo(irr::video::E_DRIVER_TYPE type);
        static float getDisplayDensity();
        static v2u32 getDisplaySize();
 
-       static void setXorgClassHint(const video::SExposedVideoData &video_data,
-                       const std::string &name);
+       bool setupTopLevelWindow(const std::string &name);
+       void setupTopLevelXorgWindow(const std::string &name);
        bool setWindowIcon();
        bool setXorgWindowIconFromPath(const std::string &icon_file);
        static bool print_video_modes();
+       void cleanupMeshCache();
 
-       static RenderingEngine *get_instance() { return s_singleton; }
+       void removeMesh(const scene::IMesh* mesh);
 
-       static io::IFileSystem *get_filesystem()
+       static v2u32 getWindowSize()
        {
-               sanity_check(s_singleton && s_singleton->m_device);
-               return s_singleton->m_device->getFileSystem();
+               sanity_check(s_singleton);
+               return s_singleton->_getWindowSize();
        }
 
-       static video::IVideoDriver *get_video_driver()
+       io::IFileSystem *get_filesystem()
        {
-               sanity_check(s_singleton && s_singleton->m_device);
-               return s_singleton->m_device->getVideoDriver();
+               return m_device->getFileSystem();
        }
 
-       static scene::IMeshCache *get_mesh_cache()
+       static video::IVideoDriver *get_video_driver()
        {
                sanity_check(s_singleton && s_singleton->m_device);
-               return s_singleton->m_device->getSceneManager()->getMeshCache();
+               return s_singleton->m_device->getVideoDriver();
        }
 
-       static scene::ISceneManager *get_scene_manager()
+       scene::ISceneManager *get_scene_manager()
        {
-               sanity_check(s_singleton && s_singleton->m_device);
-               return s_singleton->m_device->getSceneManager();
+               return m_device->getSceneManager();
        }
 
        static irr::IrrlichtDevice *get_raw_device()
@@ -86,100 +94,46 @@ class RenderingEngine
                return s_singleton->m_device;
        }
 
-       static u32 get_timer_time()
+       u32 get_timer_time()
        {
-               sanity_check(s_singleton && s_singleton->m_device &&
-                               s_singleton->m_device->getTimer());
-               return s_singleton->m_device->getTimer()->getTime();
+               return m_device->getTimer()->getTime();
        }
 
-       static gui::IGUIEnvironment *get_gui_env()
+       gui::IGUIEnvironment *get_gui_env()
        {
-               sanity_check(s_singleton && s_singleton->m_device);
-               return s_singleton->m_device->getGUIEnvironment();
+               return m_device->getGUIEnvironment();
        }
 
-       inline static void draw_load_screen(const std::wstring &text,
+       void draw_load_screen(const std::wstring &text,
                        gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
-                       float dtime = 0, int percent = 0, bool clouds = true)
-       {
-               s_singleton->_draw_load_screen(
-                               text, guienv, tsrc, dtime, percent, clouds);
-       }
+                       float dtime = 0, int percent = 0, bool clouds = true);
+
+       void draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds);
+       void draw_scene(video::SColor skycolor, bool show_hud,
+                       bool show_minimap, bool draw_wield_tool, bool draw_crosshair);
 
-       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)
+       void initialize(Client *client, Hud *hud);
+       void finalize();
+
+       bool run()
        {
-               s_singleton->_draw_scene(camera, client, player, hud, mapper, guienv,
-                               screensize, skycolor, show_hud, show_minimap);
+               return m_device->run();
        }
 
-       static bool run()
+       // FIXME: this is still global when it shouldn't be
+       static ShadowRenderer *get_shadow_renderer()
        {
-               sanity_check(s_singleton && s_singleton->m_device);
-               return s_singleton->m_device->run();
+               if (s_singleton && s_singleton->core)
+                       return s_singleton->core->get_shadow_renderer();
+               return nullptr;
        }
-
-       static std::vector<core::vector3d<u32>> getSupportedVideoModes();
        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);
-
-       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);
-
-       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);
+       v2u32 _getWindowSize() const;
 
+       std::unique_ptr<RenderingCore> core;
        irr::IrrlichtDevice *m_device = nullptr;
+       irr::video::IVideoDriver *driver;
        static RenderingEngine *s_singleton;
 };