Mouse position & selection; warning fixes

This commit is contained in:
John Alanbrook 2023-02-02 23:52:15 +00:00
parent fcf6f76949
commit 7e1eaaae64
22 changed files with 347 additions and 137 deletions

View file

@ -67,7 +67,7 @@ includeflag != find source -type d -name include
includeflag += $(engincs) source/engine/thirdparty/Nuklear
includeflag := $(addprefix -I, $(includeflag))
WARNING_FLAGS = -Wall# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
WARNING_FLAGS = -Wall# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
SEM = 0.0.1
COM != git rev-parse --short HEAD
@ -83,7 +83,7 @@ ifeq ($(OS), WIN32)
CLIBS =
EXT = .exe
else
LINKER_FLAGS = $(QFLAGS) -L/usr/local/lib
LINKER_FLAGS = $(QFLAGS) -L/usr/local/lib -rdynamic
ELIBS = engine pthread yughc portaudio asound glfw3 c m dl samplerate
CLIBS =
endif

View file

@ -16,6 +16,7 @@
#include "tinyspline.h"
#include "script.h"
#include "ffi.h"
#include "log.h"
@ -45,6 +46,19 @@ struct color float2color(float *fcolor)
return new;
}
cpShape *phys2d_query_pos(cpVect pos)
{
cpShapeFilter filter;
filter.group = 0;
filter.mask = CP_ALL_CATEGORIES;
filter.categories = CP_ALL_CATEGORIES;
cpShape *find = cpSpacePointQueryNearest(space, pos, 0.f, filter, NULL);
YughInfo("Hit a %p", find);
return find;
}
int cpshape_enabled(cpShape *c)
{
cpShapeFilter filter = cpShapeGetFilter(c);
@ -96,22 +110,13 @@ void phys2d_update(float deltaT)
cpSpaceStep(space, deltaT);
}
void phys2d_shape_apply(struct phys2d_shape *shape)
{
cpShapeSetFriction(shape->shape, id2go(shape->go)->f);
cpShapeSetElasticity(shape->shape, id2go(shape->go)->e);
}
void init_phys2dshape(struct phys2d_shape *shape, int go, void *data)
{
shape->go = go;
shape->data = data;
go_shape_apply(id2go(go)->body, shape->shape, id2go(go));
cpShapeSetCollisionType(shape->shape, go);
cpShapeSetUserData(shape->shape, shape);
phys2d_shape_apply(shape);
}
void phys2d_shape_del(struct phys2d_shape *shape)
@ -119,7 +124,6 @@ void phys2d_shape_del(struct phys2d_shape *shape)
cpSpaceRemoveShape(space, shape->shape);
}
/***************** CIRCLE2D *****************/
struct phys2d_circle *Make2DCircle(int go)
{
@ -368,7 +372,7 @@ void phys2d_edge_rmvert(struct phys2d_edge *edge, int index)
phys2d_applyedge(edge);
}
phys2d_edge_setvert(struct phys2d_edge *edge, int index, cpVect val)
void phys2d_edge_setvert(struct phys2d_edge *edge, int index, cpVect val)
{
assert(arrlen(edge->points) > index && index >= 0);
edge->points[index] = val;

View file

@ -92,10 +92,11 @@ void phys2d_dbgdrawedge(struct phys2d_edge *edge);
void phys2d_edgeaddvert(struct phys2d_edge *edge);
void phys2d_edge_rmvert(struct phys2d_edge *edge, int index);
void edge_gui(struct phys2d_edge *edge);
void phys2d_edge_setvert(struct phys2d_edge *edge, int index, cpVect val);
void phys2d_init();
void phys2d_update(float deltaT);
cpShape *phys2d_query_pos(cpVect pos);
struct phys_cbs {
struct callee begin;

View file

@ -49,7 +49,7 @@ double lerp_val(struct anim anim, double t) {
}
double cubic_val(struct anim anim, double t) {
return 0.0f;
}
double anim_val(struct anim anim, double t) {

View file

@ -34,7 +34,7 @@ void mYughLog(int category, int priority, int line, const char *file, const char
va_end(args);
char buffer[ERROR_BUFFER] = { '\0' };
snprintf(buffer, ERROR_BUFFER, "%s:%d: %s, %s | %s\n", file, line, logstr[priority], catstr[category], msgbuffer);
snprintf(buffer, ERROR_BUFFER, "%s:%d: %s, %s: %s\n", file, line, logstr[priority], catstr[category], msgbuffer);
fprintf(stderr, "%s", buffer);
fflush(stderr);

View file

@ -54,7 +54,6 @@ void engine_init()
exit(1);
}
resources_init();
YughInfo("Starting scripts ...");

View file

@ -21,13 +21,18 @@
#include "music.h"
#include "level.h"
#include "tinyspline.h"
#include "mix.h"
void duk_dump_stack(duk_context *duk)
{
duk_push_context_dump(duk);
YughInfo("DUK STACK\n%s", duk_to_string(duk, -1));
duk_pop(duk);
}
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
#define BYTE_TO_BINARY(byte) \
(byte & 0x80 ? '1' : '0'), \
(byte & 0x40 ? '1' : '0'), \
(byte & 0x20 ? '1' : '0'), \
(byte & 0x10 ? '1' : '0'), \
(byte & 0x08 ? '1' : '0'), \
(byte & 0x04 ? '1' : '0'), \
(byte & 0x02 ? '1' : '0'), \
(byte & 0x01 ? '1' : '0')
struct color duk2color(duk_context *duk, int p)
{
@ -43,8 +48,10 @@ struct color duk2color(duk_context *duk, int p)
return color;
}
cpVect duk2vec2(duk_context *duk, int p) {
cpVect duk2vec2(duk_context *duk, int p)
{
cpVect pos;
if (p < 0) p = duk_get_top_index(duk) + p + 1;
duk_get_prop_index(duk, p, 0);
@ -59,12 +66,90 @@ cpVect duk2vec2(duk_context *duk, int p) {
return pos;
}
cpBitmask duk2bitmask(duk_context *duk, int p)
{
cpBitmask mask = 0;
if (p < 0) p = duk_get_top_index(duk)+p+1;
int len = duk_get_length(duk, p);
for (int i = 0; i < len; i++) {
duk_get_prop_index(duk, p, i);
int val = duk_to_int(duk, -1);
duk_pop(duk);
if (val > 10) continue;
mask |= 1<<val;
}
YughInfo(BYTE_TO_BINARY_PATTERN,BYTE_TO_BINARY(mask));
return mask;
}
void bitmask2duk(duk_context *duk, cpBitmask mask)
{
int arr = duk_push_array(duk);
int arridx = 0;
for (int i = 0; i < 11; i++) {
int on = mask & 1<<i;
if (on) {
duk_push_int(duk, i);
duk_put_prop_index(duk, arr, arridx++);
}
}
}
void vec2float(cpVect v, float *f)
{
f[0] = v.x;
f[1] = v.y;
}
duk_idx_t vect2duk(cpVect v) {
duk_idx_t arr = duk_push_array(duk);
duk_push_number(duk, v.x);
duk_put_prop_index(duk, arr, 0);
duk_push_number(duk, v.y);
duk_put_prop_index(duk, arr, 1);
return arr;
}
void duk_dump_stack(duk_context *duk)
{
YughInfo("DUK CALLSTACK");
for (int i = -2; ; i--) { /* Start at -2 to skip the invoked C function */
duk_inspect_callstack_entry(duk, i);
if (duk_is_undefined(duk, -1)) break;
duk_get_prop_string(duk, -1, "lineNumber");
long ln = duk_to_int(duk, -1);
duk_pop(duk);
duk_get_prop_string(duk, -1, "function");
duk_get_prop_string(duk, -1, "name");
const char *fn = duk_to_string(duk, -1);
duk_pop(duk);
duk_get_prop_string(duk, -1, "fileName");
const char *file = duk_to_string(duk, -1);
duk_pop(duk);
mYughLog(1, 3, ln, file, "function: %s", fn);
duk_pop_2(duk);
}
duk_push_context_dump(duk);
YughInfo("DUK STACK\n%s", duk_to_string(duk, -1));
duk_pop(duk);
}
duk_ret_t duk_gui_text(duk_context *duk) {
const char *s = duk_to_string(duk, 0);
cpVect pos = duk2vec2(duk, 1);
@ -183,10 +268,10 @@ return 1;
duk_ret_t duk_cmd(duk_context *duk) {
int cmd = duk_to_int(duk, 0);
switch(cmd) {
case 0:
duk_push_int(duk, script_dofile(duk_to_string(duk, 1)));
return 1;
switch(cmd) {
case 0:
duk_push_int(duk, script_dofile(duk_to_string(duk, 1)));
return 1;
case 1:
set_pawn(duk_get_heapptr(duk, 1));
@ -346,6 +431,32 @@ duk_ret_t duk_cmd(duk_context *duk) {
case 39:
duk_push_int(duk, slurp_write(duk_to_string(duk, 1), duk_to_string(duk, 2)));
return 1;
case 40:
id2go(duk_to_int(duk, 1))->filter.categories = duk2bitmask(duk, 2);
gameobject_apply(id2go(duk_to_int(duk, 1)));
break;
case 41:
id2go(duk_to_int(duk, 1))->filter.mask = duk2bitmask(duk, 2);
gameobject_apply(id2go(duk_to_int(duk, 1)));
break;
case 42:
bitmask2duk(duk, id2go(duk_to_int(duk, 1))->filter.categories);
return 1;
case 43:
bitmask2duk(duk, id2go(duk_to_int(duk, 1))->filter.mask);
return 1;
case 44:
duk_push_int(duk, pos2gameobject(duk2vec2(duk, 1)));
return 1;
case 45:
vect2duk(mouse_pos);
return 1;
}
return 0;
@ -692,7 +803,7 @@ duk_ret_t duk_make_poly2d(duk_context *duk)
duk_ret_t duk_cmd_poly2d(duk_context *duk)
{
return 0;
}
duk_ret_t duk_make_edge2d(duk_context *duk)
@ -725,7 +836,7 @@ duk_ret_t duk_make_edge2d(duk_context *duk)
duk_ret_t duk_cmd_edge2d(duk_context *duk)
{
return 0;
}
/* These are anims for controlling properties on an object */
@ -785,6 +896,7 @@ void ffi_load()
DUK_FUNC(make_sprite, 3);
DUK_FUNC(make_anim2d, 3);
DUK_FUNC(spline_cmd, 6);
DUK_FUNC(make_box2d, 3);
DUK_FUNC(cmd_box2d, DUK_VARARGS);
DUK_FUNC(make_circle2d, 3);

View file

@ -2,7 +2,19 @@
#define FFI_H
#include "duktape.h"
#include <chipmunk/chipmunk.h>
void ffi_load();
void duk_dump_stack(duk_context *duk);
duk_idx_t vect2duk(cpVect v);
cpVect duk2vec2(duk_context *duk, int p);
void bitmask2duk(duk_context *duk, cpBitmask mask);
cpBitmask duk2bitmask(duk_context *duk, int p);
struct color duk2color(duk_context *duk, int p);
#endif

View file

@ -36,7 +36,7 @@ unsigned char *slurp_file(const char *filename) {
return slurp;
}
unsigned char *slurp_text(const char *filename) {
char *slurp_text(const char *filename) {
FILE *f = fopen(filename, "r'");
if (!f) return NULL;

View file

@ -22,8 +22,6 @@ struct sFont {
uint32_t texID;
};
void font_init(struct shader *s);
void font_frame(struct window *w);
struct sFont *MakeFont(const char *fontfile, int height);
@ -32,7 +30,7 @@ void text_settype(struct sFont *font);
void renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw);
unsigned char *slurp_file(const char *filename);
unsigned char *slurp_text(const char *filename);
char *slurp_text(const char *filename);
int slurp_write(const char *txt, const char *filename);

View file

@ -32,6 +32,26 @@ struct gameobject *id2go(int id) {
return &gameobjects[id];
}
int pos2gameobject(cpVect pos)
{
cpShape *hit = phys2d_query_pos(pos);
if (hit) {
struct phys2d_shape *shape = cpShapeGetUserData(hit);
return shape->go;
}
for (int i = 0; i < arrlen(gameobjects); i++) {
cpVect gpos = cpBodyGetPosition(gameobjects[i].body);
float dist = cpvlength(cpvsub(gpos, pos));
if (dist <= 25) return i;
}
return -1;
}
int id_from_gameobject(struct gameobject *go) {
for (int i = 0; i < arrlen(gameobjects); i++) {
if (&gameobjects[i] == go) return i;
@ -40,12 +60,23 @@ int id_from_gameobject(struct gameobject *go) {
return -1;
}
void go_shape_apply(cpBody *body, cpShape *shape, struct gameobject *go)
{
cpShapeSetFriction(shape, go->f);
cpShapeSetElasticity(shape, go->e);
// cpShapeSetFilter(shape, go->filter);
// YughLog("Set filter; %d", go->filter.mask);
}
void gameobject_apply(struct gameobject *go)
{
cpBodySetType(go->body, go->bodytype);
if (go->bodytype == CP_BODY_TYPE_DYNAMIC)
cpBodySetMass(go->body, go->mass);
cpBodyEachShape(go->body, go_shape_apply, go);
}
static void gameobject_setpickcolor(struct gameobject *go)
@ -82,14 +113,19 @@ int MakeGameobject()
first = id2go(first)->next;
*id2go(retid) = go;
}
cpBodySetUserData(go.body, retid);
go.filter.group = retid;
go.filter.mask = CP_ALL_CATEGORIES;
go.filter.categories = CP_ALL_CATEGORIES;
cpBodySetUserData(go.body, (int)retid);
return retid;
}
void rm_body_shapes(cpBody *body, cpShape *shape, void *data) {
struct phys2d_shape *s = cpShapeGetUserData(shape);
free(s->data);
if (s->data) {
free(s->data);
s->data = NULL;
}
cpSpaceRemoveShape(space, shape);
cpShapeFree(shape);
}
@ -101,6 +137,7 @@ void gameobject_delete(int id)
first = id;
}
/* Free this gameobject */
void gameobject_clean(int id) {
struct gameobject *go = id2go(id);
cpBodyEachShape(go->body, rm_body_shapes, NULL);
@ -138,29 +175,6 @@ void gameobject_save(struct gameobject *go, FILE * file)
*/
}
int gameobject_makefromprefab(char *path)
{
/*
FILE *fprefab = fopen(path, "rb");
if (fprefab == NULL) {
YughError("Could not find prefab %s.", path);
return -1;
}
struct gameobject *new = get_gameobject_from_id(MakeGameobject());
fread(new, sizeof(*new), 1, fprefab);
new->components = NULL;
gameobject_init(new, fprefab);
fclose(fprefab);
arrlast(gameobjects).editor.id = arrlen(gameobjects)-1;
return arrlen(gameobjects)-1;
*/
}
void gameobject_init(struct gameobject *go, FILE * fprefab)
{
/*
@ -190,8 +204,6 @@ void gameobject_init(struct gameobject *go, FILE * fprefab)
newc->init(newc->data, go);
}
*/
}
void gameobject_saveprefab(struct gameobject *go)
@ -208,10 +220,6 @@ void gameobject_saveprefab(struct gameobject *go)
*/
}
void gameobject_syncprefabs(char *revertPath)
{
/*

View file

@ -32,6 +32,7 @@ struct gameobject {
float e; /* elasticity */
int flipx; /* 1 or -1 */
int flipy;
cpShapeFilter filter;
cpBody *body; /* NULL if this object is dead */
int id;
struct phys_cbs cbs;
@ -49,13 +50,17 @@ struct gameobject *get_gameobject_from_id(int id);
struct gameobject *id2go(int id);
int id_from_gameobject(struct gameobject *go);
void go_shape_apply(cpBody *body, cpShape *shape, struct gameobject *go);
void gameobject_save(struct gameobject *go, FILE * file);
void gameobject_saveprefab(struct gameobject *go);
int gameobject_makefromprefab(char *path);
void gameobject_syncprefabs(char *revertPath);
void gameobject_revertprefab(struct gameobject *go);
/* Tries a few methods to select a gameobject; if none is selected returns -1 */
int pos2gameobject(cpVect pos);
void gameobject_init(struct gameobject *go, FILE * fprefab);
void gameobject_move(struct gameobject *go, cpVect vec);

View file

@ -7,13 +7,10 @@
int32_t mouseWheelX = 0;
int32_t mouseWheelY = 0;
int ychange = 0;
int xchange = 0;
float deltaT = 0;
static double c_xpos;
static double c_ypos;
cpVect mouse_pos = {0,0};
cpVect mouse_delta = {0,0};
static int *downkeys = NULL;
@ -26,21 +23,28 @@ void set_pawn(void *pawn) {
}
void remove_pawn(void *pawn) {
for (int i = 0; i < arrlen(pawns); i++) {
if (pawns[i] == pawn) {
pawns[i] = NULL;
return;
}
for (int i = 0; i < arrlen(pawns); i++) {
if (pawns[i] == pawn) {
pawns[i] = NULL;
return;
}
}
}
static void cursor_pos_cb(GLFWwindow *w, double xpos, double ypos)
{
xchange = (int)xpos - c_xpos;
ychange = (int)ypos - c_ypos;
mouse_delta.x = xpos - mouse_pos.x;
mouse_delta.y = ypos - mouse_pos.y;
mouse_pos.x = xpos;
mouse_pos.y = ypos;
for (int i = 0; i < arrlen(pawns); i++) {
if (script_eval_setup("input_mouse_pos", pawns[i])) continue;
vect2duk(duk, mouse_pos);
script_eval_exec(1);
}
c_xpos = xpos;
c_ypos = ypos;
}
static void scroll_cb(GLFWwindow *w, double xoffset, double yoffset)
@ -49,10 +53,49 @@ static void scroll_cb(GLFWwindow *w, double xoffset, double yoffset)
mouseWheelX = xoffset;
}
static void mb_cb(GLFWwindow *w, int button, int action, int mods)
{
const char *act = NULL;
const char *btn = NULL;
switch (action) {
case GLFW_PRESS:
act = "pressed";
break;
case GLFW_RELEASE:
act = "released";
break;
case GLFW_REPEAT:
act = "repeat";
break;
}
switch (button) {
case GLFW_MOUSE_BUTTON_LEFT:
btn = "lmouse";
break;
case GLFW_MOUSE_BUTTON_RIGHT:
btn = "rmouse";
break;
}
if (!act || !btn) {
YughError("Tried to call a mouse action that doesn't exist.");
return;
}
char keystr[50] = {'\0'};
snprintf(keystr, 50, "input_%s_%s", btn, act);
call_input_signal(keystr);
}
void input_init()
{
glfwSetCursorPosCallback(mainwin->window, cursor_pos_cb);
glfwSetScrollCallback(mainwin->window, scroll_cb);
glfwSetMouseButtonCallback(mainwin->window, mb_cb);
}
void call_input_signal(char *signal) {
@ -149,8 +192,7 @@ void call_input_down(int *key) {
/* This is called once every frame - or more if we want it more! */
void input_poll(double wait)
{
ychange = 0;
xchange = 0;
mouse_delta = cpvzero;
mouseWheelX = 0;
mouseWheelY = 0;

View file

@ -3,13 +3,15 @@
#include <stdint.h>
#include "window.h"
#include <chipmunk/chipmunk.h>
#include "script.h"
extern int32_t mouseWheelX;
extern int32_t mouseWheelY;
extern int ychange;
extern int xchange;
extern cpVect mouse_pos;
extern cpVect mouse_delta;
extern float deltaT;
void input_init();
@ -18,6 +20,7 @@ void input_poll(double wait);
void cursor_hide();
void cursor_show();
void call_input_signal(char *signal);
int action_down(int scancode);
int want_quit();

View file

@ -10,13 +10,10 @@
#include "debugdraw.h"
#include "log.h"
#include "datastream.h"
#include "nuke.h"
int renderMode = 0;
static GLuint UBO;
struct shader *spriteShader = NULL;
struct shader *animSpriteShader = NULL;
static struct shader *textShader;
@ -79,13 +76,9 @@ void openglInit()
animSpriteShader = MakeShader("animspritevert.glsl", "animspritefrag.glsl");
textShader = MakeShader("textvert.glsl", "textfrag.glsl");
shader_use(textShader);
shader_setint(textShader, "text", 0);
font_init(textShader);
sprite_initialize();
debugdraw_init();

View file

@ -1,4 +1,5 @@
#include "particle.h"
#include "stb_ds.h"
struct emitter make_emitter()
{
@ -15,6 +16,8 @@ struct emitter set_emitter(struct emitter e)
for (int i = 0; i < arrlen(e.particles)-1; i++) {
e.particles[i].next = &e.particles[i+1];
}
return e;
}
void free_emitter(struct emitter e)

View file

@ -16,17 +16,6 @@
duk_context *duk = NULL;
duk_idx_t vect2duk(cpVect v) {
duk_idx_t arr = duk_push_array(duk);
duk_push_number(duk, v.x);
duk_put_prop_index(duk, arr, 0);
duk_push_number(duk, v.y);
duk_put_prop_index(duk, arr, 1);
return arr;
}
static int load_prefab(const char *fpath, const struct stat *sb, int typeflag) {
if (typeflag != FTW_F)
return 0;
@ -109,6 +98,9 @@ void script_call(const char *f) {
//s7_call(s7, s7_name_to_value(s7, f), s7_nil(s7));
}
/* env is an object in the scripting environment;
s is the function to call on that object
*/
void script_eval_w_env(const char *s, void *env) {
duk_push_heapptr(duk, env);
duk_push_string(duk, s);
@ -124,6 +116,27 @@ void script_eval_w_env(const char *s, void *env) {
duk_pop_2(duk);
}
int script_eval_setup(const char *s, void *env)
{
duk_push_heapptr(duk, env);
if (!duk_has_prop_string(duk, -1, s)) {
duk_pop(duk);
return 1;
}
duk_push_string(duk, s);
return 0;
}
void script_eval_exec(int argc)
{
if (duk_pcall_prop(duk, -2 - argc, argc))
duk_run_err();
duk_pop_2(duk);
}
void script_call_sym(void *sym)
{
duk_push_heapptr(duk, sym);
@ -138,8 +151,6 @@ void script_call_sym_args(void *sym, void *args)
//s7_call(s7, sym, s7_cons(s7, args, s7_nil(s7)));
}
struct callee *updates = NULL;
struct callee *physics = NULL;
struct callee *guis = NULL;
@ -159,25 +170,38 @@ void register_physics(struct callee c) {
arrput(physics, c);
}
void call_callee(struct callee *c) {
duk_push_heapptr(duk, c->fn);
duk_push_heapptr(duk, c->obj);
void setup_callee(struct callee c)
{
duk_push_heapptr(duk, c.fn);
duk_push_heapptr(duk, c.obj);
}
if (duk_pcall_method(duk, 0))
void exec_callee(int argc)
{
if (duk_pcall_method(duk, argc))
duk_run_err();
duk_pop(duk);
}
void callee_dbl(struct callee c, double d) {
duk_push_heapptr(duk, c.fn);
duk_push_heapptr(duk, c.obj);
duk_push_number(duk, d);
void call_callee(struct callee *c) {
setup_callee(*c);
exec_callee(0);
}
if (duk_pcall_method(duk, 1))
duk_run_err();
duk_pop(duk);
void callee_dbl(struct callee c, double d)
{
setup_callee(c);
duk_push_number(duk, d);
exec_callee(1);
}
void callee_vec2(struct callee c, cpVect vec)
{
setup_callee(c);
vect2duk(vec);
exec_callee(1);
}
void call_updates(double dt) {

View file

@ -17,6 +17,7 @@ void script_run(const char *script);
int script_dofile(const char *file);
void script_update(double dt);
void script_draw();
void script_editor();
void script_call(const char *f);
void script_call_sym(void *sym);
@ -24,6 +25,10 @@ void script_call_sym_args(void *sym, void *args);
void call_callee(struct callee *c);
int script_has_sym(void *sym);
void script_eval_w_env(const char *s, void *env);
int script_eval_setup(const char *s, void *env);
void script_eval_exec(int argc);
time_t file_mod_secs(const char *file);
void register_update(struct callee c);
@ -37,6 +42,4 @@ void call_nk_gui();
void register_physics(struct callee c);
void call_physics(double dt);
duk_idx_t vec2duk(cpVect v);
#endif

View file

@ -116,14 +116,6 @@ void sprite_initialize()
glEnableVertexAttribArray(0);
}
struct glrect sprite_get_rect(struct sprite *sprite) {
if (sprite->tex->opts.animation) {
} else {
return tex_get_rect(sprite->tex);
}
}
void tex_draw(struct Texture *tex, float pos[2], float angle, float size[2], float offset[2], struct glrect r) {
mfloat_t model[16] = { 0.f };
mfloat_t r_model[16] = { 0.f };

View file

@ -22,7 +22,6 @@ struct sprite {
int enabled;
};
int make_sprite(int go);
struct sprite *id2sprite(int id);
void sprite_delete(int id);

View file

@ -20,6 +20,8 @@ struct Texture *tex_default;
struct Texture *texture_pullfromfile(const char *path)
{
if (!path) { YughError("Tried to pull a texture with a NULL path."); return NULL; }
int index = shgeti(texhash, path);
if (index != -1)
return texhash[index].value;

View file

@ -6,7 +6,12 @@
#include "engine.h"
#include "input.h"
#include "openglrender.h"
#include "gameobject.h"
#include "timer.h"
#include "script.h"
#include "ffi.h"
#include "log.h"
#include <stdio.h>
@ -66,10 +71,14 @@ void seghandle(int sig) {
YughCritical("====================BACKTRACE====================");
char **stackstr = backtrace_symbols(ents, size);
YughInfo("Stack size is %d.", size);
for (int i = 0; i < size; i++) {
YughCritical(stackstr[i]);
}
duk_dump_stack(duk);
exit(1);
#endif
}
@ -166,6 +175,7 @@ int main(int argc, char **args) {
script_dofile("game.js");
}
input_init();
openglInit();
sim_stop();
while (!want_quit()) {