Skip to content

Commit b5ce1d7

Browse files
committed
new_frame,end_frame,render
1 parent 136cb33 commit b5ce1d7

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

src/imgui_stdweb.rs

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22

33
#[derive(Debug, Clone)]
44
pub struct ImguiIO{
5+
imgui_io:stdweb::Value
56
}
67

78
#[derive(Debug, Clone)]
8-
pub struct ImguiDrawData{
9+
pub struct ImDrawData{
10+
imgui_draw_data:stdweb::Value
11+
}
12+
13+
impl ImDrawData{
14+
pub fn iterate_draw_lists(&self, callback:fn(stdweb::Value)->()){
15+
js! {
16+
window.Imgui.IterateDrawLists(@{callback});
17+
};
18+
}
919
}
1020

1121
#[derive(Debug, Clone)]
@@ -26,12 +36,6 @@ impl ImDrawList{
2636
self.draw_list.Flags
2737
}
2838

29-
pub fn iterate_draw_lists(&self, callback:fn(stdweb::Value)->()){
30-
js! {
31-
window.Imgui.IterateDrawLists(@{callback});
32-
};
33-
}
34-
3539
pub fn iterate_draw_cmds(&self, callback:fn(stdweb::Value)->()){
3640
js! {
3741
window.Imgui.IterateDrawCmds(@{callback});
@@ -67,22 +71,44 @@ impl Imgui{
6771

6872
pub fn create_context(&self){
6973
js! {
70-
return window.Imgui.create_context();
74+
return window.Imgui.CreateContext();
7175
};
7276
}
7377

74-
pub fn get_io(&self) -> stdweb::Value{
78+
pub fn new_frame(&self){
79+
js! {
80+
return window.Imgui.NewFrame();
81+
};
82+
}
83+
84+
pub fn end_frame(&self){
85+
js! {
86+
return window.Imgui.EndFrame();
87+
};
88+
}
89+
90+
pub fn render(&self){
91+
js! {
92+
return window.Imgui.Render();
93+
};
94+
}
95+
96+
pub fn get_io(&self) -> ImguiIO{
7597
let ret = js! {
76-
return window.Imgui.get_io();
98+
return window.Imgui.GetIO();
7799
};
78-
ret
100+
ImguiIO{
101+
imgui_io:ret
102+
}
79103
}
80104

81-
pub fn get_draw_data(&self) -> stdweb::Value{
105+
pub fn get_draw_data(&self) -> ImDrawData{
82106
let ret = js! {
83107
return window.Imgui.GetDrawData();
84108
};
85-
ret
109+
ImguiDrawData{
110+
imgui_draw_data:ret
111+
}
86112
}
87113

88114
pub fn style_colors_dark(&self){

0 commit comments

Comments
 (0)