Nuklear bindings
This commit is contained in:
parent
63eb212dcd
commit
4eeb16ec48
|
@ -368,6 +368,8 @@ void phys2d_applycircle(struct phys2d_circle *circle)
|
|||
float s = go->scale;
|
||||
cpVect offset = { circle->offset[0] * s, circle->offset[1] * s };
|
||||
|
||||
YughInfo("Setting radius to %g ...", radius);
|
||||
|
||||
cpCircleShapeSetRadius(circle->shape.shape, radius);
|
||||
cpCircleShapeSetOffset(circle->shape.shape, offset);
|
||||
cpBodySetMoment(go->body, cpMomentForCircle(go->mass, 0, radius, offset));
|
||||
|
|
|
@ -63,6 +63,34 @@ duk_ret_t duk_gui_img(duk_context *duk) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
duk_ret_t duk_nuke(duk_context *duk)
|
||||
{
|
||||
int cmd = duk_to_int(duk, 0);
|
||||
float editnum;
|
||||
|
||||
switch(cmd) {
|
||||
case 0:
|
||||
nuke_begin_win(duk_to_string(duk, 1));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
nuke_stop();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
editnum = duk_to_number(duk, 2);
|
||||
nuke_property_float(duk_to_string(duk, 1), 0.f, &editnum, 100.f, 0.01f, 0.01f);
|
||||
duk_push_number(duk, editnum);
|
||||
return 1;
|
||||
|
||||
case 3:
|
||||
nuke_nel(duk_to_number(duk, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
duk_ret_t duk_win_make(duk_context *duk) {
|
||||
const char *title = duk_to_string(duk, 0);
|
||||
int w = duk_to_int(duk, 1);
|
||||
|
@ -246,6 +274,10 @@ duk_ret_t duk_register(duk_context *duk) {
|
|||
case 2:
|
||||
register_gui(c);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
register_nk_gui(c);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -504,6 +536,20 @@ duk_ret_t duk_make_circle2d(duk_context *duk) {
|
|||
|
||||
duk_ret_t duk_cmd_circle2d(duk_context *duk)
|
||||
{
|
||||
int cmd = duk_to_int(duk, 0);
|
||||
struct phys2d_circle *circle = duk_to_pointer(duk, 1);
|
||||
|
||||
YughInfo("DOING CIRCLE CMD");
|
||||
|
||||
switch(cmd) {
|
||||
case 0:
|
||||
circle->radius = duk_to_number(duk, 2);
|
||||
phys2d_applycircle(circle);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -553,6 +599,7 @@ duk_ret_t duk_make_timer(duk_context *duk) {
|
|||
void ffi_load()
|
||||
{
|
||||
DUK_FUNC(yughlog, 4);
|
||||
DUK_FUNC(nuke, DUK_VARARGS);
|
||||
DUK_FUNC(make_gameobject, 7);
|
||||
DUK_FUNC(set_body, 3);
|
||||
DUK_FUNC(q_body, 2);
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#define NK_GLFW_GL3_IMPLEMENTATION
|
||||
#define NK_KEYSTATE_BASED_INPUT
|
||||
|
||||
|
||||
#include "nuke.h"
|
||||
#include "nuklear_glfw_gl3.h"
|
||||
|
||||
|
@ -33,7 +32,7 @@ void nuke_init(struct window *win) {
|
|||
|
||||
struct nk_font_atlas *atlas;
|
||||
nk_glfw3_font_stash_begin(&nkglfw, &atlas);
|
||||
struct nk_font *noto = nk_font_atlas_add_from_file(atlas, "fonts/notosans.tff", 14, 0);
|
||||
struct nk_font *noto = nk_font_atlas_add_from_file(atlas, "fonts/teenytinypixels.tff", 14, 0);
|
||||
nk_glfw3_font_stash_end(&nkglfw);
|
||||
}
|
||||
|
||||
|
@ -51,6 +50,12 @@ void nuke_end()
|
|||
int nuke_begin(const char *lbl, struct nk_rect rect, int flags) {
|
||||
return nk_begin(ctx, lbl, rect, flags);
|
||||
}
|
||||
|
||||
int nuke_begin_win(const char *lbl)
|
||||
{
|
||||
return nk_begin(ctx, lbl, nk_rect(10, 10, 400, 600), NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_SCALABLE | NK_WINDOW_TITLE);
|
||||
}
|
||||
|
||||
void nuke_stop() {
|
||||
nk_end(ctx);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ void nuke_start();
|
|||
void nuke_end();
|
||||
|
||||
int nuke_begin(const char *lbl, struct nk_rect rect, int flags);
|
||||
int nuke_begin_win(const char *lbl);
|
||||
void nuke_stop();
|
||||
struct nk_rect nuke_win_get_bounds();
|
||||
|
||||
|
|
|
@ -162,7 +162,12 @@ void openglRender(struct window *window)
|
|||
////// TEXT && GUI
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, projUBO);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, 64, ui_projection);
|
||||
|
||||
call_gui();
|
||||
|
||||
nuke_start();
|
||||
call_nk_gui();
|
||||
nuke_end();
|
||||
}
|
||||
|
||||
void BindUniformBlock(GLuint shaderID, const char *bufferName, GLuint bufferBind)
|
||||
|
|
|
@ -143,6 +143,7 @@ void script_call_sym_args(void *sym, void *args)
|
|||
struct callee *updates = NULL;
|
||||
struct callee *physics = NULL;
|
||||
struct callee *guis = NULL;
|
||||
struct callee *nk_guis = NULL;
|
||||
|
||||
void register_update(struct callee c) {
|
||||
arrput(updates, c);
|
||||
|
@ -152,6 +153,8 @@ void register_gui(struct callee c) {
|
|||
arrput(guis, c);
|
||||
}
|
||||
|
||||
void register_nk_gui(struct callee c) { arrput(nk_guis, c); }
|
||||
|
||||
void register_physics(struct callee c) {
|
||||
arrput(physics, c);
|
||||
}
|
||||
|
@ -188,6 +191,11 @@ void call_gui() {
|
|||
call_callee(&guis[i]);
|
||||
}
|
||||
|
||||
void call_nk_gui() {
|
||||
for (int i = 0; i < arrlen(nk_guis); i++)
|
||||
call_callee(&nk_guis[i]);
|
||||
}
|
||||
|
||||
void call_physics(double dt) {
|
||||
for (int i = 0; i < arrlen(physics); i++) {
|
||||
callee_dbl(updates[i], dt);
|
||||
|
|
|
@ -30,7 +30,9 @@ void register_update(struct callee c);
|
|||
void call_updates(double dt);
|
||||
|
||||
void register_gui(struct callee c);
|
||||
void register_nk_gui(struct callee c);
|
||||
void call_gui();
|
||||
void call_nk_gui();
|
||||
|
||||
void register_physics(struct callee c);
|
||||
void call_physics(double dt);
|
||||
|
|
|
@ -275,15 +275,6 @@ int window_hasfocus(struct window *w)
|
|||
void window_render(struct window *w) {
|
||||
window_makecurrent(w);
|
||||
openglRender(w);
|
||||
|
||||
|
||||
if (w->nuke_gui != NULL) {
|
||||
nuke_start();
|
||||
w->nuke_gui();
|
||||
nuke_end();
|
||||
}
|
||||
|
||||
|
||||
window_swap(w);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue