mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-18 02:52:47 +03:00
feat(gx): add window creation to d3d backend
This commit is contained in:
parent
2010aa8e4e
commit
80388f0279
@ -78,6 +78,10 @@ void CGxDevice::Log(const char* format, ...) {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGxDevice::Log(const CGxFormat& format) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(WHOA_SYSTEM_WIN)
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
CGxDevice* CGxDevice::NewD3d() {
|
CGxDevice* CGxDevice::NewD3d() {
|
||||||
auto m = SMemAlloc(sizeof(CGxDeviceD3d), __FILE__, __LINE__, 0x0);
|
auto m = SMemAlloc(sizeof(CGxDeviceD3d), __FILE__, __LINE__, 0x0);
|
||||||
|
@ -47,6 +47,7 @@ class CGxDevice {
|
|||||||
|
|
||||||
// Static functions
|
// Static functions
|
||||||
static void Log(const char* format, ...);
|
static void Log(const char* format, ...);
|
||||||
|
static void Log(const CGxFormat& format);
|
||||||
#if defined(WHOA_SYSTEM_WIN)
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
static CGxDevice* NewD3d();
|
static CGxDevice* NewD3d();
|
||||||
static CGxDevice* NewD3d9Ex();
|
static CGxDevice* NewD3d9Ex();
|
||||||
|
@ -27,6 +27,7 @@ class CGxFormat {
|
|||||||
uint32_t sampleCount;
|
uint32_t sampleCount;
|
||||||
Format colorFormat;
|
Format colorFormat;
|
||||||
uint32_t refreshRate;
|
uint32_t refreshRate;
|
||||||
|
C2iVector pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@ ATOM WindowClassCreate() {
|
|||||||
wc.style = CS_OWNDC;
|
wc.style = CS_OWNDC;
|
||||||
wc.lpfnWndProc = CGxDeviceD3d::WindowProcD3d;
|
wc.lpfnWndProc = CGxDeviceD3d::WindowProcD3d;
|
||||||
wc.hInstance = instance;
|
wc.hInstance = instance;
|
||||||
wc.lpszClassName = "GxWindowClassD3d";
|
wc.lpszClassName = TEXT("GxWindowClassD3d");
|
||||||
|
|
||||||
wc.hIcon = static_cast<HICON>(LoadImage(instance, TEXT("BlizzardIcon.ico"), 1u, 0, 0, 0x40));
|
wc.hIcon = static_cast<HICON>(LoadImage(instance, TEXT("BlizzardIcon.ico"), 1u, 0, 0, 0x40));
|
||||||
wc.hCursor = LoadCursor(instance, TEXT("BlizzardCursor.cur"));
|
wc.hCursor = LoadCursor(instance, TEXT("BlizzardCursor.cur"));
|
||||||
@ -62,7 +62,8 @@ void CGxDeviceD3d::IUnloadD3dLib(HINSTANCE& d3dLib, LPDIRECT3D9& d3d) {
|
|||||||
|
|
||||||
LRESULT CGxDeviceD3d::WindowProcD3d(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
LRESULT CGxDeviceD3d::WindowProcD3d(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
|
||||||
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGxDeviceD3d::CapsWindowSize(CRect& dst) {
|
void CGxDeviceD3d::CapsWindowSize(CRect& dst) {
|
||||||
@ -96,6 +97,41 @@ int32_t CGxDeviceD3d::DeviceCreate(long (*windowProc)(void*, uint32_t, uint32_t,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t CGxDeviceD3d::DeviceSetFormat(const CGxFormat& format) {
|
||||||
|
CGxDevice::Log("CGxDeviceD3d::DeviceSetFormat():");
|
||||||
|
CGxDevice::Log(format);
|
||||||
|
|
||||||
|
if (this->m_hwnd) {
|
||||||
|
ShowWindow(this->m_hwnd, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
if (this->m_hwnd) {
|
||||||
|
DestroyWindow(this->m_hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_hwnd = nullptr;
|
||||||
|
|
||||||
|
this->m_format = format;
|
||||||
|
|
||||||
|
CGxFormat createFormat = format;
|
||||||
|
|
||||||
|
if (this->ICreateWindow(createFormat) && this->ICreateD3dDevice(createFormat) && this->CGxDevice::DeviceSetFormat(format)) {
|
||||||
|
this->m_context = 1;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
if (this->m_format.window == 0) {
|
||||||
|
RECT windowRect;
|
||||||
|
GetWindowRect(this->m_hwnd, &windowRect);
|
||||||
|
ClipCursor(&windowRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t CGxDeviceD3d::ICreateD3d() {
|
int32_t CGxDeviceD3d::ICreateD3d() {
|
||||||
if (CGxDeviceD3d::ILoadD3dLib(this->m_d3dLib, this->m_d3d) && this->m_d3d->GetDeviceCaps(0, D3DDEVTYPE_HAL, &this->m_d3dCaps) >= S_OK) {
|
if (CGxDeviceD3d::ILoadD3dLib(this->m_d3dLib, this->m_d3d) && this->m_d3d->GetDeviceCaps(0, D3DDEVTYPE_HAL, &this->m_d3dCaps) >= S_OK) {
|
||||||
if (this->m_desktopDisplayMode.Format != D3DFMT_UNKNOWN) {
|
if (this->m_desktopDisplayMode.Format != D3DFMT_UNKNOWN) {
|
||||||
@ -118,6 +154,56 @@ int32_t CGxDeviceD3d::ICreateD3d() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t CGxDeviceD3d::ICreateD3dDevice(const CGxFormat& format) {
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CGxDeviceD3d::ICreateWindow(CGxFormat& format) {
|
||||||
|
auto instance = GetModuleHandle(nullptr);
|
||||||
|
|
||||||
|
DWORD dwStyle;
|
||||||
|
if (format.window == 0) {
|
||||||
|
dwStyle = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU;
|
||||||
|
} else if (format.maximize == 1) {
|
||||||
|
dwStyle = WS_POPUP | WS_VISIBLE;
|
||||||
|
} else if (format.maximize == 2) {
|
||||||
|
dwStyle = WS_POPUP;
|
||||||
|
} else {
|
||||||
|
dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
int32_t width = format.size.x ? format.size.x : CW_USEDEFAULT;
|
||||||
|
int32_t height = format.size.y ? format.size.y : CW_USEDEFAULT;
|
||||||
|
|
||||||
|
if (format.window && format.maximize != 1 && format.size.x && format.size.y) {
|
||||||
|
// TODO adjust width and height
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_hwnd = CreateWindowEx(
|
||||||
|
WS_EX_APPWINDOW,
|
||||||
|
TEXT("GxWindowClassD3d"),
|
||||||
|
TEXT("World of Warcraft"),
|
||||||
|
dwStyle,
|
||||||
|
format.pos.x,
|
||||||
|
format.pos.y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
instance,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this->m_hwnd && format.maximize != 2) {
|
||||||
|
ShowWindow(this->m_hwnd, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->m_hwnd != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void CGxDeviceD3d::IDestroyD3d() {
|
void CGxDeviceD3d::IDestroyD3d() {
|
||||||
this->IDestroyD3dDevice();
|
this->IDestroyD3dDevice();
|
||||||
CGxDeviceD3d::IUnloadD3dLib(this->m_d3dLib, this->m_d3d);
|
CGxDeviceD3d::IUnloadD3dLib(this->m_d3dLib, this->m_d3d);
|
||||||
|
@ -14,6 +14,7 @@ class CGxDeviceD3d : public CGxDevice {
|
|||||||
static LRESULT WindowProcD3d(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
static LRESULT WindowProcD3d(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
|
HWND m_hwnd;
|
||||||
ATOM m_hwndClass;
|
ATOM m_hwndClass;
|
||||||
int32_t m_ownhwnd;
|
int32_t m_ownhwnd;
|
||||||
HINSTANCE m_d3dLib;
|
HINSTANCE m_d3dLib;
|
||||||
@ -26,6 +27,7 @@ class CGxDeviceD3d : public CGxDevice {
|
|||||||
virtual void ITexMarkAsUpdated(CGxTex* texId);
|
virtual void ITexMarkAsUpdated(CGxTex* texId);
|
||||||
virtual void IRsSendToHw(EGxRenderState rs);
|
virtual void IRsSendToHw(EGxRenderState rs);
|
||||||
virtual int32_t DeviceCreate(long (*windowProc)(void*, uint32_t, uint32_t, long), const CGxFormat& format);
|
virtual int32_t DeviceCreate(long (*windowProc)(void*, uint32_t, uint32_t, long), const CGxFormat& format);
|
||||||
|
virtual int32_t DeviceSetFormat(const CGxFormat& format);
|
||||||
virtual void CapsWindowSize(CRect& dst);
|
virtual void CapsWindowSize(CRect& dst);
|
||||||
virtual void CapsWindowSizeInScreenCoords(CRect& dst);
|
virtual void CapsWindowSizeInScreenCoords(CRect& dst);
|
||||||
virtual void PoolSizeSet(CGxPool* pool, uint32_t size);
|
virtual void PoolSizeSet(CGxPool* pool, uint32_t size);
|
||||||
@ -34,6 +36,8 @@ class CGxDeviceD3d : public CGxDevice {
|
|||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
int32_t ICreateD3d();
|
int32_t ICreateD3d();
|
||||||
|
int32_t ICreateD3dDevice(const CGxFormat& format);
|
||||||
|
bool ICreateWindow(CGxFormat& format);
|
||||||
void IDestroyD3d();
|
void IDestroyD3d();
|
||||||
void IDestroyD3dDevice();
|
void IDestroyD3dDevice();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user