imgui window stuff
This commit is contained in:
parent
daad058225
commit
849c85cd7a
|
@ -14,6 +14,7 @@ debug.draw_phys = false;
|
||||||
debug.draw_bb = false;
|
debug.draw_bb = false;
|
||||||
debug.draw_gizmos = false;
|
debug.draw_gizmos = false;
|
||||||
debug.draw_names = false;
|
debug.draw_names = false;
|
||||||
|
debug.sprite_nums = false;
|
||||||
debug.draw = function() {
|
debug.draw = function() {
|
||||||
if (this.draw_phys) game.all_objects(function(x) { debug.draw_gameobject(x); });
|
if (this.draw_phys) game.all_objects(function(x) { debug.draw_gameobject(x); });
|
||||||
|
|
||||||
|
|
|
@ -240,3 +240,5 @@ Mum.debug_colors = {
|
||||||
//Object.values(Mum.debug_colors).forEach(function(v) { v.a = 100; });
|
//Object.values(Mum.debug_colors).forEach(function(v) { v.a = 100; });
|
||||||
|
|
||||||
//return { Mum };
|
//return { Mum };
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -222,13 +222,28 @@ profile.print_frame_avg = function()
|
||||||
say("\n");
|
say("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cache_reporting = false;
|
||||||
|
|
||||||
var report_cache = {};
|
var report_cache = {};
|
||||||
|
|
||||||
var cachest = 0;
|
var cachest = 0;
|
||||||
var cachegroup;
|
var cachegroup;
|
||||||
var cachetitle;
|
var cachetitle;
|
||||||
|
|
||||||
|
profile.imgui = function()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.cache_reporting = function() { return cache_reporting; }
|
||||||
|
profile.cache_toggle = function() { cache_reporting = !cache_reporting; }
|
||||||
|
profile.cache_dump = function() {
|
||||||
|
report_cache = {};
|
||||||
|
}
|
||||||
|
|
||||||
profile.cache = function profile_cache(group, title)
|
profile.cache = function profile_cache(group, title)
|
||||||
{
|
{
|
||||||
|
if (!cache_reporting) return;
|
||||||
cachest = profile.now();
|
cachest = profile.now();
|
||||||
cachegroup = group;
|
cachegroup = group;
|
||||||
cachetitle = title;
|
cachetitle = title;
|
||||||
|
@ -303,11 +318,6 @@ profile.print_mem = function()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.atom_count = function()
|
|
||||||
{
|
|
||||||
// return os.dump_atoms().split(
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.print_gc = function()
|
profile.print_gc = function()
|
||||||
{
|
{
|
||||||
var gc = os.check_gc();
|
var gc = os.check_gc();
|
||||||
|
|
|
@ -567,7 +567,7 @@ render.sprites = function render_sprites(gridsize = 1)
|
||||||
render.use_mat(ss);
|
render.use_mat(ss);
|
||||||
render.make_sprite_ssbo(sparray, sprite_ssbo);
|
render.make_sprite_ssbo(sparray, sprite_ssbo);
|
||||||
render.draw(shape.quad, sprite_ssbo, sparray.length);
|
render.draw(shape.quad, sprite_ssbo, sparray.length);
|
||||||
render.text(ss.diffuse.getid(), ss.transform.pos);
|
if (debug.sprite_nums) render.text(ss.diffuse.getid(), ss.transform.pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
profile.endframe();
|
profile.endframe();
|
||||||
|
@ -998,7 +998,6 @@ prosperon.render = function()
|
||||||
profile.frame("imgui");
|
profile.frame("imgui");
|
||||||
|
|
||||||
render.imgui_new(window.size.x, window.size.y, 0.01);
|
render.imgui_new(window.size.x, window.size.y, 0.01);
|
||||||
// render.gfx_gui();
|
|
||||||
prosperon.imgui();
|
prosperon.imgui();
|
||||||
render.imgui_end();
|
render.imgui_end();
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,28 @@ var appy = {};
|
||||||
appy.inputs = {};
|
appy.inputs = {};
|
||||||
if (os.sys() === 'macos') {
|
if (os.sys() === 'macos') {
|
||||||
appy.inputs['S-q'] = os.quit;
|
appy.inputs['S-q'] = os.quit;
|
||||||
appy.inputs['S-h'] = function() { };
|
|
||||||
appy.inputs['S-g'] = os.gc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//appy.inputs.f12 = function() { mum.debug = !mum.debug; }
|
game.op_search = function()
|
||||||
|
{
|
||||||
|
if (!game.ooop) return;
|
||||||
|
game.ooop = imgui.window("operator search", _ => {
|
||||||
|
imgui.text("test");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
game.ooop = false;
|
||||||
|
|
||||||
|
//appy.inputs.f12 = function() { mum.debug = !mum.debug; }
|
||||||
|
appy.inputs['C-space'] = function() {
|
||||||
|
game.ooop = !game.ooop;
|
||||||
|
}
|
||||||
appy.inputs.f9 = function() { profile.print_mem(); }
|
appy.inputs.f9 = function() { profile.print_mem(); }
|
||||||
appy.inputs.f10 = function() { profile.toggle_frame_avg(); }
|
appy.inputs.f10 = function() { profile.toggle_frame_avg(); }
|
||||||
appy.inputs.f11 = window.toggle_fullscreen;
|
appy.inputs.f11 = window.toggle_fullscreen;
|
||||||
appy.inputs.f12 = function() { profile.cpu_frame(); }
|
appy.inputs.f11.doc = "Toggle window fullscreen.";
|
||||||
appy.inputs['M-f4'] = prosperon.quit;
|
appy.inputs.f11.title = "Toggle Fullscreen";
|
||||||
|
appy.inputs['M-f4'] = os.quit;
|
||||||
|
|
||||||
player[0].control(appy);
|
player[0].control(appy);
|
||||||
|
|
||||||
|
|
|
@ -12,40 +12,57 @@ static sgimgui_t sgimgui;
|
||||||
|
|
||||||
#include "jsffi.h"
|
#include "jsffi.h"
|
||||||
|
|
||||||
JSC_CCALL(imgui_begin,
|
JSC_SCALL(imgui_window,
|
||||||
char *title = js2strdup(argv[0]);
|
|
||||||
bool active = true;
|
bool active = true;
|
||||||
ImGui::Begin(title, &active, ImGuiWindowFlags_MenuBar);
|
ImGui::Begin(str, &active);
|
||||||
free(title);
|
script_call_sym(argv[1], 0, NULL);
|
||||||
return boolean2js(active);
|
ImGui::End();
|
||||||
|
ret = boolean2js(active);
|
||||||
|
)
|
||||||
|
JSC_SCALL(imgui_menu,
|
||||||
|
if (ImGui::BeginMenu(str)) {
|
||||||
|
script_call_sym(argv[1], 0, NULL);
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_CCALL(imgui_end, ImGui::End())
|
JSC_CCALL(imgui_menubar,
|
||||||
|
if (ImGui::BeginMenuBar()) {
|
||||||
JSC_CCALL(imgui_beginmenu,
|
script_call_sym(argv[0], 0, NULL);
|
||||||
char *title = js2strdup(argv[0]);
|
ImGui::EndMenuBar();
|
||||||
bool active = ImGui::BeginMenu(title);
|
}
|
||||||
free(title);
|
|
||||||
return boolean2js(active);
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
JSC_CCALL(imgui_mainmenubar,
|
||||||
|
if (ImGui::BeginMainMenuBar()) {
|
||||||
|
script_call_sym(argv[0], 0, NULL);
|
||||||
|
ImGui::EndMainMenuBar();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const char* imempty = "##empty";
|
||||||
|
|
||||||
JSC_CCALL(imgui_menuitem,
|
JSC_CCALL(imgui_menuitem,
|
||||||
char *name = js2strdup(argv[0]);
|
char *name = !JS_Is(argv[0]) ? imempty : js2strdup(argv[0]);
|
||||||
char *hotkey = js2strdup(argv[1]);
|
char *keyfn = JS_IsUndefined(argv[1]) ? NULL : js2strdup(argv[1]);
|
||||||
if (ImGui::MenuItem(name,hotkey))
|
bool on = JS_IsUndefined(argv[3]) ? false : js2boolean(argv[3]);
|
||||||
|
if (ImGui::MenuItem(name,keyfn, &on))
|
||||||
script_call_sym(argv[2], 0, NULL);
|
script_call_sym(argv[2], 0, NULL);
|
||||||
free(name);
|
|
||||||
free(hotkey);
|
if (name != imempty) free(name);
|
||||||
|
if (keyfn) free(keyfn);
|
||||||
|
|
||||||
|
return boolean2js(on);
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_SCALL(imgui_startplot,
|
JSC_SCALL(imgui_plot,
|
||||||
ImPlot::SetNextAxisToFit(ImAxis_X1);
|
ImPlot::SetNextAxisToFit(ImAxis_X1);
|
||||||
ImPlot::SetNextAxisToFit(ImAxis_Y1);
|
ImPlot::SetNextAxisToFit(ImAxis_Y1);
|
||||||
ImPlot::BeginPlot(str);
|
ImPlot::BeginPlot(str);
|
||||||
|
script_call_sym(argv[1], 0, NULL);
|
||||||
|
ImPlot::EndPlot();
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_CCALL(imgui_endplot, ImPlot::EndPlot() )
|
|
||||||
|
|
||||||
JSC_SCALL(imgui_lineplot,
|
JSC_SCALL(imgui_lineplot,
|
||||||
double data[js_arrlen(argv[1])];
|
double data[js_arrlen(argv[1])];
|
||||||
for (int i = 0; i < js_arrlen(argv[1]); i++)
|
for (int i = 0; i < js_arrlen(argv[1]); i++)
|
||||||
|
@ -54,9 +71,6 @@ JSC_SCALL(imgui_lineplot,
|
||||||
ImPlot::PlotLine(str, data, js_arrlen(argv[1]));
|
ImPlot::PlotLine(str, data, js_arrlen(argv[1]));
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_CCALL(imgui_beginmenubar, ImGui::BeginMenuBar())
|
|
||||||
JSC_CCALL(imgui_endmenubar, ImGui::EndMenuBar())
|
|
||||||
|
|
||||||
JSC_SSCALL(imgui_textinput,
|
JSC_SSCALL(imgui_textinput,
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
strncpy(buffer, str2, 512);
|
strncpy(buffer, str2, 512);
|
||||||
|
@ -64,17 +78,43 @@ JSC_SSCALL(imgui_textinput,
|
||||||
ret = str2js(buffer);
|
ret = str2js(buffer);
|
||||||
)
|
)
|
||||||
|
|
||||||
|
JSC_SCALL(imgui_text,
|
||||||
|
ImGui::Text(str);
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_SCALL(imgui_button,
|
||||||
|
if (ImGui::Button(str))
|
||||||
|
script_call_sym(argv[1], 0, NULL);
|
||||||
|
)
|
||||||
|
|
||||||
|
JSC_CCALL(imgui_sokol_gfx,
|
||||||
|
sgimgui_draw(&sgimgui);
|
||||||
|
if (ImGui::BeginMenu("sokol-gfx")) {
|
||||||
|
ImGui::MenuItem("Capabilities", 0, &sgimgui.caps_window.open);
|
||||||
|
ImGui::MenuItem("Frame Stats", 0, &sgimgui.frame_stats_window.open);
|
||||||
|
ImGui::MenuItem("Buffers", 0, &sgimgui.buffer_window.open);
|
||||||
|
ImGui::MenuItem("Images", 0, &sgimgui.image_window.open);
|
||||||
|
ImGui::MenuItem("Samplers", 0, &sgimgui.sampler_window.open);
|
||||||
|
ImGui::MenuItem("Shaders", 0, &sgimgui.shader_window.open);
|
||||||
|
ImGui::MenuItem("Pipelines", 0, &sgimgui.pipeline_window.open);
|
||||||
|
ImGui::MenuItem("Attachments", 0, &sgimgui.attachments_window.open);
|
||||||
|
ImGui::MenuItem("Calls", 0, &sgimgui.capture_window.open);
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
static const JSCFunctionListEntry js_imgui_funcs[] = {
|
static const JSCFunctionListEntry js_imgui_funcs[] = {
|
||||||
MIST_FUNC_DEF(imgui, begin, 1),
|
MIST_FUNC_DEF(imgui, window, 2),
|
||||||
MIST_FUNC_DEF(imgui, end,0),
|
MIST_FUNC_DEF(imgui, menu, 2),
|
||||||
MIST_FUNC_DEF(imgui, beginmenu, 1),
|
MIST_FUNC_DEF(imgui, menubar, 1),
|
||||||
|
MIST_FUNC_DEF(imgui, mainmenubar, 1),
|
||||||
MIST_FUNC_DEF(imgui, menuitem, 3),
|
MIST_FUNC_DEF(imgui, menuitem, 3),
|
||||||
MIST_FUNC_DEF(imgui, beginmenubar, 0),
|
|
||||||
MIST_FUNC_DEF(imgui, endmenubar, 0),
|
|
||||||
MIST_FUNC_DEF(imgui, textinput, 2),
|
MIST_FUNC_DEF(imgui, textinput, 2),
|
||||||
MIST_FUNC_DEF(imgui, startplot,1),
|
MIST_FUNC_DEF(imgui, button, 2),
|
||||||
MIST_FUNC_DEF(imgui,endplot,0),
|
MIST_FUNC_DEF(imgui, text, 1),
|
||||||
MIST_FUNC_DEF(imgui,lineplot,2)
|
MIST_FUNC_DEF(imgui, plot,1),
|
||||||
|
MIST_FUNC_DEF(imgui,lineplot,2),
|
||||||
|
MIST_FUNC_DEF(imgui, sokol_gfx, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int started = 0;
|
static int started = 0;
|
||||||
|
@ -111,12 +151,6 @@ void gui_newframe(int x, int y, float dt)
|
||||||
simgui_new_frame(&frame);
|
simgui_new_frame(&frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_gui()
|
|
||||||
{
|
|
||||||
sgimgui_draw(&sgimgui);
|
|
||||||
sgimgui_draw_menu(&sgimgui, "sokol-gfx");
|
|
||||||
}
|
|
||||||
|
|
||||||
void gui_endframe()
|
void gui_endframe()
|
||||||
{
|
{
|
||||||
simgui_render();
|
simgui_render();
|
||||||
|
|
|
@ -62,6 +62,8 @@ JSValue str2js(const char *c, ...) {
|
||||||
return JS_NewString(js, buf);
|
return JS_NewString(js, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int JS_Is(JSValue v) { return JS_ToBool(js, v); }
|
||||||
|
|
||||||
const char *js2str(JSValue v) {
|
const char *js2str(JSValue v) {
|
||||||
return JS_ToCString(js, v);
|
return JS_ToCString(js, v);
|
||||||
}
|
}
|
||||||
|
@ -1123,7 +1125,6 @@ JSC_CCALL(render_screencolor,
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_CCALL(render_imgui_new, gui_newframe(js2number(argv[0]),js2number(argv[1]),js2number(argv[2])); )
|
JSC_CCALL(render_imgui_new, gui_newframe(js2number(argv[0]),js2number(argv[1]),js2number(argv[2])); )
|
||||||
JSC_CCALL(render_gfx_gui, gfx_gui())
|
|
||||||
JSC_CCALL(render_imgui_end, gui_endframe())
|
JSC_CCALL(render_imgui_end, gui_endframe())
|
||||||
|
|
||||||
JSC_CCALL(render_imgui_init, return gui_init(js))
|
JSC_CCALL(render_imgui_init, return gui_init(js))
|
||||||
|
@ -1153,7 +1154,6 @@ static const JSCFunctionListEntry js_render_funcs[] = {
|
||||||
MIST_FUNC_DEF(render, setpipeline, 1),
|
MIST_FUNC_DEF(render, setpipeline, 1),
|
||||||
MIST_FUNC_DEF(render, screencolor, 0),
|
MIST_FUNC_DEF(render, screencolor, 0),
|
||||||
MIST_FUNC_DEF(render, imgui_new, 3),
|
MIST_FUNC_DEF(render, imgui_new, 3),
|
||||||
MIST_FUNC_DEF(render, gfx_gui, 0),
|
|
||||||
MIST_FUNC_DEF(render, imgui_end, 0),
|
MIST_FUNC_DEF(render, imgui_end, 0),
|
||||||
MIST_FUNC_DEF(render, imgui_init, 0),
|
MIST_FUNC_DEF(render, imgui_init, 0),
|
||||||
MIST_FUNC_DEF(render, make_t_ssbo, 2),
|
MIST_FUNC_DEF(render, make_t_ssbo, 2),
|
||||||
|
|
|
@ -12,6 +12,8 @@ extern "C" {
|
||||||
|
|
||||||
void script_report_gc_time(double t, double startmem, double mem);
|
void script_report_gc_time(double t, double startmem, double mem);
|
||||||
|
|
||||||
|
int JS_Is(JSValue v);
|
||||||
|
|
||||||
extern JSValue cpShape2js(cpShape *s);
|
extern JSValue cpShape2js(cpShape *s);
|
||||||
|
|
||||||
#define MIST_CFUNC_DEF(name, length, func1, props) { name, props, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_generic, { .generic = func1 } } } }
|
#define MIST_CFUNC_DEF(name, length, func1, props) { name, props, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_generic, { .generic = func1 } } } }
|
||||||
|
|
Loading…
Reference in a new issue