-
Notifications
You must be signed in to change notification settings - Fork 3
/
source.hpp
55 lines (44 loc) · 1.56 KB
/
source.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <includes.hpp>
HWND window_handle;
LPDIRECT3DDEVICE9 device_handle;
D3DPRESENT_PARAMETERS device_parameters;
LPDIRECT3D9 device_direct;
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
const int WINDOW_WIDTH = 1200;
const int WINDOW_HEIGHT = 800;
bool CreateDeviceD3D(HWND hWnd)
{
if ((device_direct = Direct3DCreate9(D3D_SDK_VERSION)) == NULL)
return false;
memset(&device_parameters, 0, sizeof(device_parameters));
device_parameters.Windowed = TRUE;
device_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
device_parameters.BackBufferFormat = D3DFMT_UNKNOWN;
device_parameters.EnableAutoDepthStencil = TRUE;
device_parameters.AutoDepthStencilFormat = D3DFMT_D16;
device_parameters.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
if (device_direct->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &device_parameters, &device_handle) < 0)
return false;
return true;
}
void CleanupDeviceD3D()
{
if (device_handle)
{
device_handle->Release();
device_handle = 0;
}
if (device_direct)
{
device_direct->Release();
device_direct = 0;
}
}
void ResetDevice()
{
ImGui_ImplDX9_InvalidateDeviceObjects();
device_handle->Reset(&device_parameters);
ImGui_ImplDX9_CreateDeviceObjects();
}