Compare commits
No commits in common. "00fa902e1f3a4fa4f71b3b78a50cb2cfcb912dcf" and "e7a3a8597bdd2e578ee25d5b05128ef8d83c6238" have entirely different histories.
00fa902e1f
...
e7a3a8597b
|
@ -159,27 +159,13 @@ JSC_CCALL(imgui_popid, ImGui::PopID(); )
|
||||||
|
|
||||||
JSC_CCALL(imgui_image,
|
JSC_CCALL(imgui_image,
|
||||||
texture *tex = js2texture(argv[0]);
|
texture *tex = js2texture(argv[0]);
|
||||||
if (!tex->simgui.id) {
|
simgui_image_desc_t simgd;
|
||||||
simgui_image_desc_t simgd;
|
simgd.image = tex->id;
|
||||||
simgd.image = tex->id;
|
simgd.sampler = std_sampler;
|
||||||
simgd.sampler = std_sampler;
|
simgui_image_t simgui_img = simgui_make_image(&simgd);
|
||||||
tex->simgui = simgui_make_image(&simgd);
|
ImTextureID tex_id = simgui_imtextureid(simgui_img);
|
||||||
}
|
ImGui::Image(tex_id, ImVec2(tex->width, tex->height), ImVec2(0,0), ImVec2(1,1));
|
||||||
|
simgui_destroy_image(simgui_img);
|
||||||
ImGui::Image(simgui_imtextureid(tex->simgui), ImVec2(tex->width, tex->height), ImVec2(0,0), ImVec2(1,1));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_SCALL(imgui_imagebutton,
|
|
||||||
texture *tex = js2texture(argv[1]);
|
|
||||||
if (!tex->simgui.id) {
|
|
||||||
simgui_image_desc_t simgd;
|
|
||||||
simgd.image = tex->id;
|
|
||||||
simgd.sampler = std_sampler;
|
|
||||||
tex->simgui = simgui_make_image(&simgd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::ImageButton(str, simgui_imtextureid(tex->simgui), ImVec2(tex->width, tex->height)))
|
|
||||||
script_call_sym(argv[2], 1, argv);
|
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_CCALL(imgui_sameline, ImGui::SameLine(js2number(argv[0])) )
|
JSC_CCALL(imgui_sameline, ImGui::SameLine(js2number(argv[0])) )
|
||||||
|
@ -375,16 +361,9 @@ JSC_SCALL(imgui_seq,
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_SCALL(imgui_sequencer,
|
JSC_SCALL(imgui_sequencer,
|
||||||
/*float start_time = js2number(js_getpropstr(argv[1], "start"));
|
int32_t current = js2number(js_getpropstr(argv[1], "current"));
|
||||||
float end_time = js2number(js_getpropstr(argv[1], "end"));
|
int32_t start = js2number(js_getpropstr(argv[1], "start"));
|
||||||
float current = js2number(js_getpropstr(argv[1], "current"));
|
int32_t end = js2number(js_getpropstr(argv[1], "end"));
|
||||||
|
|
||||||
ImVec2 timeline_size = ImGui::GetContentRegionAvail();
|
|
||||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
|
||||||
ImVec2 timeline_start = ImGui::GetCursorScreenPos();
|
|
||||||
float total_time = end_time - start_time;
|
|
||||||
float pixels_per_second = zoom * (timeline_size.x / total_time);
|
|
||||||
|
|
||||||
if(ImGui::BeginNeoSequencer(str, ¤t, &start, &end, {700,200},
|
if(ImGui::BeginNeoSequencer(str, ¤t, &start, &end, {700,200},
|
||||||
ImGuiNeoSequencerFlags_AllowLengthChanging |
|
ImGuiNeoSequencerFlags_AllowLengthChanging |
|
||||||
ImGuiNeoSequencerFlags_EnableSelection |
|
ImGuiNeoSequencerFlags_EnableSelection |
|
||||||
|
@ -396,7 +375,7 @@ JSC_SCALL(imgui_sequencer,
|
||||||
|
|
||||||
js_setpropstr(argv[1], "current", number2js(current));
|
js_setpropstr(argv[1], "current", number2js(current));
|
||||||
js_setpropstr(argv[1], "start", number2js(start));
|
js_setpropstr(argv[1], "start", number2js(start));
|
||||||
js_setpropstr(argv[1], "end", number2js(end)); */
|
js_setpropstr(argv[1], "end", number2js(end));
|
||||||
)
|
)
|
||||||
|
|
||||||
JSC_SCALL(imgui_timeline,
|
JSC_SCALL(imgui_timeline,
|
||||||
|
@ -431,100 +410,6 @@ JSC_SCALL(imgui_tlgroup,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
ImVec2 js2imvec2(JSValue v)
|
|
||||||
{
|
|
||||||
HMM_Vec2 va = js2vec2(v);
|
|
||||||
return ImVec2(va.x,va.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImVec4 js2imvec4(JSValue v)
|
|
||||||
{
|
|
||||||
HMM_Vec4 va = js2vec4(v);
|
|
||||||
return ImVec4(va.x, va.y, va.z, va.w);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImU32 js2imu32(JSValue v)
|
|
||||||
{
|
|
||||||
return ImGui::ColorConvertFloat4ToU32(js2imvec4(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_rectfilled,
|
|
||||||
ImGui::GetWindowDrawList()->AddRectFilled(js2imvec2(argv[0]), js2imvec2(argv[1]), js2imu32(argv[2]));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_line,
|
|
||||||
ImGui::GetWindowDrawList()->AddLine(js2imvec2(argv[0]), js2imvec2(argv[1]),js2imu32(argv[2]));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_cursorscreenpos,
|
|
||||||
ImVec2 v = ImGui::GetCursorScreenPos();
|
|
||||||
HMM_Vec2 va;
|
|
||||||
va.x = v.x;
|
|
||||||
va.y = v.y;
|
|
||||||
return vec22js(va);
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_setcursorscreenpos,
|
|
||||||
ImGui::SetCursorScreenPos(js2imvec2(argv[0]));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_contentregionavail,
|
|
||||||
ImVec2 v = ImGui::GetContentRegionAvail();
|
|
||||||
HMM_Vec2 va;
|
|
||||||
va.x = v.x;
|
|
||||||
va.y = v.y;
|
|
||||||
return vec22js(va);
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_beziercubic,
|
|
||||||
ImGui::GetWindowDrawList()->AddBezierCubic(js2imvec2(argv[0]), js2imvec2(argv[1]), js2imvec2(argv[2]), js2imvec2(argv[3]), js2imu32(argv[4]), js2number(argv[5]));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_bezierquad,
|
|
||||||
ImGui::GetWindowDrawList()->AddBezierQuadratic(js2imvec2(argv[0]), js2imvec2(argv[1]), js2imvec2(argv[2]), js2imu32(argv[3]), js2number(argv[4]));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_SCALL(imgui_drawtext,
|
|
||||||
ImGui::GetWindowDrawList()->AddText(js2imvec2(argv[1]), js2imu32(argv[2]), str);
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_rect,
|
|
||||||
ImGui::GetWindowDrawList()->AddRect(js2imvec2(argv[0]), js2imvec2(argv[1]), js2imu32(argv[2]));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_mousehoveringrect,
|
|
||||||
return boolean2js(ImGui::IsMouseHoveringRect(js2imvec2(argv[0]), js2imvec2(argv[1])));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_mouseclicked,
|
|
||||||
return boolean2js(ImGui::IsMouseClicked(js2number(argv[0])));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_mousedown,
|
|
||||||
return boolean2js(ImGui::IsMouseDown(js2number(argv[0])));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_mousereleased,
|
|
||||||
return boolean2js(ImGui::IsMouseReleased(js2number(argv[0])));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_mousedragging,
|
|
||||||
return boolean2js(ImGui::IsMouseDragging(js2number(argv[0])));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_mousedelta,
|
|
||||||
ImVec2 dm = ImGui::GetIO().MouseDelta;
|
|
||||||
return vec22js((HMM_Vec2){dm.x,dm.y});
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_CCALL(imgui_dummy,
|
|
||||||
ImGui::Dummy(js2imvec2(argv[0]));
|
|
||||||
)
|
|
||||||
|
|
||||||
JSC_SCALL(imgui_invisiblebutton,
|
|
||||||
ImGui::InvisibleButton(str, js2imvec2(argv[1]));
|
|
||||||
)
|
|
||||||
|
|
||||||
static const JSCFunctionListEntry js_imgui_funcs[] = {
|
static const JSCFunctionListEntry js_imgui_funcs[] = {
|
||||||
MIST_FUNC_DEF(imgui, window, 2),
|
MIST_FUNC_DEF(imgui, window, 2),
|
||||||
MIST_FUNC_DEF(imgui, menu, 2),
|
MIST_FUNC_DEF(imgui, menu, 2),
|
||||||
|
@ -538,7 +423,6 @@ static const JSCFunctionListEntry js_imgui_funcs[] = {
|
||||||
MIST_FUNC_DEF(imgui, menuitem, 3),
|
MIST_FUNC_DEF(imgui, menuitem, 3),
|
||||||
MIST_FUNC_DEF(imgui, radio, 2),
|
MIST_FUNC_DEF(imgui, radio, 2),
|
||||||
MIST_FUNC_DEF(imgui, image, 1),
|
MIST_FUNC_DEF(imgui, image, 1),
|
||||||
MIST_FUNC_DEF(imgui, imagebutton, 2),
|
|
||||||
MIST_FUNC_DEF(imgui, textinput, 2),
|
MIST_FUNC_DEF(imgui, textinput, 2),
|
||||||
MIST_FUNC_DEF(imgui, textbox, 2),
|
MIST_FUNC_DEF(imgui, textbox, 2),
|
||||||
MIST_FUNC_DEF(imgui, button, 2),
|
MIST_FUNC_DEF(imgui, button, 2),
|
||||||
|
@ -575,23 +459,6 @@ static const JSCFunctionListEntry js_imgui_funcs[] = {
|
||||||
MIST_FUNC_DEF(imgui, timeline, 3),
|
MIST_FUNC_DEF(imgui, timeline, 3),
|
||||||
MIST_FUNC_DEF(imgui, tlgroup, 2),
|
MIST_FUNC_DEF(imgui, tlgroup, 2),
|
||||||
MIST_FUNC_DEF(imgui, seq, 3),
|
MIST_FUNC_DEF(imgui, seq, 3),
|
||||||
MIST_FUNC_DEF(imgui, mousehoveringrect, 2),
|
|
||||||
MIST_FUNC_DEF(imgui, mouseclicked, 1),
|
|
||||||
MIST_FUNC_DEF(imgui, mousedown, 1),
|
|
||||||
MIST_FUNC_DEF(imgui, mousereleased, 1),
|
|
||||||
MIST_FUNC_DEF(imgui, mousedragging, 1),
|
|
||||||
MIST_FUNC_DEF(imgui, mousedelta, 0),
|
|
||||||
MIST_FUNC_DEF(imgui, rect, 3),
|
|
||||||
MIST_FUNC_DEF(imgui, rectfilled, 3),
|
|
||||||
MIST_FUNC_DEF(imgui, line, 3),
|
|
||||||
MIST_FUNC_DEF(imgui, bezierquad, 5),
|
|
||||||
MIST_FUNC_DEF(imgui, beziercubic, 6),
|
|
||||||
MIST_FUNC_DEF(imgui, drawtext, 3),
|
|
||||||
MIST_FUNC_DEF(imgui, cursorscreenpos, 0),
|
|
||||||
MIST_FUNC_DEF(imgui, setcursorscreenpos, 1),
|
|
||||||
MIST_FUNC_DEF(imgui, contentregionavail, 0),
|
|
||||||
MIST_FUNC_DEF(imgui, dummy, 1),
|
|
||||||
MIST_FUNC_DEF(imgui, invisiblebutton, 2),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int started = 0;
|
static int started = 0;
|
||||||
|
|
|
@ -139,7 +139,6 @@ void ffi_load();
|
||||||
|
|
||||||
JSValue vec22js(HMM_Vec2 v);
|
JSValue vec22js(HMM_Vec2 v);
|
||||||
HMM_Vec2 js2vec2(JSValue v);
|
HMM_Vec2 js2vec2(JSValue v);
|
||||||
HMM_Vec4 js2vec4(JSValue v);
|
|
||||||
|
|
||||||
const char *js2str(JSValue v);
|
const char *js2str(JSValue v);
|
||||||
char *js2strdup(JSValue v);
|
char *js2strdup(JSValue v);
|
||||||
|
@ -149,7 +148,6 @@ cpBitmask js2bitmask(JSValue v);
|
||||||
int js_print_exception(JSValue v);
|
int js_print_exception(JSValue v);
|
||||||
|
|
||||||
struct rgba js2color(JSValue v);
|
struct rgba js2color(JSValue v);
|
||||||
|
|
||||||
double js2number(JSValue v);
|
double js2number(JSValue v);
|
||||||
JSValue number2js(double g);
|
JSValue number2js(double g);
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,8 @@ struct texture *texture_from_file(const char *path) {
|
||||||
for (int i = 1; i < mips; i++)
|
for (int i = 1; i < mips; i++)
|
||||||
free(mipdata[i]);
|
free(mipdata[i]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,8 +174,6 @@ void texture_free(texture *tex)
|
||||||
free(tex->data);
|
free(tex->data);
|
||||||
if (tex->delays) arrfree(tex->delays);
|
if (tex->delays) arrfree(tex->delays);
|
||||||
sg_destroy_image(tex->id);
|
sg_destroy_image(tex->id);
|
||||||
if (tex->simgui.id)
|
|
||||||
simgui_destroy_image(tex->simgui);
|
|
||||||
free(tex);
|
free(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
#include "HandmadeMath.h"
|
#include "HandmadeMath.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
#include "sokol_app.h"
|
|
||||||
#include "sokol/util/sokol_imgui.h"
|
|
||||||
|
|
||||||
#define TEX_SPEC 0
|
#define TEX_SPEC 0
|
||||||
#define TEX_NORM 1
|
#define TEX_NORM 1
|
||||||
#define TEX_HEIGHT 2
|
#define TEX_HEIGHT 2
|
||||||
|
@ -21,8 +18,8 @@ extern struct rect ST_UNIT;
|
||||||
|
|
||||||
/* Represents an actual texture on the GPU */
|
/* Represents an actual texture on the GPU */
|
||||||
struct texture {
|
struct texture {
|
||||||
sg_image id; /* ID reference for the GPU memory location of the texture */
|
sg_image id; /* ID reference for the GPU memory location of the
|
||||||
simgui_image_t simgui;
|
texture */
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
Loading…
Reference in a new issue