renderingengine.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2.1 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. */
  17. #pragma once
  18. #include <vector>
  19. #include <memory>
  20. #include <string>
  21. #include "irrlichttypes_extrabloated.h"
  22. #include "debug.h"
  23. #include "client/render/core.h"
  24. // include the shadow mapper classes too
  25. #include "client/shadows/dynamicshadowsrender.h"
  26. struct VideoDriverInfo {
  27. std::string name;
  28. std::string friendly_name;
  29. };
  30. class ITextureSource;
  31. class Camera;
  32. class Client;
  33. class LocalPlayer;
  34. class Hud;
  35. class Minimap;
  36. class RenderingCore;
  37. class RenderingEngine
  38. {
  39. public:
  40. RenderingEngine(IEventReceiver *eventReceiver);
  41. ~RenderingEngine();
  42. void setResizable(bool resize);
  43. video::IVideoDriver *getVideoDriver() { return driver; }
  44. static const VideoDriverInfo &getVideoDriverInfo(irr::video::E_DRIVER_TYPE type);
  45. static float getDisplayDensity();
  46. bool setupTopLevelWindow(const std::string &name);
  47. void setupTopLevelXorgWindow(const std::string &name);
  48. bool setWindowIcon();
  49. bool setXorgWindowIconFromPath(const std::string &icon_file);
  50. static bool print_video_modes();
  51. void cleanupMeshCache();
  52. void removeMesh(const scene::IMesh* mesh);
  53. static v2u32 getWindowSize()
  54. {
  55. sanity_check(s_singleton);
  56. return s_singleton->_getWindowSize();
  57. }
  58. io::IFileSystem *get_filesystem()
  59. {
  60. return m_device->getFileSystem();
  61. }
  62. static video::IVideoDriver *get_video_driver()
  63. {
  64. sanity_check(s_singleton && s_singleton->m_device);
  65. return s_singleton->m_device->getVideoDriver();
  66. }
  67. scene::ISceneManager *get_scene_manager()
  68. {
  69. return m_device->getSceneManager();
  70. }
  71. static irr::IrrlichtDevice *get_raw_device()
  72. {
  73. sanity_check(s_singleton && s_singleton->m_device);
  74. return s_singleton->m_device;
  75. }
  76. u32 get_timer_time()
  77. {
  78. return m_device->getTimer()->getTime();
  79. }
  80. gui::IGUIEnvironment *get_gui_env()
  81. {
  82. return m_device->getGUIEnvironment();
  83. }
  84. void draw_load_screen(const std::wstring &text,
  85. gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
  86. float dtime = 0, int percent = 0, bool clouds = true);
  87. void draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds);
  88. void draw_scene(video::SColor skycolor, bool show_hud,
  89. bool show_minimap, bool draw_wield_tool, bool draw_crosshair);
  90. void initialize(Client *client, Hud *hud);
  91. void finalize();
  92. bool run()
  93. {
  94. return m_device->run();
  95. }
  96. // FIXME: this is still global when it shouldn't be
  97. static ShadowRenderer *get_shadow_renderer()
  98. {
  99. if (s_singleton && s_singleton->core)
  100. return s_singleton->core->get_shadow_renderer();
  101. return nullptr;
  102. }
  103. static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();
  104. private:
  105. v2u32 _getWindowSize() const;
  106. std::unique_ptr<RenderingCore> core;
  107. irr::IrrlichtDevice *m_device = nullptr;
  108. irr::video::IVideoDriver *driver;
  109. static RenderingEngine *s_singleton;
  110. };