Forgot about dx9 (UNTESTED!!!)

This commit is contained in:
2026-03-21 14:48:48 +01:00
parent baad2ce15c
commit 6fab4a07a9
+14 -4
View File
@@ -5,11 +5,21 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <glad/glad.h> #include <glad/glad.h>
#ifdef _WIN32
#include <d3d9.h>
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h>
#endif
#include <pdsystem> #include <pdsystem>
namespace PD { namespace PD {
struct DesktopOS::Impl { struct DesktopOS::Impl {
GLFWwindow* win = nullptr; GLFWwindow* win = nullptr;
#if WIN32
IDirect3D9* d3d = nullptr;
IDirect3DDevice9* dx9_device = nullptr;
#endif
}; };
void DesktopOS::Init() { void DesktopOS::Init() {
@@ -45,21 +55,21 @@ void DesktopOS::Init() {
} }
#ifdef _WIN32 #ifdef _WIN32
if (pDriver == Driver::DirectX9) { if (pDriver == Driver::DirectX9) {
d3d = Direct3DCreate9(D3D_SDK_VERSION); impl->d3d = Direct3DCreate9(D3D_SDK_VERSION);
auto hwnd = glfwGetWin32Window(impl->win); auto hwnd = glfwGetWin32Window(impl->win);
D3DPRESENT_PARAMETERS d3dpp = {}; D3DPRESENT_PARAMETERS d3dpp = {};
d3dpp.Windowed = TRUE; d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hwnd; d3dpp.hDeviceWindow = hwnd;
HRESULT hr = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, HRESULT hr = impl->d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp,
&dx9_device); &impl->dx9_device);
if (FAILED(hr)) { if (FAILED(hr)) {
MessageBoxW(nullptr, L"Failed to create D3D9 device", L"Error", MB_OK); MessageBoxW(nullptr, L"Failed to create D3D9 device", L"Error", MB_OK);
std::abort(); std::abort();
} }
PD::Gfx::UseDriver<PD::GfxDirectX9>(dx9_device); PD::Gfx::UseDriver<PD::GfxDirectX9>(impl->dx9_device);
} }
#endif #endif
glfwSwapInterval(1); glfwSwapInterval(1);