Last active
December 11, 2015 03:08
-
-
Save daeken/4535560 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
class IDirect3D9; | |
typedef struct { | |
void **vtable; | |
IDirect3D9 *object; | |
} COMIDirect3D9; | |
class IDirect3D9 : public IUnknown { | |
public: | |
IDirect3D9(); | |
~IDirect3D9(); | |
HRESULT RegisterSoftwareDevice(void* pInitializeFunction); | |
UINT GetAdapterCount(); | |
HRESULT GetAdapterIdentifier(UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier); | |
UINT GetAdapterModeCount(UINT Adapter, D3DFORMAT Format); | |
HRESULT EnumAdapterModes(UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE* pMode); | |
HRESULT GetAdapterDisplayMode(UINT Adapter, D3DDISPLAYMODE* pMode); | |
HRESULT CheckDeviceType(UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed); | |
HRESULT CheckDeviceFormat(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); | |
HRESULT CheckDeviceMultiSampleType(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels); | |
HRESULT CheckDepthStencilMatch(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); | |
HRESULT CheckDeviceFormatConversion(UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); | |
HRESULT GetDeviceCaps(UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps); | |
HMONITOR GetAdapterMonitor(UINT Adapter); | |
HRESULT CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface); | |
protected: | |
#ifdef WINABI | |
static HRESULT _RegisterSoftwareDevice_wrap(COMIDirect3D9 *_this, void *pInitializeFunction) { | |
HRESULT _retval = _this->object->RegisterSoftwareDevice(pInitializeFunction); | |
return _retval; | |
} | |
static UINT _GetAdapterCount_wrap(COMIDirect3D9 *_this) { | |
UINT _retval = _this->object->GetAdapterCount(); | |
return _retval; | |
} | |
static HRESULT _GetAdapterIdentifier_wrap(COMIDirect3D9 *_this, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier) { | |
HRESULT _retval = _this->object->GetAdapterIdentifier(Adapter, Flags, pIdentifier); | |
return _retval; | |
} | |
static UINT _GetAdapterModeCount_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DFORMAT Format) { | |
UINT _retval = _this->object->GetAdapterModeCount(Adapter, Format); | |
return _retval; | |
} | |
static HRESULT _EnumAdapterModes_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode) { | |
HRESULT _retval = _this->object->EnumAdapterModes(Adapter, Format, Mode, pMode); | |
return _retval; | |
} | |
static HRESULT _GetAdapterDisplayMode_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DDISPLAYMODE *pMode) { | |
HRESULT _retval = _this->object->GetAdapterDisplayMode(Adapter, pMode); | |
return _retval; | |
} | |
static HRESULT _CheckDeviceType_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed) { | |
HRESULT _retval = _this->object->CheckDeviceType(Adapter, DevType, AdapterFormat, BackBufferFormat, bWindowed); | |
return _retval; | |
} | |
static HRESULT _CheckDeviceFormat_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) { | |
HRESULT _retval = _this->object->CheckDeviceFormat(Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat); | |
return _retval; | |
} | |
static HRESULT _CheckDeviceMultiSampleType_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels) { | |
HRESULT _retval = _this->object->CheckDeviceMultiSampleType(Adapter, DeviceType, SurfaceFormat, Windowed, MultiSampleType, pQualityLevels); | |
return _retval; | |
} | |
static HRESULT _CheckDepthStencilMatch_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) { | |
HRESULT _retval = _this->object->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat); | |
return _retval; | |
} | |
static HRESULT _CheckDeviceFormatConversion_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) { | |
HRESULT _retval = _this->object->CheckDeviceFormatConversion(Adapter, DeviceType, SourceFormat, TargetFormat); | |
return _retval; | |
} | |
static HRESULT _GetDeviceCaps_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps) { | |
HRESULT _retval = _this->object->GetDeviceCaps(Adapter, DeviceType, pCaps); | |
return _retval; | |
} | |
static HMONITOR _GetAdapterMonitor_wrap(COMIDirect3D9 *_this, UINT Adapter) { | |
HMONITOR _retval = _this->object->GetAdapterMonitor(Adapter); | |
return _retval; | |
} | |
static HRESULT _CreateDevice_wrap(COMIDirect3D9 *_this, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, COMIDirect3DDevice9 **ppReturnedDeviceInterface) { | |
IDirect3DDevice9 *_ppReturnedDeviceInterface; | |
HRESULT _retval = _this->object->CreateDevice(Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, &_ppReturnedDeviceInterface); | |
*ppReturnedDeviceInterface = _ppReturnedDeviceInterface->GetCOMObject(); | |
return _retval; | |
} | |
static void *_vtable[] = { | |
_QueryInterface_wrap, | |
_AddRef_wrap, | |
_Release_wrap, | |
_RegisterSoftwareDevice_wrap, | |
_GetAdapterCount_wrap, | |
_GetAdapterIdentifier_wrap, | |
_GetAdapterModeCount_wrap, | |
_EnumAdapterModes_wrap, | |
_GetAdapterDisplayMode_wrap, | |
_CheckDeviceType_wrap, | |
_CheckDeviceFormat_wrap, | |
_CheckDeviceMultiSampleType_wrap, | |
_CheckDepthStencilMatch_wrap, | |
_CheckDeviceFormatConversion_wrap, | |
_GetDeviceCaps_wrap, | |
_GetAdapterMonitor_wrap, | |
_CreateDevice_wrap | |
}; | |
COMIDirect3D9 _comObject; | |
COMIDirect3D9 *_GetCOMObject() { | |
_comObject.vtable = _vtable; | |
_comObject.object = this; | |
return &_comObject; | |
} | |
#endif | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment