diff --git a/CMakeLists.txt b/CMakeLists.txt
index a687b91ede..5f7d160ece 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -980,6 +980,7 @@ add_library(native STATIC
ext/native/profiler/profiler.h
ext/native/thin3d/thin3d.cpp
ext/native/thin3d/thin3d.h
+ ext/native/thin3d/thin3d_create.h
${THIN3D_PLATFORMS}
ext/native/thread/executor.cpp
ext/native/thread/executor.h
diff --git a/Common/CommonWindows.h b/Common/CommonWindows.h
index 255cd441db..bacd41cb5f 100644
--- a/Common/CommonWindows.h
+++ b/Common/CommonWindows.h
@@ -14,4 +14,5 @@
#undef min
#undef max
-#endif
\ No newline at end of file
+#undef DrawText
+#endif
diff --git a/Core/Core.cpp b/Core/Core.cpp
index 450ea97595..a65c17e944 100644
--- a/Core/Core.cpp
+++ b/Core/Core.cpp
@@ -37,6 +37,7 @@
#include "Common/GraphicsContext.h"
#ifdef _WIN32
+#include "Common/CommonWindows.h"
#include "Windows/InputDevice.h"
#endif
diff --git a/Qt/QtMain.h b/Qt/QtMain.h
index 191dd320ec..7f67794487 100644
--- a/Qt/QtMain.h
+++ b/Qt/QtMain.h
@@ -39,6 +39,7 @@ QTM_USE_NAMESPACE
#include "Core/Core.h"
#include "Core/Config.h"
#include "Core/System.h"
+#include "thin3d/thin3d_create.h"
#include "thin3d/GLRenderManager.h"
// Input
diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp
index b6d25ae126..c499a90392 100644
--- a/UI/DevScreens.cpp
+++ b/UI/DevScreens.cpp
@@ -42,6 +42,7 @@
#include "UI/GameSettingsScreen.h"
#ifdef _WIN32
+#include "Common/CommonWindows.h"
// Want to avoid including the full header here as it includes d3dx.h
int GetD3DXVersion();
#endif
diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp
index b8ec01bd4b..e42ddd2eed 100644
--- a/Windows/GPU/D3D11Context.cpp
+++ b/Windows/GPU/D3D11Context.cpp
@@ -14,6 +14,7 @@
#include "Windows/GPU/D3D11Context.h"
#include "Windows/W32Util/Misc.h"
#include "thin3d/thin3d.h"
+#include "thin3d/thin3d_create.h"
#include "thin3d/d3d11_loader.h"
#if PPSSPP_PLATFORM(UWP)
diff --git a/Windows/GPU/D3D9Context.cpp b/Windows/GPU/D3D9Context.cpp
index 19f772fb91..ad71c0a48d 100644
--- a/Windows/GPU/D3D9Context.cpp
+++ b/Windows/GPU/D3D9Context.cpp
@@ -14,6 +14,7 @@
#include "Windows/GPU/D3D9Context.h"
#include "Windows/W32Util/Misc.h"
#include "thin3d/thin3d.h"
+#include "thin3d/thin3d_create.h"
#include "thin3d/d3dx9_loader.h"
void D3D9Context::SwapBuffers() {
diff --git a/Windows/GPU/WindowsGLContext.cpp b/Windows/GPU/WindowsGLContext.cpp
index b5dfc831d0..7bed8d1e69 100644
--- a/Windows/GPU/WindowsGLContext.cpp
+++ b/Windows/GPU/WindowsGLContext.cpp
@@ -21,6 +21,7 @@
#include "gfx/gl_common.h"
#include "gfx/gl_debug_log.h"
#include "gfx_es2/gpu_features.h"
+#include "thin3d/thin3d_create.h"
#include "thin3d/GLRenderManager.h"
#include "GL/gl.h"
#include "GL/wglew.h"
diff --git a/Windows/GPU/WindowsVulkanContext.cpp b/Windows/GPU/WindowsVulkanContext.cpp
index 67e6f51954..0e71ace543 100644
--- a/Windows/GPU/WindowsVulkanContext.cpp
+++ b/Windows/GPU/WindowsVulkanContext.cpp
@@ -58,6 +58,7 @@
#include "base/stringutil.h"
#include "thin3d/thin3d.h"
+#include "thin3d/thin3d_create.h"
#include "thin3d/VulkanRenderManager.h"
#include "util/text/parsers.h"
#include "Windows/GPU/WindowsVulkanContext.h"
diff --git a/android/jni/AndroidEGLContext.cpp b/android/jni/AndroidEGLContext.cpp
index 68438cce21..1a40994cf7 100644
--- a/android/jni/AndroidEGLContext.cpp
+++ b/android/jni/AndroidEGLContext.cpp
@@ -2,6 +2,7 @@
#include "base/logging.h"
#include "base/NativeApp.h"
#include "gfx_es2/gpu_features.h"
+#include "thin3d/thin3d_create.h"
#include "AndroidEGLContext.h"
#include "GL/GLInterface/EGLAndroid.h"
diff --git a/android/jni/AndroidJavaGLContext.h b/android/jni/AndroidJavaGLContext.h
index 44f062bd78..7b47f58f3c 100644
--- a/android/jni/AndroidJavaGLContext.h
+++ b/android/jni/AndroidJavaGLContext.h
@@ -6,6 +6,7 @@
#include "AndroidGraphicsContext.h"
#include "thin3d/GLRenderManager.h"
+#include "thin3d/thin3d_create.h"
// Doesn't do much. Just to fit in.
class AndroidJavaEGLGraphicsContext : public AndroidGraphicsContext {
diff --git a/android/jni/AndroidVulkanContext.cpp b/android/jni/AndroidVulkanContext.cpp
index b067d7f533..04481b3377 100644
--- a/android/jni/AndroidVulkanContext.cpp
+++ b/android/jni/AndroidVulkanContext.cpp
@@ -6,6 +6,7 @@
#include "Common/Vulkan/VulkanLoader.h"
#include "Common/Vulkan/VulkanContext.h"
#include "thin3d/VulkanRenderManager.h"
+#include "thin3d/thin3d_create.h"
#include "util/text/parsers.h"
#include "Core/Config.h"
#include "Core/System.h"
diff --git a/ext/native/gfx_es2/draw_buffer.h b/ext/native/gfx_es2/draw_buffer.h
index 2734d065b2..e797152554 100644
--- a/ext/native/gfx_es2/draw_buffer.h
+++ b/ext/native/gfx_es2/draw_buffer.h
@@ -11,8 +11,6 @@
#include "math/lin/matrix4x4.h"
#include "thin3d/thin3d.h"
-#undef DrawText
-
struct Atlas;
enum {
diff --git a/ext/native/native.vcxproj b/ext/native/native.vcxproj
index ebb1517ea2..8d43e4329d 100644
--- a/ext/native/native.vcxproj
+++ b/ext/native/native.vcxproj
@@ -243,6 +243,7 @@
+
@@ -766,4 +767,4 @@
-
+
\ No newline at end of file
diff --git a/ext/native/native.vcxproj.filters b/ext/native/native.vcxproj.filters
index e0507e183a..aecf223674 100644
--- a/ext/native/native.vcxproj.filters
+++ b/ext/native/native.vcxproj.filters
@@ -338,6 +338,9 @@
thin3d
+
+ thin3d
+
diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h
index cbd46e2d4a..d4f4134e65 100644
--- a/ext/native/thin3d/thin3d.h
+++ b/ext/native/thin3d/thin3d.h
@@ -6,7 +6,7 @@
#pragma once
-#include
+#include
#include
#include
#include
@@ -16,26 +16,6 @@
class Matrix4x4;
-#ifdef _WIN32
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-#define WIN32_LEAN_AND_MEAN
-#include
-#include
-struct IDirect3DDevice9;
-struct IDirect3D9;
-struct IDirect3DDevice9Ex;
-struct IDirect3D9Ex;
-struct ID3D11Device;
-struct ID3D11DeviceContext;
-struct ID3D11Device1;
-struct ID3D11DeviceContext1;
-
-#endif
-
-class VulkanContext;
-
namespace Draw {
// Useful in UBOs
@@ -664,17 +644,8 @@ protected:
int targetHeight_;
};
-DrawContext *T3DCreateGLContext();
-
extern const UniformBufferDesc UBPresetDesc;
-#ifdef _WIN32
-DrawContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx);
-DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, ID3D11Device1 *device1, ID3D11DeviceContext1 *context1, D3D_FEATURE_LEVEL featureLevel, HWND hWnd);
-#endif
-
-DrawContext *T3DCreateVulkanContext(VulkanContext *context, bool split);
-
// UBs for the preset shaders
struct VsTexColUB {
diff --git a/ext/native/thin3d/thin3d_create.h b/ext/native/thin3d/thin3d_create.h
new file mode 100644
index 0000000000..3d4ea0f1a4
--- /dev/null
+++ b/ext/native/thin3d/thin3d_create.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "thin3d/thin3d.h"
+
+// Separated this stuff into its own file so we don't get Windows.h included if all we want is the thin3d declarations.
+
+#ifdef _WIN32
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+#define WIN32_LEAN_AND_MEAN
+#include
+#include
+struct IDirect3DDevice9;
+struct IDirect3D9;
+struct IDirect3DDevice9Ex;
+struct IDirect3D9Ex;
+struct ID3D11Device;
+struct ID3D11DeviceContext;
+struct ID3D11Device1;
+struct ID3D11DeviceContext1;
+
+#endif
+
+class VulkanContext;
+
+namespace Draw {
+
+DrawContext *T3DCreateGLContext();
+
+#ifdef _WIN32
+DrawContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx);
+DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, ID3D11Device1 *device1, ID3D11DeviceContext1 *context1, D3D_FEATURE_LEVEL featureLevel, HWND hWnd);
+#endif
+
+DrawContext *T3DCreateVulkanContext(VulkanContext *context, bool split);
+
+} // namespace Draw
diff --git a/headless/SDLHeadlessHost.cpp b/headless/SDLHeadlessHost.cpp
index 17026f7fca..ed60e409d9 100644
--- a/headless/SDLHeadlessHost.cpp
+++ b/headless/SDLHeadlessHost.cpp
@@ -36,6 +36,7 @@
#include "gfx_es2/gpu_features.h"
#include "file/vfs.h"
#include "file/zip_read.h"
+#include "thin3d/thin3d_create.h"
const bool WINDOW_VISIBLE = false;
const int WINDOW_WIDTH = 480;
diff --git a/ios/ViewController.mm b/ios/ViewController.mm
index 9551f6a453..4f7dcaad16 100644
--- a/ios/ViewController.mm
+++ b/ios/ViewController.mm
@@ -16,6 +16,7 @@
#include "net/resolve.h"
#include "ui/screen.h"
#include "thin3d/thin3d.h"
+#include "thin3d/thin3d_create.h"
#include "thin3d/GLRenderManager.h"
#include "input/keycodes.h"
#include "gfx_es2/gpu_features.h"