Isolate irrlicht references and use a singleton (#6041)

* 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
This commit is contained in:
Loïc Blot
2017-06-26 20:11:17 +02:00
committed by GitHub
parent a8650e785d
commit b3a36f7378
50 changed files with 1568 additions and 1567 deletions

View File

@@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IGUIFont.h>
#include <IGUITabControl.h>
#include <IGUIComboBox.h>
#include "client/renderingengine.h"
#include "log.h"
#include "client/tile.h" // ITextureSource
#include "hud.h" // drawItemStack
@@ -78,14 +79,11 @@ static unsigned int font_line_height(gui::IGUIFont *font)
return font->getDimension(L"Ay").Height + font->getKerningHeight();
}
GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
JoystickController *joystick,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr,
Client *client,
ISimpleTextureSource *tsrc, IFormSource* fsrc, TextDest* tdst,
GUIFormSpecMenu::GUIFormSpecMenu(JoystickController *joystick,
gui::IGUIElement *parent, s32 id, IMenuManager *menumgr,
Client *client, ISimpleTextureSource *tsrc, IFormSource *fsrc, TextDest *tdst,
bool remap_dbl_click) :
GUIModalMenu(dev->getGUIEnvironment(), parent, id, menumgr),
m_device(dev),
GUIModalMenu(RenderingEngine::get_gui_env(), parent, id, menumgr),
m_invmgr(client),
m_tsrc(tsrc),
m_client(client),
@@ -2054,7 +2052,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
if (mydata.explicit_size) {
// compute scaling for specified form size
if (m_lock) {
v2u32 current_screensize = m_device->getVideoDriver()->getScreenSize();
v2u32 current_screensize = RenderingEngine::get_video_driver()->getScreenSize();
v2u32 delta = current_screensize - m_lockscreensize;
if (current_screensize.Y > m_lockscreensize.Y)
@@ -2075,7 +2073,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
}
double gui_scaling = g_settings->getFloat("gui_scaling");
double screen_dpi = porting::getDisplayDensity() * 96;
double screen_dpi = RenderingEngine::getDisplayDensity() * 96;
double use_imgsize;
if (m_lock) {
@@ -2108,7 +2106,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
((5.0/4.0) * (0.5 + mydata.invsize.X));
double fity_imgsize = mydata.screensize.Y /
((15.0/13.0) * (0.85 * mydata.invsize.Y));
double screen_dpi = porting::getDisplayDensity() * 96;
double screen_dpi = RenderingEngine::getDisplayDensity() * 96;
double min_imgsize = 0.3 * screen_dpi * gui_scaling;
use_imgsize = MYMAX(min_imgsize, MYMIN(prefer_imgsize,
MYMIN(fitx_imgsize, fity_imgsize)));
@@ -2579,7 +2577,7 @@ void GUIFormSpecMenu::drawMenu()
/* TODO find way to show tooltips on touchscreen */
#ifndef HAVE_TOUCHSCREENGUI
m_pointer = m_device->getCursorControl()->getPosition();
m_pointer = RenderingEngine::get_raw_device()->getCursorControl()->getPosition();
#endif
/*