#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
+#endif
+#ifdef _WIN32
+#include <windows.h>
+#include <winuser.h>
#endif
#if ENABLE_GLES
}
SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
+ if (g_logger.getTraceEnabled())
+ params.LoggingLevel = irr::ELL_DEBUG;
params.DriverType = driverType;
params.WindowSize = core::dimension2d<u32>(screen_w, screen_h);
params.Bits = bits;
params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu");
params.ZBufferBits = 24;
#ifdef __ANDROID__
- // clang-format off
params.PrivateData = porting::app_global;
- params.OGLES2ShaderPath = std::string(porting::path_user + DIR_DELIM + "media" +
- DIR_DELIM + "Shaders" + DIR_DELIM).c_str();
- // clang-format on
-#elif ENABLE_GLES
+#endif
+#if ENABLE_GLES
// there is no standardized path for these on desktop
std::string rel_path = std::string("client") + DIR_DELIM
+ "shaders" + DIR_DELIM + "Irrlicht";
RenderingEngine::~RenderingEngine()
{
core.reset();
- m_device->drop();
+ m_device->closeDevice();
s_singleton = nullptr;
}
return videomode_list != NULL;
}
+void RenderingEngine::removeMesh(const irr::scene::IMesh* mesh)
+{
+ m_device->getSceneManager()->getMeshCache()->removeMesh(mesh);
+}
+
+void RenderingEngine::cleanupMeshCache()
+{
+ auto mesh_cache = m_device->getSceneManager()->getMeshCache();
+ while (mesh_cache->getMeshCount() != 0) {
+ if (scene::IAnimatedMesh *mesh = mesh_cache->getMeshByIndex(0))
+ mesh_cache->removeMesh(mesh);
+ }
+}
+
bool RenderingEngine::setupTopLevelWindow(const std::string &name)
{
// FIXME: It would make more sense for there to be a switch of some
#endif
}
+#ifdef _WIN32
+static bool getWindowHandle(irr::video::IVideoDriver *driver, HWND &hWnd)
+{
+ const video::SExposedVideoData exposedData = driver->getExposedVideoData();
+
+ switch (driver->getDriverType()) {
+#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9
+ case video::EDT_DIRECT3D8:
+ hWnd = reinterpret_cast<HWND>(exposedData.D3D8.HWnd);
+ break;
+#endif
+ case video::EDT_DIRECT3D9:
+ hWnd = reinterpret_cast<HWND>(exposedData.D3D9.HWnd);
+ break;
+#if ENABLE_GLES
+ case video::EDT_OGLES1:
+ case video::EDT_OGLES2:
+#endif
+ case video::EDT_OPENGL:
+ hWnd = reinterpret_cast<HWND>(exposedData.OpenGLWin32.HWnd);
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+#endif
bool RenderingEngine::setWindowIcon()
{
"-xorg-icon-128.png");
#endif
#elif defined(_WIN32)
- const video::SExposedVideoData exposedData = driver->getExposedVideoData();
HWND hWnd; // Window handle
-
- switch (driver->getDriverType()) {
- case video::EDT_DIRECT3D8:
- hWnd = reinterpret_cast<HWND>(exposedData.D3D8.HWnd);
- break;
- case video::EDT_DIRECT3D9:
- hWnd = reinterpret_cast<HWND>(exposedData.D3D9.HWnd);
- break;
- case video::EDT_OPENGL:
- hWnd = reinterpret_cast<HWND>(exposedData.OpenGLWin32.HWnd);
- break;
- default:
+ if (!getWindowHandle(driver, hWnd))
return false;
- }
// Load the ICON from resource file
const HICON hicon = LoadIcon(GetModuleHandle(NULL),
}
#ifndef __ANDROID__
-#ifdef XORG_USED
+#if defined(XORG_USED)
static float calcDisplayDensity()
{
return cached_display_density;
}
-#else // XORG_USED
+#elif defined(_WIN32)
+
+
+static float calcDisplayDensity(irr::video::IVideoDriver *driver)
+{
+ HWND hWnd;
+ if (getWindowHandle(driver, hWnd)) {
+ HDC hdc = GetDC(hWnd);
+ float dpi = GetDeviceCaps(hdc, LOGPIXELSX);
+ ReleaseDC(hWnd, hdc);
+ return dpi / 96.0f;
+ }
+
+ /* return manually specified dpi */
+ return g_settings->getFloat("screen_dpi") / 96.0f;
+}
+
+float RenderingEngine::getDisplayDensity()
+{
+ static bool cached = false;
+ static float display_density;
+ if (!cached) {
+ display_density = calcDisplayDensity(get_video_driver());
+ cached = true;
+ }
+ return display_density;
+}
+
+#else
+
float RenderingEngine::getDisplayDensity()
{
return g_settings->getFloat("screen_dpi") / 96.0;
}
-#endif // XORG_USED
+
+#endif
v2u32 RenderingEngine::getDisplaySize()
{