forked from ocornut/imgui
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathimgui_impl_softraster.cpp
68 lines (54 loc) · 1.56 KB
/
imgui_impl_softraster.cpp
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
65
66
67
68
#include "imgui_impl_softraster.h"
#include "../misc/softraster/softraster.h"
texture_base_t *Screen = nullptr;
bool ImGui_ImplSoftraster_Init(texture_base_t *screen)
{
if (screen != nullptr)
{
Screen = screen;
return true;
}
return false;
}
void ImGui_ImplSoftraster_Shutdown()
{
Screen = nullptr;
}
void ImGui_ImplSoftraster_NewFrame()
{
if (Screen == nullptr) return;
ImGuiIO &io = ImGui::GetIO();
io.DisplaySize.x = static_cast<float>(Screen->w);
io.DisplaySize.y = static_cast<float>(Screen->h);
}
void ImGui_ImplSoftraster_RenderDrawData(ImDrawData *draw_data)
{
if (Screen == nullptr) return;
Screen->clear();
// using pos_t = float;
using pos_t = int32_t;
switch (Screen->type)
{
case texture_type_t::ALPHA8:
renderDrawLists<pos_t>(draw_data,
*reinterpret_cast<texture_alpha8_t *>(Screen));
break;
case texture_type_t::VALUE8:
renderDrawLists<pos_t>(draw_data,
*reinterpret_cast<texture_value8_t *>(Screen));
break;
case texture_type_t::COLOR16:
renderDrawLists<pos_t>(draw_data,
*reinterpret_cast<texture_color16_t *>(Screen));
break;
case texture_type_t::COLOR24:
renderDrawLists<pos_t>(draw_data,
*reinterpret_cast<texture_color24_t *>(Screen));
break;
case texture_type_t::COLOR32:
renderDrawLists<pos_t>(draw_data,
*reinterpret_cast<texture_color32_t *>(Screen));
break;
default: return;
}
}