diff --git a/source/d3d8to9.hpp b/source/d3d8to9.hpp index 10d36bf..6dbf31e 100644 --- a/source/d3d8to9.hpp +++ b/source/d3d8to9.hpp @@ -8,18 +8,34 @@ #include #include "d3d8types.hpp" -class __declspec(uuid("1DD9E8DA-1C77-4D40-B0CF-98FEFDFF9512")) Direct3D8; -class __declspec(uuid("7385E5DF-8FE8-41D5-86B6-D7B48547B6CF")) Direct3DDevice8; -class __declspec(uuid("928C088B-76B9-4C6B-A536-A590853876CD")) Direct3DSwapChain8; -class __declspec(uuid("1B36BB7B-09B7-410A-B445-7D1430D7B33F")) Direct3DResource8; -class __declspec(uuid("B4211CFA-51B9-4A9F-AB78-DB99B2BB678E")) Direct3DBaseTexture8; -class __declspec(uuid("E4CDD575-2866-4F01-B12E-7EECE1EC9358")) Direct3DTexture8; -class __declspec(uuid("3EE5B968-2ACA-4C34-8BB5-7E0C3D19B750")) Direct3DCubeTexture8; -class __declspec(uuid("4B8AAAFA-140F-42BA-9131-597EAFAA2EAD")) Direct3DVolumeTexture8; -class __declspec(uuid("B96EEBCA-B326-4EA5-882F-2FF5BAE021DD")) Direct3DSurface8; -class __declspec(uuid("BD7349F5-14F1-42E4-9C79-972380DB40C0")) Direct3DVolume8; -class __declspec(uuid("8AEEEAC7-05F9-44D4-B591-000B0DF1CB95")) Direct3DVertexBuffer8; -class __declspec(uuid("0E689C9A-053D-44A0-9D92-DB0E3D750F86")) Direct3DIndexBuffer8; +class DECLSPEC_UUID("1DD9E8DA-1C77-4D40-B0CF-98FEFDFF9512") Direct3D8; +class DECLSPEC_UUID("7385E5DF-8FE8-41D5-86B6-D7B48547B6CF") Direct3DDevice8; +class DECLSPEC_UUID("928C088B-76B9-4C6B-A536-A590853876CD") Direct3DSwapChain8; +class DECLSPEC_UUID("1B36BB7B-09B7-410A-B445-7D1430D7B33F") Direct3DResource8; +class DECLSPEC_UUID("B4211CFA-51B9-4A9F-AB78-DB99B2BB678E") Direct3DBaseTexture8; +class DECLSPEC_UUID("E4CDD575-2866-4F01-B12E-7EECE1EC9358") Direct3DTexture8; +class DECLSPEC_UUID("3EE5B968-2ACA-4C34-8BB5-7E0C3D19B750") Direct3DCubeTexture8; +class DECLSPEC_UUID("4B8AAAFA-140F-42BA-9131-597EAFAA2EAD") Direct3DVolumeTexture8; +class DECLSPEC_UUID("B96EEBCA-B326-4EA5-882F-2FF5BAE021DD") Direct3DSurface8; +class DECLSPEC_UUID("BD7349F5-14F1-42E4-9C79-972380DB40C0") Direct3DVolume8; +class DECLSPEC_UUID("8AEEEAC7-05F9-44D4-B591-000B0DF1CB95") Direct3DVertexBuffer8; +class DECLSPEC_UUID("0E689C9A-053D-44A0-9D92-DB0E3D750F86") Direct3DIndexBuffer8; + +// MinGW support +#ifdef __CRT_UUID_DECL +__CRT_UUID_DECL(Direct3D8, 0x1DD9E8DA, 0x1C77, 0x4D40, 0xB0, 0xCF, 0x98,0xFE,0xFD,0xFF,0x95,0x12) +__CRT_UUID_DECL(Direct3DDevice8, 0x7385E5DF, 0x8FE8, 0x41D5, 0x86, 0xB6, 0xD7,0xB4,0x85,0x47,0xB6,0xCF) +__CRT_UUID_DECL(Direct3DSwapChain8, 0x928C088B, 0x76B9, 0x4C6B, 0xA5, 0x36, 0xA5,0x90,0x85,0x38,0x76,0xCD) +__CRT_UUID_DECL(Direct3DResource8, 0x1B36BB7B, 0x09B7, 0x410A, 0xB4, 0x45, 0x7D,0x14,0x30,0xD7,0xB3,0x3F) +__CRT_UUID_DECL(Direct3DBaseTexture8, 0xB4211CFA, 0x51B9, 0x4A9F, 0xAB, 0x78, 0xDB,0x99,0xB2,0xBB,0x67,0x8E) +__CRT_UUID_DECL(Direct3DTexture8, 0xE4CDD575, 0x2866, 0x4F01, 0xB1, 0x2E, 0x7E,0xEC,0xE1,0xEC,0x93,0x58) +__CRT_UUID_DECL(Direct3DCubeTexture8, 0x3EE5B968, 0x2ACA, 0x4C34, 0x8B, 0xB5, 0x7E,0x0C,0x3D,0x19,0xB7,0x50) +__CRT_UUID_DECL(Direct3DVolumeTexture8, 0x4B8AAAFA, 0x140F, 0x42BA, 0x91, 0x31, 0x59,0x7E,0xAF,0xAA,0x2E,0xAD) +__CRT_UUID_DECL(Direct3DSurface8, 0xB96EEBCA, 0xB326, 0x4EA5, 0x88, 0x2F, 0x2F,0xF5,0xBA,0xE0,0x21,0xDD) +__CRT_UUID_DECL(Direct3DVolume8, 0xBD7349F5, 0x14F1, 0x42E4, 0x9C, 0x79, 0x97,0x23,0x80,0xDB,0x40,0xC0) +__CRT_UUID_DECL(Direct3DVertexBuffer8, 0x8AEEEAC7, 0x05F9, 0x44D4, 0xB5, 0x91, 0x00,0x0B,0x0D,0xF1,0xCB,0x95) +__CRT_UUID_DECL(Direct3DIndexBuffer8, 0x0E689C9A, 0x053D, 0x44A0, 0x9D, 0x92, 0xDB,0x0E,0x3D,0x75,0x0F,0x86) +#endif #include "interface_query.hpp" diff --git a/source/d3d8types.cpp b/source/d3d8types.cpp index 80f4898..b190243 100644 --- a/source/d3d8types.cpp +++ b/source/d3d8types.cpp @@ -5,6 +5,7 @@ #include "d3d8types.hpp" #include +#include bool SupportsPalettes() { @@ -88,7 +89,7 @@ void ConvertCaps(D3DCAPS9 &Input, D3DCAPS8 &Output) // Set default vertex shader version to 1.1 for D3D8 compatibility Output.VertexShaderVersion = D3DVS_VERSION(1, 1); // D3D8 can only handle up to 256 for MaxVertexShaderConst - Output.MaxVertexShaderConst = min(256, Input.MaxVertexShaderConst); + Output.MaxVertexShaderConst = std::min(256ul, Input.MaxVertexShaderConst); } void ConvertVolumeDesc(D3DVOLUME_DESC &Input, D3DVOLUME_DESC8 &Output) diff --git a/source/d3d8types.hpp b/source/d3d8types.hpp index b8cb2f7..b8e00b9 100644 --- a/source/d3d8types.hpp +++ b/source/d3d8types.hpp @@ -2,6 +2,10 @@ struct IUnknown; +#ifndef NOMINMAX +#define NOMINMAX +#endif + #include #define D3DFMT_W11V11U10 65 @@ -46,10 +50,20 @@ struct IUnknown; #define D3DVSD_CONSTADDRESSMASK (0x7F << D3DVSD_CONSTADDRESSSHIFT) #define D3DVSD_END() 0xFFFFFFFF +// Fix for MinGW headers which are missing defines in d3d9.h... +#ifndef D3DENUM_WHQL_LEVEL +#define D3DENUM_WHQL_LEVEL 0x00000002L +#endif +// Fix for MinGW headers which have some d3d8 defines in d3d9.h... +#ifndef D3DENUM_NO_WHQL_LEVEL #define D3DENUM_NO_WHQL_LEVEL 0x00000002L +#endif #define D3DSWAPEFFECT_COPY_VSYNC 4 #define D3DPRESENT_RATE_UNLIMITED 0x7FFFFFFF +// Fix for MinGW headers which have some d3d8 defines in d3d9.h... +#ifndef D3DCAPS2_CANRENDERWINDOWED #define D3DCAPS2_CANRENDERWINDOWED 0x00080000L +#endif #define D3DPRASTERCAPS_ZBIAS 0x00004000L typedef D3DLIGHT9 D3DLIGHT8; diff --git a/source/d3dx9.hpp b/source/d3dx9.hpp index d319114..63ac7e1 100644 --- a/source/d3dx9.hpp +++ b/source/d3dx9.hpp @@ -1,5 +1,9 @@ #pragma once +#ifndef NOMINMAX +#define NOMINMAX +#endif + #include #define D3DX_FILTER_NONE 1 diff --git a/source/interface_query.hpp b/source/interface_query.hpp index 904bad7..9b9f4af 100644 --- a/source/interface_query.hpp +++ b/source/interface_query.hpp @@ -12,30 +12,6 @@ class AddressLookupTable { template struct AddressCacheIndex; - template <> - struct AddressCacheIndex - { static constexpr UINT CacheIndex = 0; using Type9 = IDirect3DSurface9; }; - template <> - struct AddressCacheIndex - { static constexpr UINT CacheIndex = 1; using Type9 = IDirect3DTexture9; }; - template <> - struct AddressCacheIndex - { static constexpr UINT CacheIndex = 2; using Type9 = IDirect3DVolumeTexture9; }; - template <> - struct AddressCacheIndex - { static constexpr UINT CacheIndex = 3; using Type9 = IDirect3DCubeTexture9; }; - template <> - struct AddressCacheIndex - { static constexpr UINT CacheIndex = 4; using Type9 = IDirect3DVolume9; }; - template <> - struct AddressCacheIndex - { static constexpr UINT CacheIndex = 5; using Type9 = IDirect3DVertexBuffer9; }; - template <> - struct AddressCacheIndex - { static constexpr UINT CacheIndex = 6; using Type9 = IDirect3DIndexBuffer9; }; - template <> - struct AddressCacheIndex - { static constexpr UINT CacheIndex = 7; using Type9 = IDirect3DSwapChain9; }; public: @@ -54,7 +30,7 @@ class AddressLookupTable if (it != cache.end()) return static_cast(it->second); - return new T(Device, static_cast::Type9 *>(pAddress9)); + return new T(Device, static_cast::Type9 *>(pAddress9)); } template @@ -85,6 +61,31 @@ class AddressLookupTable std::unordered_map AddressCache[8]; }; +template <> +struct AddressLookupTable::AddressCacheIndex +{ static constexpr UINT CacheIndex = 0; using Type9 = IDirect3DSurface9; }; +template <> +struct AddressLookupTable::AddressCacheIndex +{ static constexpr UINT CacheIndex = 1; using Type9 = IDirect3DTexture9; }; +template <> +struct AddressLookupTable::AddressCacheIndex +{ static constexpr UINT CacheIndex = 2; using Type9 = IDirect3DVolumeTexture9; }; +template <> +struct AddressLookupTable::AddressCacheIndex +{ static constexpr UINT CacheIndex = 3; using Type9 = IDirect3DCubeTexture9; }; +template <> +struct AddressLookupTable::AddressCacheIndex +{ static constexpr UINT CacheIndex = 4; using Type9 = IDirect3DVolume9; }; +template <> +struct AddressLookupTable::AddressCacheIndex +{ static constexpr UINT CacheIndex = 5; using Type9 = IDirect3DVertexBuffer9; }; +template <> +struct AddressLookupTable::AddressCacheIndex +{ static constexpr UINT CacheIndex = 6; using Type9 = IDirect3DIndexBuffer9; }; +template <> +struct AddressLookupTable::AddressCacheIndex +{ static constexpr UINT CacheIndex = 7; using Type9 = IDirect3DSwapChain9; }; + class AddressLookupTableObject { public: