-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimgui_impl_dxlib.hpp
More file actions
64 lines (57 loc) · 1.91 KB
/
imgui_impl_dxlib.hpp
File metadata and controls
64 lines (57 loc) · 1.91 KB
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
56
57
58
59
60
61
62
63
64
#pragma once
#include "imgui.h"
#include "imgui_impl_dx9.h"
#include "imgui_impl_dx11.h"
#include "imgui_impl_win32.h"
#include <DxLib.h>
#include <exception>
// Win32 message handler
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
int GetUseDxLibDirect3DVersion() {
switch (DxLib::GetUseDirect3DVersion()) {
case DX_DIRECT3D_9:
case DX_DIRECT3D_9EX:
return 9;
case DX_DIRECT3D_11:
return 11;
case DX_DIRECT3D_NONE:
default:
//return -1;
throw std::exception("Can't get DxLib Direct3D Version");
}
}
bool ImGui_ImplDXlib_Init() {
ImGui_ImplWin32_Init(DxLib::GetMainWindowHandle());
switch (GetUseDxLibDirect3DVersion()) {
case 9: {
auto d = static_cast<IDirect3DDevice9*>(const_cast<void*>(GetUseDirect3DDevice9()));
return ImGui_ImplDX9_Init(d);
}
case 11: {
auto d = static_cast<ID3D11Device*>(const_cast<void*>(GetUseDirect3D11Device()));
auto dc = static_cast<ID3D11DeviceContext*>(const_cast<void*>(GetUseDirect3D11DeviceContext()));
return ImGui_ImplDX11_Init(d, dc);
}
}
return false;
}
void ImGui_ImplDXlib_NewFrame() {
switch (GetUseDxLibDirect3DVersion()) {
case 9: ImGui_ImplDX9_NewFrame(); break;
case 11: ImGui_ImplDX11_NewFrame(); break;
}
ImGui_ImplWin32_NewFrame();
}
void ImGui_ImplDXlib_RenderDrawData() {
switch (GetUseDxLibDirect3DVersion()) {
case 9: ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); return;
case 11: ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); return;
}
}
void ImGui_ImplDXlib_Shutdown() {
switch (GetUseDxLibDirect3DVersion()) {
case 9: ImGui_ImplDX9_Shutdown(); break;
case 11: ImGui_ImplDX11_Shutdown(); break;
}
ImGui_ImplWin32_Shutdown();
}