From 5a4020bcb8761350d19f20bf092dd37ed3cbd400 Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 18 Dec 2023 10:32:29 +0800 Subject: [PATCH] Revert "Remove DX9 leftovers" This reverts commit 4525411e84b828d965b33878f7b24ac79afd8e31. --- lib/graphics_engine/CMakeLists.txt | 1 + lib/graphics_engine/src/ge_dx9_texture.cpp | 229 ++++++++++++++++++ lib/graphics_engine/src/ge_dx9_texture.hpp | 88 +++++++ lib/graphics_engine/src/ge_texture.cpp | 13 + lib/irrlicht/CMakeLists.txt | 1 + lib/irrlicht/include/EDriverTypes.h | 10 + lib/irrlicht/include/IVideoModeList.h | 2 +- lib/irrlicht/include/IrrCompileConfig.h | 34 +++ lib/irrlicht/include/IrrlichtDevice.h | 16 +- lib/irrlicht/include/SIrrCreationParameters.h | 3 +- lib/irrlicht/include/irrlicht.h | 2 +- .../source/Irrlicht/CIrrDeviceLinux.cpp | 6 + .../source/Irrlicht/CIrrDeviceSDL.cpp | 20 +- .../source/Irrlicht/CIrrDeviceWin32.cpp | 40 +++ .../Irrlicht/MacOSX/CIrrDeviceMacOSX.mm | 5 + 15 files changed, 463 insertions(+), 7 deletions(-) create mode 100644 lib/graphics_engine/src/ge_dx9_texture.cpp create mode 100644 lib/graphics_engine/src/ge_dx9_texture.hpp diff --git a/lib/graphics_engine/CMakeLists.txt b/lib/graphics_engine/CMakeLists.txt index a4ecc5261..b42ff383c 100644 --- a/lib/graphics_engine/CMakeLists.txt +++ b/lib/graphics_engine/CMakeLists.txt @@ -67,6 +67,7 @@ set(GE_SOURCES src/ge_compressor_bptc_bc7.cpp src/ge_compressor_s3tc_bc3.cpp src/ge_culling_tool.cpp + src/ge_dx9_texture.cpp src/ge_main.cpp src/ge_texture.cpp src/ge_vma.cpp diff --git a/lib/graphics_engine/src/ge_dx9_texture.cpp b/lib/graphics_engine/src/ge_dx9_texture.cpp new file mode 100644 index 000000000..9c57ae98d --- /dev/null +++ b/lib/graphics_engine/src/ge_dx9_texture.cpp @@ -0,0 +1,229 @@ +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include "ge_dx9_texture.hpp" +#include "ge_main.hpp" +#include "ge_texture.hpp" + +#include +#include + +namespace GE +{ +GEDX9Texture::GEDX9Texture(const std::string& path, + std::function image_mani) + : video::ITexture(path.c_str()), m_image_mani(image_mani), + m_device_9(NULL), m_texture_9(NULL), m_texture_size(0), + m_disable_reload(false) +{ + m_max_size = getDriver()->getDriverAttributes() + .getAttributeAsDimension2d("MAX_TEXTURE_SIZE"); + getDevice9(); + reload(); +} // GEDX9Texture + +// ---------------------------------------------------------------------------- +GEDX9Texture::GEDX9Texture(video::IImage* img, const std::string& name) + : video::ITexture(name.c_str()), m_image_mani(nullptr), + m_device_9(NULL), m_texture_9(NULL), m_texture_size(0), + m_disable_reload(true) +{ + getDevice9(); + if (!m_device_9 || !img) + { + LoadingFailed = true; + return; + } + uint8_t* data = NULL; + m_size = m_orig_size = img->getDimension(); + HRESULT hr = m_device_9->CreateTexture(m_size.Width, m_size.Height, + 0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, + &m_texture_9, NULL); + if (FAILED(hr)) + { + LoadingFailed = true; + goto exit; + } + data = (uint8_t*)img->lock(); + upload(data); +exit: + img->unlock(); + img->drop(); +} // GEDX9Texture + +// ---------------------------------------------------------------------------- +GEDX9Texture::GEDX9Texture(const std::string& name, unsigned int size) + : video::ITexture(name.c_str()), m_image_mani(nullptr), + m_device_9(NULL), m_texture_9(NULL), m_texture_size(0), + m_disable_reload(true) +{ + getDevice9(); + if (!m_device_9) + { + LoadingFailed = true; + return; + } + m_orig_size.Width = size; + m_orig_size.Height = size; + m_size = m_orig_size; + HRESULT hr = m_device_9->CreateTexture(m_size.Width, m_size.Height, + 0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, + &m_texture_9, NULL); + if (FAILED(hr)) + { + LoadingFailed = true; + return; + } + std::vector data; + data.resize(size * size * 4, 0); + upload(data.data()); +} // GEDX9Texture + +// ---------------------------------------------------------------------------- +GEDX9Texture::~GEDX9Texture() +{ + if (m_texture_9) + m_texture_9->Release(); + if (m_device_9) + m_device_9->Release(); +} // ~GEDX9Texture + +// ---------------------------------------------------------------------------- +void GEDX9Texture::getDevice9() +{ + m_device_9 = GE::getDriver()->getExposedVideoData().D3D9.D3DDev9; + if (m_device_9) + m_device_9->AddRef(); +} // getDevice9 + +// ---------------------------------------------------------------------------- +void GEDX9Texture::reload() +{ + if (m_disable_reload) + return; + + if (!m_device_9) + { + LoadingFailed = true; + return; + } + + video::IImage* texture_image = getResizedImage(NamedPath.getPtr(), + m_max_size, &m_orig_size); + if (texture_image == NULL) + { + LoadingFailed = true; + return; + } + m_size = texture_image->getDimension(); + if (m_image_mani) + m_image_mani(texture_image); + if (m_texture_9 != NULL) + { + m_texture_9->Release(); + m_texture_9 = NULL; + } + uint8_t* data = (uint8_t*)texture_image->lock(); + HRESULT hr = m_device_9->CreateTexture(m_size.Width, m_size.Height, + 0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, + &m_texture_9, NULL); + if (FAILED(hr)) + { + LoadingFailed = true; + goto exit; + } + upload(data); +exit: + texture_image->unlock(); + texture_image->drop(); +} // reload + +// ---------------------------------------------------------------------------- +void GEDX9Texture::upload(uint8_t* data) +{ + const unsigned int w = m_size.Width; + const unsigned int h = m_size.Height; + HRESULT hr; + D3DLOCKED_RECT rect; + hr = m_texture_9->LockRect(0, &rect, 0, 0); + if (FAILED(hr)) + return; + uint8_t* dst = (uint8_t*)rect.pBits; + for (u32 i = 0; i < h; i++) + { + memcpy(dst, data, w * 4); + data += w * 4; + dst += rect.Pitch; + } + hr = m_texture_9->UnlockRect(0); + if (FAILED(hr)) + return; + m_texture_9->GenerateMipSubLevels(); + m_texture_size = w * h * 4; +} // upload + +// ---------------------------------------------------------------------------- +void* GEDX9Texture::lock(video::E_TEXTURE_LOCK_MODE mode, u32 mipmap_level) +{ + if (mode != video::ETLM_READ_ONLY || !m_texture_9) + return NULL; + HRESULT hr; + D3DLOCKED_RECT rect; + hr = m_texture_9->LockRect(0, &rect, 0, + (mode == video::ETLM_READ_ONLY) ? D3DLOCK_READONLY : 0); + if (FAILED(hr)) + return NULL; + return rect.pBits; +} // lock + +//----------------------------------------------------------------------------- +void GEDX9Texture::updateTexture(void* data, video::ECOLOR_FORMAT format, + u32 w, u32 h, u32 x, u32 y) +{ + if (!m_texture_9) + return; + + std::vector image_data; + uint8_t* src = NULL; + if (format == video::ECF_R8) + { + const unsigned int size = w * h; + image_data.resize(size * 4, 255); + uint8_t* orig_data = (uint8_t*)data; + for (unsigned int i = 0; i < size; i++) + image_data[4 * i + 3] = orig_data[i]; + src = image_data.data(); + } + else if (format == video::ECF_A8R8G8B8) + { + src = (uint8_t*)data; + } + + if (src == NULL) + return; + HRESULT hr; + D3DLOCKED_RECT rect; + RECT subimg; + subimg.left = x; + subimg.top = y; + subimg.right = x + w; + subimg.bottom = y + h; + hr = m_texture_9->LockRect(0, &rect, &subimg, 0); + if (FAILED(hr)) + return; + uint8_t* dst = (uint8_t*)rect.pBits; + for (u32 i = 0; i < h; i++) + { + memcpy(dst, src, w * 4); + src += w * 4; + dst += rect.Pitch; + } + hr = m_texture_9->UnlockRect(0); + if (FAILED(hr)) + return; + m_texture_9->GenerateMipSubLevels(); +} // updateTexture + +} + +#endif diff --git a/lib/graphics_engine/src/ge_dx9_texture.hpp b/lib/graphics_engine/src/ge_dx9_texture.hpp new file mode 100644 index 000000000..1be770183 --- /dev/null +++ b/lib/graphics_engine/src/ge_dx9_texture.hpp @@ -0,0 +1,88 @@ +#ifndef HEADER_GE_DX9_TEXTURE_HPP +#define HEADER_GE_DX9_TEXTURE_HPP + +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + +#include + +#include +#include +#include + +using namespace irr; + +namespace GE +{ +class GEDX9Texture : public video::ITexture +{ +private: + core::dimension2d m_size, m_orig_size, m_max_size; + + std::function m_image_mani; + + IDirect3DDevice9* m_device_9; + + IDirect3DTexture9* m_texture_9; + + unsigned int m_texture_size; + + const bool m_disable_reload; + + // ------------------------------------------------------------------------ + void getDevice9(); + // ------------------------------------------------------------------------ + void upload(uint8_t* data); + +public: + // ------------------------------------------------------------------------ + GEDX9Texture(const std::string& path, + std::function image_mani = nullptr); + // ------------------------------------------------------------------------ + GEDX9Texture(video::IImage* img, const std::string& name); + // ------------------------------------------------------------------------ + GEDX9Texture(const std::string& name, unsigned int size); + // ------------------------------------------------------------------------ + virtual ~GEDX9Texture(); + // ------------------------------------------------------------------------ + virtual void* lock(video::E_TEXTURE_LOCK_MODE mode = + video::ETLM_READ_WRITE, u32 mipmap_level = 0); + // ------------------------------------------------------------------------ + virtual void unlock() + { + if (m_texture_9) + m_texture_9->UnlockRect(0); + } + // ------------------------------------------------------------------------ + virtual const core::dimension2d& getOriginalSize() const + { return m_orig_size; } + // ------------------------------------------------------------------------ + virtual const core::dimension2d& getSize() const { return m_size; } + // ------------------------------------------------------------------------ + virtual video::E_DRIVER_TYPE getDriverType() const + { return video::EDT_DIRECT3D9; } + // ------------------------------------------------------------------------ + virtual video::ECOLOR_FORMAT getColorFormat() const + { return video::ECF_A8R8G8B8; } + // ------------------------------------------------------------------------ + virtual u32 getPitch() const { return 0; } + // ------------------------------------------------------------------------ + virtual bool hasMipMaps() const { return true; } + // ------------------------------------------------------------------------ + virtual void regenerateMipMapLevels(void* mipmap_data = NULL) {} + // ------------------------------------------------------------------------ + virtual u64 getTextureHandler() const { return (u64)m_texture_9; } + // ------------------------------------------------------------------------ + virtual unsigned int getTextureSize() const { return m_texture_size; } + // ------------------------------------------------------------------------ + virtual void reload(); + // ------------------------------------------------------------------------ + virtual void updateTexture(void* data, irr::video::ECOLOR_FORMAT format, + u32 w, u32 h, u32 x, u32 y); +}; // GEDX9Texture + +} + +#endif + +#endif diff --git a/lib/graphics_engine/src/ge_texture.cpp b/lib/graphics_engine/src/ge_texture.cpp index 1e7b57f6e..314d266c9 100644 --- a/lib/graphics_engine/src/ge_texture.cpp +++ b/lib/graphics_engine/src/ge_texture.cpp @@ -1,4 +1,5 @@ #include "ge_main.hpp" +#include "ge_dx9_texture.hpp" #include "ge_gl_texture.hpp" #include "ge_vulkan_texture.hpp" #include "ge_texture.hpp" @@ -96,6 +97,10 @@ irr::video::ITexture* createTexture(const std::string& path, case video::EDT_OPENGL: case video::EDT_OGLES2: return new GEGLTexture(path, image_mani); +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + case video::EDT_DIRECT3D9: + return new GEDX9Texture(path, image_mani); +#endif case video::EDT_VULKAN: return new GEVulkanTexture(path, image_mani); default: @@ -112,6 +117,10 @@ irr::video::ITexture* createTexture(video::IImage* img, case video::EDT_OPENGL: case video::EDT_OGLES2: return new GEGLTexture(img, name); +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + case video::EDT_DIRECT3D9: + return new GEDX9Texture(img, name); +#endif case video::EDT_VULKAN: return new GEVulkanTexture(img, name); default: @@ -128,6 +137,10 @@ irr::video::ITexture* createFontTexture(const std::string& name, case video::EDT_OPENGL: case video::EDT_OGLES2: return new GEGLTexture(name, size, single_channel); +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + case video::EDT_DIRECT3D9: + return new GEDX9Texture(name, size); +#endif case video::EDT_VULKAN: return new GEVulkanTexture(name, size, single_channel); default: diff --git a/lib/irrlicht/CMakeLists.txt b/lib/irrlicht/CMakeLists.txt index 376dbf2b1..27a8a52db 100644 --- a/lib/irrlicht/CMakeLists.txt +++ b/lib/irrlicht/CMakeLists.txt @@ -26,6 +26,7 @@ else() add_definitions(-DNO_IRR_COMPILE_WITH_X11_) add_definitions(-DNO_IRR_COMPILE_WITH_WAYLAND_DEVICE_) add_definitions(-DNO_IRR_COMPILE_WITH_SDL_DEVICE_) + add_definitions(-DNO_IRR_COMPILE_WITH_DIRECT3D_9_) add_definitions(-DNO_IRR_COMPILE_WITH_VULKAN_) endif() diff --git a/lib/irrlicht/include/EDriverTypes.h b/lib/irrlicht/include/EDriverTypes.h index 3839ab73a..2815c5534 100644 --- a/lib/irrlicht/include/EDriverTypes.h +++ b/lib/irrlicht/include/EDriverTypes.h @@ -37,6 +37,16 @@ namespace video contribution. */ EDT_BURNINGSVIDEO, + //! Direct3D8 device, only available on Win32 platforms. + /** Performs hardware accelerated rendering of 3D and 2D + primitives. */ + EDT_DIRECT3D8, + + //! Direct3D 9 device, only available on Win32 platforms. + /** Performs hardware accelerated rendering of 3D and 2D + primitives. */ + EDT_DIRECT3D9, + //! OpenGL device, available on most platforms. /** Performs hardware accelerated rendering of 3D and 2D primitives. */ diff --git a/lib/irrlicht/include/IVideoModeList.h b/lib/irrlicht/include/IVideoModeList.h index bb2a5b608..4fe2e69af 100644 --- a/lib/irrlicht/include/IVideoModeList.h +++ b/lib/irrlicht/include/IVideoModeList.h @@ -17,7 +17,7 @@ namespace video /** You can get a list via IrrlichtDevice::getVideoModeList(). If you are confused now, because you think you have to create an Irrlicht Device with a video mode before being able to get the video mode list, let me tell you that - there is no need to start up an Irrlicht Device with EDT_OPENGL or + there is no need to start up an Irrlicht Device with EDT_DIRECT3D8, EDT_OPENGL or EDT_SOFTWARE: For this (and for lots of other reasons) the null device, EDT_NULL exists.*/ class IVideoModeList : public virtual IReferenceCounted diff --git a/lib/irrlicht/include/IrrCompileConfig.h b/lib/irrlicht/include/IrrCompileConfig.h index 3cb25cccf..384c6836e 100644 --- a/lib/irrlicht/include/IrrCompileConfig.h +++ b/lib/irrlicht/include/IrrCompileConfig.h @@ -135,6 +135,21 @@ //! Maximum number of texture an SMaterial can have, up to 8 are supported by Irrlicht. #define _IRR_MATERIAL_MAX_TEXTURES_ 8 +//! Define _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_ to +//! compile the Irrlicht engine with Direct3D8 and/or DIRECT3D9. +/** If you only want to use the software device or opengl you can disable those defines. +This switch is mostly disabled because people do not get the g++ compiler compile +directX header files, and directX is only available on Windows platforms. If you +are using Dev-Cpp, and want to compile this using a DX dev pack, you can define +_IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this +to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK +and this to the linker settings: -ld3dx9 -ld3dx8 + +Microsoft have chosen to remove D3D8 headers from their recent DXSDKs, and +so D3D8 support is now disabled by default. If you really want to build +with D3D8 support, then you will have to source a DXSDK with the appropriate +headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one. +*/ #if defined(_IRR_WINDOWS_API_) //! Define _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ if you want to use DirectInput for joystick handling. @@ -145,6 +160,14 @@ If not defined, Windows Multimedia library is used, which offers also broad supp #undef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ #endif +//! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004 +// #define _IRR_COMPILE_WITH_DIRECT3D_8_ +#ifdef NO_IRR_COMPILE_WITH_DIRECT3D_9_ +#undef _IRR_COMPILE_WITH_DIRECT3D_9_ +#else +#define _IRR_COMPILE_WITH_DIRECT3D_9_ +#endif + #endif //! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL. @@ -431,6 +454,17 @@ precision will be lower but speed higher. currently X86 only #endif // _IRR_WINDOWS_API_ +// We need to disable DIRECT3D9 support for Visual Studio 6.0 because +// those $%&$!! disabled support for it since Dec. 2004 and users are complaining +// about linker errors. Comment this out only if you are knowing what you are +// doing. (Which means you have an old DX9 SDK and VisualStudio6). +#ifdef _MSC_VER +#if (_MSC_VER < 1300 && !defined(__GNUC__)) +#undef _IRR_COMPILE_WITH_DIRECT3D_9_ +#pragma message("Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled.") +#endif +#endif + #ifndef _IRR_WINDOWS_API_ #undef _IRR_WCHAR_FILESYSTEM #endif diff --git a/lib/irrlicht/include/IrrlichtDevice.h b/lib/irrlicht/include/IrrlichtDevice.h index 7e642d750..983990eb1 100644 --- a/lib/irrlicht/include/IrrlichtDevice.h +++ b/lib/irrlicht/include/IrrlichtDevice.h @@ -111,8 +111,8 @@ namespace irr /** If you are confused now, because you think you have to create an Irrlicht Device with a video mode before being able to get the video mode list, let me tell you that there is no - need to start up an Irrlicht Device with EDT_OPENGL or - EDT_SOFTWARE: For this (and for lots of other + need to start up an Irrlicht Device with EDT_DIRECT3D8, + EDT_OPENGL or EDT_SOFTWARE: For this (and for lots of other reasons) the null driver, EDT_NULL exists. \return Pointer to a list with all video modes supported by the gfx adapter. */ @@ -344,6 +344,18 @@ namespace irr return true; #else return false; +#endif + case video::EDT_DIRECT3D8: +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + return true; +#else + return false; +#endif + case video::EDT_DIRECT3D9: +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + return true; +#else + return false; #endif case video::EDT_OPENGL: #ifdef _IRR_COMPILE_WITH_OPENGL_ diff --git a/lib/irrlicht/include/SIrrCreationParameters.h b/lib/irrlicht/include/SIrrCreationParameters.h index 5a5730b72..b73b152d1 100644 --- a/lib/irrlicht/include/SIrrCreationParameters.h +++ b/lib/irrlicht/include/SIrrCreationParameters.h @@ -112,7 +112,8 @@ namespace irr //! Type of video driver used to render graphics. /** This can currently be video::EDT_NULL, video::EDT_SOFTWARE, - video::EDT_BURNINGSVIDEO, video::EDT_OPENGL, and video::EDT_VULKAN. + video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, + video::EDT_DIRECT3D9, and video::EDT_OPENGL. Default: Software. */ video::E_DRIVER_TYPE DriverType; diff --git a/lib/irrlicht/include/irrlicht.h b/lib/irrlicht/include/irrlicht.h index b90537a62..fb802bb60 100644 --- a/lib/irrlicht/include/irrlicht.h +++ b/lib/irrlicht/include/irrlicht.h @@ -300,7 +300,7 @@ namespace irr /** If you need more parameters to be passed to the creation of the Irrlicht Engine device, use the createDeviceEx() function. \param deviceType: Type of the device. This can currently be video::EDT_NULL, - video::EDT_SOFTWARE, video::EDT_BURNINGSVIDEO, video::EDT_OPENGL and video::EDT_VULKAN. + video::EDT_SOFTWARE, video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL. \param windowSize: Size of the window or the video mode in fullscreen mode. \param bits: Bits per pixel in fullscreen mode. Ignored if windowed mode. \param fullscreen: Should be set to true if the device should run in fullscreen. Otherwise diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp index 459a647d3..4e80d9d5d 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp @@ -1332,6 +1332,12 @@ void CIrrDeviceLinux::createDriver() break; } + case video::EDT_DIRECT3D8: + case video::EDT_DIRECT3D9: + os::Printer::log("This driver is not available in Linux. Try OpenGL or Software renderer.", + ELL_ERROR); + break; + case video::EDT_NULL: VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); break; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp index 460c70acd..dd71d0cc5 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp @@ -39,6 +39,10 @@ namespace irr io::IFileSystem* io, CIrrDeviceSDL* device); IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device, u32 default_fb); +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + IVideoDriver* createDirectX9Driver(const SIrrlichtCreationParameters& params, + io::IFileSystem* io, HWND window); +#endif #ifdef _IRR_COMPILE_WITH_VULKAN_ IVideoDriver* createVulkanDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, SDL_Window* win, IrrlichtDevice* device); @@ -128,11 +132,13 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) { SDL_VERSION(&Info.version); -#if (defined(IOS_STK) && !defined(__SWITCH__)) - // Only iOS build uses the Info structure +#if (defined(IOS_STK) || defined(_IRR_COMPILE_WITH_DIRECT3D_9_)) && !defined(__SWITCH__) + // Only iOS or DirectX9 build uses the Info structure // Switch doesn't support GetWindowWMInfo #ifdef IOS_STK if (!SDL_GetWindowWMInfo(Window, &Info)) +#else + if (CreationParams.DriverType == video::EDT_DIRECT3D9 && !SDL_GetWindowWMInfo(Window, &Info)) #endif return; #endif @@ -722,6 +728,16 @@ void CIrrDeviceSDL::createDriver() break; } + case video::EDT_DIRECT3D9: + { + #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, Info.info.win.window); + #else + os::Printer::log("No DirectX 9 support compiled in.", ELL_ERROR); + #endif + break; + } + case video::EDT_NULL: VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); break; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp index 6f3c8e92d..34a81d88a 100755 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp @@ -58,6 +58,16 @@ namespace irr { namespace video { + #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + IVideoDriver* createDirectX8Driver(const irr::SIrrlichtCreationParameters& params, + io::IFileSystem* io, HWND window); + #endif + + #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params, + io::IFileSystem* io, HWND window); + #endif + #ifdef _IRR_COMPILE_WITH_OPENGL_ IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceWin32* device); @@ -1523,6 +1533,36 @@ void CIrrDeviceWin32::createDriver() { switch(CreationParams.DriverType) { + case video::EDT_DIRECT3D8: + #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + + VideoDriver = video::createDirectX8Driver(CreationParams, FileSystem, HWnd); + + if (!VideoDriver) + { + os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR); + } + #else + os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR); + #endif // _IRR_COMPILE_WITH_DIRECT3D_8_ + + break; + + case video::EDT_DIRECT3D9: + #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + + VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, HWnd); + + if (!VideoDriver) + { + os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR); + } + #else + os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR); + #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ + + break; + case video::EDT_OPENGL: #ifdef _IRR_COMPILE_WITH_OPENGL_ diff --git a/lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm index 3173bc18e..981b8df42 100644 --- a/lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm +++ b/lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm @@ -971,6 +971,11 @@ void CIrrDeviceMacOSX::createDriver() #endif break; + case video::EDT_DIRECT3D8: + case video::EDT_DIRECT3D9: + os::Printer::log("This driver is not available in OSX. Try OpenGL or Software renderer.", ELL_ERROR); + break; + case video::EDT_NULL: VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); break;