mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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:
parent
a8650e785d
commit
b3a36f7378
50 changed files with 1568 additions and 1567 deletions
|
@ -33,10 +33,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "serverlist.h"
|
||||
#include "mapgen.h"
|
||||
#include "settings.h"
|
||||
#include "EDriverTypes.h"
|
||||
|
||||
#include <IFileArchive.h>
|
||||
#include <IFileSystem.h>
|
||||
#include "client/renderingengine.h"
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -628,8 +628,7 @@ int ModApiMainMenu::l_show_keys_menu(lua_State *L)
|
|||
GUIEngine* engine = getGuiEngine(L);
|
||||
sanity_check(engine != NULL);
|
||||
|
||||
GUIKeyChangeMenu *kmenu
|
||||
= new GUIKeyChangeMenu( engine->m_device->getGUIEnvironment(),
|
||||
GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu(RenderingEngine::get_gui_env(),
|
||||
engine->m_parent,
|
||||
-1,
|
||||
engine->m_menumanager);
|
||||
|
@ -832,9 +831,6 @@ int ModApiMainMenu::l_copy_dir(lua_State *L)
|
|||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_extract_zip(lua_State *L)
|
||||
{
|
||||
GUIEngine* engine = getGuiEngine(L);
|
||||
sanity_check(engine);
|
||||
|
||||
const char *zipfile = luaL_checkstring(L, 1);
|
||||
const char *destination = luaL_checkstring(L, 2);
|
||||
|
||||
|
@ -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();
|
||||
|
||||
if (!fs->addFileArchive(zipfile,true,false,io::EFAT_ZIP)) {
|
||||
lua_pushboolean(L,false);
|
||||
|
@ -960,7 +956,7 @@ int ModApiMainMenu::l_show_path_select_dialog(lua_State *L)
|
|||
bool is_file_select = lua_toboolean(L, 3);
|
||||
|
||||
GUIFileSelectMenu* fileOpenMenu =
|
||||
new GUIFileSelectMenu(engine->m_device->getGUIEnvironment(),
|
||||
new GUIFileSelectMenu(RenderingEngine::get_gui_env(),
|
||||
engine->m_parent,
|
||||
-1,
|
||||
engine->m_menumanager,
|
||||
|
@ -997,13 +993,12 @@ int ModApiMainMenu::l_download_file(lua_State *L)
|
|||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_get_video_drivers(lua_State *L)
|
||||
{
|
||||
std::vector<irr::video::E_DRIVER_TYPE> drivers
|
||||
= porting::getSupportedVideoDrivers();
|
||||
std::vector<irr::video::E_DRIVER_TYPE> drivers = RenderingEngine::getSupportedVideoDrivers();
|
||||
|
||||
lua_newtable(L);
|
||||
for (u32 i = 0; i != drivers.size(); i++) {
|
||||
const char *name = porting::getVideoDriverName(drivers[i]);
|
||||
const char *fname = porting::getVideoDriverFriendlyName(drivers[i]);
|
||||
const char *name = RenderingEngine::getVideoDriverName(drivers[i]);
|
||||
const char *fname = RenderingEngine::getVideoDriverFriendlyName(drivers[i]);
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, name);
|
||||
|
@ -1021,7 +1016,7 @@ int ModApiMainMenu::l_get_video_drivers(lua_State *L)
|
|||
int ModApiMainMenu::l_get_video_modes(lua_State *L)
|
||||
{
|
||||
std::vector<core::vector3d<u32> > videomodes
|
||||
= porting::getSupportedVideoModes();
|
||||
= RenderingEngine::getSupportedVideoModes();
|
||||
|
||||
lua_newtable(L);
|
||||
for (u32 i = 0; i != videomodes.size(); i++) {
|
||||
|
@ -1054,23 +1049,24 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
|
|||
lua_newtable(L);
|
||||
int top = lua_gettop(L);
|
||||
lua_pushstring(L,"density");
|
||||
lua_pushnumber(L,porting::getDisplayDensity());
|
||||
lua_pushnumber(L,RenderingEngine::getDisplayDensity());
|
||||
lua_settable(L, top);
|
||||
|
||||
lua_pushstring(L,"display_width");
|
||||
lua_pushnumber(L,porting::getDisplaySize().X);
|
||||
lua_pushnumber(L,RenderingEngine::getDisplaySize().X);
|
||||
lua_settable(L, top);
|
||||
|
||||
lua_pushstring(L,"display_height");
|
||||
lua_pushnumber(L,porting::getDisplaySize().Y);
|
||||
lua_pushnumber(L,RenderingEngine::getDisplaySize().Y);
|
||||
lua_settable(L, top);
|
||||
|
||||
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
|
||||
lua_pushstring(L,"window_width");
|
||||
lua_pushnumber(L,porting::getWindowSize().X);
|
||||
lua_pushnumber(L, window_size.X);
|
||||
lua_settable(L, top);
|
||||
|
||||
lua_pushstring(L,"window_height");
|
||||
lua_pushnumber(L,porting::getWindowSize().Y);
|
||||
lua_pushnumber(L, window_size.Y);
|
||||
lua_settable(L, top);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue