New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Isolate irrlicht references and use a singleton #6041
Conversation
move getSupportedVideoDrivers to Device3D Add Device3D singleton & use it in various places Rename Device3D to Rendering engine & add helper functions to various device pointers More singleton work RenderingEngine owns draw_load_screen move draw functions to RenderingEngine Reduce IrrlichtDevice exposure and guienvironment RenderingEngine: Expose get_timer_time() to remove device from guiEngine Make irrlichtdevice & scene manager less exposed
6bd4647
to
1360f3c
Compare
src/client/renderingengine.h
Outdated
void init_texture(const v2u32& screensize, | ||
video::ITexture** texture, const char* name); | ||
|
||
video::ITexture* draw_image(const v2u32 &screensize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
video::ITexture *draw_image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
video::ITexture *drawImage
src/client/renderingengine.h
Outdated
|
||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gui::IGUIEnvironment *guienv
src/client/renderingengine.h
Outdated
const video::SColor &skycolor); | ||
|
||
void init_texture(const v2u32& screensize, | ||
video::ITexture** texture, const char* name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
video::ITexture **texture, const char *name
src/client/renderingengine.h
Outdated
Camera *camera, Hud *hud, bool draw_wield_tool, Client *client, | ||
gui::IGUIEnvironment *guienv, const video::SColor &skycolor); | ||
|
||
video::ITexture* draw_hud(const v2u32 &screensize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/client/tile.cpp
Outdated
@@ -238,15 +239,15 @@ class SourceImageCache | |||
return NULL; | |||
} | |||
// Primarily fetches from cache, secondarily tries to read from filesystem | |||
video::IImage* getOrLoad(const std::string &name, IrrlichtDevice *device) | |||
video::IImage* getOrLoad(const std::string &name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/client/tile.cpp
Outdated
{ | ||
std::map<std::string, video::IImage*>::iterator n; | ||
n = m_images.find(name); | ||
if (n != m_images.end()){ | ||
n->second->grab(); // Grab for caller | ||
return n->second; | ||
} | ||
video::IVideoDriver* driver = device->getVideoDriver(); | ||
video::IVideoDriver* driver = RenderingEngine::get_video_driver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/client/tile.cpp
Outdated
@@ -435,16 +428,13 @@ class TextureSource : public IWritableTextureSource | |||
bool m_setting_anisotropic_filter; | |||
}; | |||
|
|||
IWritableTextureSource* createTextureSource(IrrlichtDevice *device) | |||
IWritableTextureSource* createTextureSource() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/client/tile.cpp
Outdated
@@ -461,7 +451,7 @@ TextureSource::TextureSource(IrrlichtDevice *device): | |||
|
|||
TextureSource::~TextureSource() | |||
{ | |||
video::IVideoDriver* driver = m_device->getVideoDriver(); | |||
video::IVideoDriver* driver = RenderingEngine::get_video_driver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/client/tile.cpp
Outdated
m_source_image_existence.set(name, true); | ||
} | ||
|
||
void TextureSource::rebuildImagesAndTextures() | ||
{ | ||
MutexAutoLock lock(m_textureinfo_cache_mutex); | ||
|
||
video::IVideoDriver* driver = m_device->getVideoDriver(); | ||
video::IVideoDriver* driver = RenderingEngine::get_video_driver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/client/tile.cpp
Outdated
@@ -1196,13 +1181,13 @@ bool TextureSource::generateImagePart(std::string part_of_name, | |||
video::IImage *& baseimg) | |||
{ | |||
const char escape = '\\'; // same as in generateImage() | |||
video::IVideoDriver* driver = m_device->getVideoDriver(); | |||
video::IVideoDriver* driver = RenderingEngine::get_video_driver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/client/tile.cpp
Outdated
@@ -1275,15 +1260,15 @@ bool TextureSource::generateImagePart(std::string part_of_name, | |||
blit_with_alpha(image, baseimg, pos_from, pos_to, dim); | |||
} else if (dim.Width * dim.Height < dim_dst.Width * dim_dst.Height) { | |||
// Upscale overlying image | |||
video::IImage* scaled_image = m_device->getVideoDriver()-> | |||
video::IImage* scaled_image = RenderingEngine::get_video_driver()-> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/particles.h
Outdated
void addNodeParticle(IGameDef* gamedef, scene::ISceneManager* smgr, | ||
LocalPlayer *player, v3s16 pos, const MapNode &n, | ||
const ContentFeatures &f); | ||
void addNodeParticle(IGameDef* gamedef, LocalPlayer *player, v3s16 pos, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/script/lua_api/l_mainmenu.cpp
Outdated
@@ -843,7 +839,7 @@ int ModApiMainMenu::l_extract_zip(lua_State *L) | |||
if (ModApiMainMenu::isMinetestPath(absolute_destination)) { | |||
fs::CreateAllDirs(absolute_destination); | |||
|
|||
io::IFileSystem* fs = engine->m_device->getFileSystem(); | |||
io::IFileSystem* fs = RenderingEngine::get_filesystem(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/shader.cpp
Outdated
@@ -332,17 +331,16 @@ class ShaderSource : public IWritableShaderSource | |||
std::vector<ShaderCallback *> m_callbacks; | |||
}; | |||
|
|||
IWritableShaderSource* createShaderSource(IrrlichtDevice *device) | |||
IWritableShaderSource* createShaderSource() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
src/shader.cpp
Outdated
} | ||
|
||
/* | ||
Generate shader given the shader name. | ||
*/ | ||
ShaderInfo generate_shader(const std::string &name, | ||
u8 material_type, u8 drawtype, | ||
IrrlichtDevice *device, std::vector<ShaderCallback *> &callbacks, | ||
u8 material_type, u8 drawtype, std::vector<ShaderCallback *> &callbacks, | ||
const std::vector<IShaderConstantSetterFactory*> &setter_factories, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<IShaderConstantSetterFactory *>
src/shader.cpp
Outdated
} | ||
|
||
bool enable_shaders = g_settings->getBool("enable_shaders"); | ||
if (!enable_shaders) | ||
return shaderinfo; | ||
|
||
video::IVideoDriver* driver = device->getVideoDriver(); | ||
sanity_check(driver); | ||
video::IVideoDriver* driver = RenderingEngine::get_video_driver(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/client/renderingengine.h
Outdated
static void setXorgClassHint(const video::SExposedVideoData &video_data, | ||
const std::string &name); | ||
bool setWindowIcon(); | ||
bool setXorgWindowIconFromPath(const std::string &icon_file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these part of the rendering engine?
IMO porting makes more sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setXorgWindowIconFromPath uses Irrlicht:
video::IVideoDriver *v_driver = m_device->getVideoDriver();
video::IImageLoader *image_loader = NULL;
then it make sense to link it with rendering engine
@sfan5 i don't know if it's really non trivial, it's a huge rework it's right, but the change itself in all engine is not difficult it just take some time :p EDIT: also note i cleanup many IrrlichtDevice references, VideoDriver, SceneManager and guiEnvironment but all it not done yet, i prefer cleanup other parts after making this PR merged to ensure the work is okay |
c08c72f
to
b801b81
Compare
b801b81
to
93d9932
Compare
Okay PR is ready for merge if CI pass. @sfan5 @SmallJoker @Zeno- please do a review |
…layDensity, getDisplaySize to RenderingEngine Fix XORG_USED macro -> RenderingEngine + create_engine_device from RenderingEngine constructor directly
5d0386d
to
4fa3b1c
Compare
src/client/renderingengine.h
Outdated
return s_singleton->m_device->getGUIEnvironment(); | ||
} | ||
|
||
static void draw_load_screen(const std::wstring &text, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why inline draw_scene
but not here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because function is not inlined itself, it's split between declaration & definition
src/client/renderingengine.h
Outdated
static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers(); | ||
|
||
private: | ||
enum paralax_sign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parallax_sign
irr::core::vector3df eye_pos; | ||
irr::core::matrix4 movement; | ||
movement.setTranslation(irr::core::vector3df( | ||
(int)psign * g_settings->getFloat("3d_paralax_strength"), 0.0f, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/paralax/parallax over the whole file 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not a new setting but an old setting, this is not for this PR, please do a fix PR after merging this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the enum as it's a private enum, but i don't modify the setting name which is out of this PR scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll do that
src/client/renderingengine.h
Outdated
void init_texture(const v2u32 &screensize, video::ITexture **texture, | ||
const char *name); | ||
|
||
video::ITexture *draw_image(const v2u32 &screensize, paralax_sign psign, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parallax_sign psign
for spelling fix
src/client/renderingengine.cpp
Outdated
irr::video::ECF_A8R8G8B8); | ||
} | ||
|
||
video::ITexture *RenderingEngine::draw_image(const v2u32 &screensize, paralax_sign psign, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parallax_sign psign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, works.
* Add Device3D class which will contain IrrlichtDevice interface move getSupportedVideoDrivers to Device3D Add Device3D singleton & use it in various places Rename Device3D to Rendering engine & add helper functions to various device pointers More singleton work RenderingEngine owns draw_load_screen move draw functions to RenderingEngine Reduce IrrlichtDevice exposure and guienvironment RenderingEngine: Expose get_timer_time() to remove device from guiEngine Make irrlichtdevice & scene manager less exposed * Code style fixes * Move porting::getVideoDriverName, getVideoDriverFriendlyName, getDisplayDensity, getDisplaySize to RenderingEngine Fix XORG_USED macro -> RenderingEngine + create_engine_device from RenderingEngine constructor directly * enum paralax => enum parallax
* Add Device3D class which will contain IrrlichtDevice interface move getSupportedVideoDrivers to Device3D Add Device3D singleton & use it in various places Rename Device3D to Rendering engine & add helper functions to various device pointers More singleton work RenderingEngine owns draw_load_screen move draw functions to RenderingEngine Reduce IrrlichtDevice exposure and guienvironment RenderingEngine: Expose get_timer_time() to remove device from guiEngine Make irrlichtdevice & scene manager less exposed * Code style fixes * Move porting::getVideoDriverName, getVideoDriverFriendlyName, getDisplayDensity, getDisplaySize to RenderingEngine Fix XORG_USED macro -> RenderingEngine + create_engine_device from RenderingEngine constructor directly * enum paralax => enum parallax
Isolate irrlichtdevice to a RenderingEngine class, with various static function related to the device singleton
This permits to remove many function cost passing irrlicht or scene_mgr or videodriver and isolate minetest code from irrlicht interfaces.
This is a first step needed to minetest to properly have a rendering interface permitting to use another rendering engine, if needed.