diff --git a/source/engine/2dphysics.c b/source/engine/2dphysics.c index 8b457e2..63d02f9 100644 --- a/source/engine/2dphysics.c +++ b/source/engine/2dphysics.c @@ -61,7 +61,6 @@ struct phys2d_circle *Make2DCircle(struct mGameObject *go) void phys2d_circleinit(struct phys2d_circle *circle, struct mGameObject *go) { - printf("Initing a circle\n"); circle->shape.shape = cpSpaceAddShape(space, cpCircleShapeNew(go->body, circle->radius, cpvzero)); init_phys2dshape(&circle->shape, go); } diff --git a/source/engine/dsp.c b/source/engine/dsp.c index 2029f37..fd45960 100644 --- a/source/engine/dsp.c +++ b/source/engine/dsp.c @@ -87,7 +87,7 @@ struct wav gen_sine(float amp, float freq, int sr, int ch) } } - printf("Made sine with %i frames.\n", new.frames); + YughInfo("Made sine with %i frames.", new.frames); return new; } @@ -318,7 +318,7 @@ struct dsp_filter lpf_make(int poles, float freq) double sf = sf_bwlp(poles, fcf); - printf("Making LPF filter, fcf: %f, coeffs: %i, scale %1.15lf\n", fcf, new->n, sf); + YughInfo("Making LPF filter, fcf: %f, coeffs: %i, scale %1.15lf", fcf, new->n, sf); int *ccof = ccof_bwlp(new->n); new->dcof = dcof_bwlp(new->n, fcf); @@ -388,7 +388,6 @@ void dsp_fir_fillbuf(struct dsp_fir *fir, short *out, int n) for (int i = 0; i < n; i++) { short val = fir_filter(fir, out[i*CHANNELS]); - // printf("%hd\n", val); for (int j = 0; j < CHANNELS; j++) out[i*CHANNELS + j] = val*5; @@ -429,7 +428,7 @@ struct dsp_delay dsp_delay_make(unsigned int ms_delay) new.buf = circbuf_init(sizeof(short), datasize); new.buf.write = datasize; - printf("Buffer size is %u.\n", new.buf.len); + YughInfo("Buffer size is %u.", new.buf.len); return new; } diff --git a/source/engine/editor.c b/source/engine/editor.c index acb009b..88ebee5 100644 --- a/source/engine/editor.c +++ b/source/engine/editor.c @@ -56,7 +56,7 @@ const char *allowed_extensions[] = {"jpg", "png", "rb", "wav", "mp3", }; void text_ed_cb(GLFWwindow *win, unsigned int codepoint); void asset_srch_cb(GLFWwindow *win, unsigned int codepoint) { - printf("Pushed %d.\n", codepoint); + YughInfo("Pushed %d.", codepoint); } static const char *editor_filename = "editor.ini"; @@ -913,10 +913,10 @@ void editor_asset_tex_gui(struct Texture *tex) { void text_ed_cb(GLFWwindow *win, unsigned int codepoint) { - printf("Pressed button %d\n", codepoint); + YughInfo("Pressed button %d", codepoint); if (editor.text_ed & NK_EDIT_ACTIVE) { if (codepoint == '\n') { - printf("Hit newline.\n"); + YughInfo("Hit newline."); } } } @@ -992,7 +992,7 @@ void get_levels() { fill_extensions(levels, DATA_PATH, EXT_LEVEL); } void editor_prefab_btn(char *prefab) { if (nk_button_label(ctx, prefab)) { - printf("making prefab\n"); + YughInfo("Making prefab '%s'.", prefab); gameobject_makefromprefab(prefab); /*GameObject* newprefab = (GameObject*)createPrefab(*prefab); */ /*cam_inverse_goto(&camera, &newprefab->transform); */ diff --git a/source/engine/editorstate.c b/source/engine/editorstate.c index 1deb320..7e2ec62 100644 --- a/source/engine/editorstate.c +++ b/source/engine/editorstate.c @@ -6,7 +6,7 @@ void (*asset_command)(char *asset) = print_file; void print_file(char *file) { - printf("File path: %s\n", file); + YughInfo("File path: %s", file); } void set_new_model(char *modelPath) diff --git a/source/engine/engine.c b/source/engine/engine.c index a9bb5af..83ee864 100644 --- a/source/engine/engine.c +++ b/source/engine/engine.c @@ -44,6 +44,7 @@ void error_callback(int error, const char *description) { fprintf(stderr, "Error: %s\n", description); + YughError("GLFW Error: %s", description); } void engine_init() diff --git a/source/engine/font.c b/source/engine/font.c index c052f35..ff2b36f 100644 --- a/source/engine/font.c +++ b/source/engine/font.c @@ -8,6 +8,7 @@ #include #include #include +#include "log.h" #include @@ -62,7 +63,7 @@ struct sFont *MakeFont(const char *fontfile, int height) stbtt_fontinfo fontinfo; if (!stbtt_InitFont(&fontinfo, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0))) { - printf("failed\n"); + YughError("Failed to make font %s", fontfile); } float scale = stbtt_ScaleForPixelHeight(&fontinfo, height); diff --git a/source/engine/gameobject.c b/source/engine/gameobject.c index ee1c7c8..52e0e23 100644 --- a/source/engine/gameobject.c +++ b/source/engine/gameobject.c @@ -10,6 +10,7 @@ #include #include "resources.h" #include "nuke.h" +#include "log.h" #include "stb_ds.h" @@ -36,7 +37,7 @@ static void gameobject_setpickcolor(struct mGameObject *go) struct mGameObject *MakeGameobject() { - printf("Making gameobject\n"); + YughInfo("Making new gameobject"); struct mGameObject go = { .editor.id = arrlen(gameobjects), .transform.scale = 1.f, @@ -96,7 +97,7 @@ void gameobject_save(struct mGameObject *go, FILE * file) { fwrite(go, sizeof(*go), 1, file); - printf("Number of components is %d.\n", arrlen(go->components)); + YughInfo("Number of components is %d.", arrlen(go->components)); int n = arrlen(go->components); fwrite(&n, sizeof(n), 1, file); diff --git a/source/engine/log.h b/source/engine/log.h index 3c05d6d..67dd597 100644 --- a/source/engine/log.h +++ b/source/engine/log.h @@ -8,11 +8,11 @@ #define LOG_ERROR 2 #define LOG_CRITICAL 3 -#define YughLog(cat, pri, msg, ...) mYughLog(cat, pri, __LINE__, __FILE__, msg, __VA_ARGS__) -#define YughInfo(msg, ...) mYughLog(0, 0, __LINE__, __FILE__, msg, __VA_ARGS__); -#define YughWarn(msg, ...) mYughLog(0, 1, __LINE__, __FILE__, msg, __VA_ARGS__); -#define YughError(msg, ...) mYughLog(0, 2, __LINE__, __FILE__, msg, __VA_ARGS__); -#define YughCritical(msg, ...) mYughLog(0, 3, __LINE__, __FILE__, msg, __VA_ARGS__); +#define YughLog(cat, pri, msg, ...) mYughLog(cat, pri, __LINE__, __FILE__, msg, ##__VA_ARGS__) +#define YughInfo(msg, ...) mYughLog(0, 0, __LINE__, __FILE__, msg, ##__VA_ARGS__); +#define YughWarn(msg, ...) mYughLog(0, 1, __LINE__, __FILE__, msg, ##__VA_ARGS__); +#define YughError(msg, ...) mYughLog(0, 2, __LINE__, __FILE__, msg, ##__VA_ARGS__); +#define YughCritical(msg, ...) mYughLog(0, 3, __LINE__, __FILE__, msg, ##__VA_ARGS__); void mYughLog(int category, int priority, int line, const char *file, const char *message, ...); diff --git a/source/engine/model.c b/source/engine/model.c index 50e0fcc..aee7f3c 100644 --- a/source/engine/model.c +++ b/source/engine/model.c @@ -6,6 +6,7 @@ #include #include #include +#include "log.h" static struct mModel *lastRendered; static struct mModel *loadedModels[100]; @@ -69,7 +70,7 @@ void draw_model(struct mModel *model, struct mShader *shader) void loadmodel(struct mModel *model) { - printf("Loading model at path %s\n", model->path); + YughInfo("Loading model at path %s", model->path); /* // Load model with cgltf cgltf_options options = {0}; diff --git a/source/engine/mrbffi.c b/source/engine/mrbffi.c index bd8621d..19f6697 100644 --- a/source/engine/mrbffi.c +++ b/source/engine/mrbffi.c @@ -13,6 +13,7 @@ #include "window.h" #include "editor.h" #include "engine.h" +#include "log.h" extern mrb_state *mrb; @@ -143,7 +144,7 @@ mrb_value mrb_sound_make(mrb_state *mrb, mrb_value self) { mrb_value vals; mrb_get_args(mrb, "H", &vals); char *name = mrb_str_to_cstr(mrb, mrb_hash_fetch(mrb, vals, mrb_symbol_value(mrb_intern_cstr(mrb, "name")), mrb_str_new_cstr(mrb, "New Window"))); - printf("Window name is %s.\n", name); + YughInfo("Window name is %s.", name); return self; } diff --git a/source/engine/resources.c b/source/engine/resources.c index 1396054..7d96a31 100644 --- a/source/engine/resources.c +++ b/source/engine/resources.c @@ -11,6 +11,7 @@ #include #include #include +#include "log.h" #include @@ -55,7 +56,7 @@ char *get_filename_from_path(char *path, int extension) if (!extension) { char *ext = strrchr(path, '.'); offset = end - ext; - printf("Making without extension ...\n"); + YughInfo("Making %s without extension ..."); } char *filename = malloc(sizeof(char) * (end - dirpos - offset + 1)); diff --git a/source/engine/shader.c b/source/engine/shader.c index 37c901d..98435aa 100644 --- a/source/engine/shader.c +++ b/source/engine/shader.c @@ -79,7 +79,7 @@ GLuint load_shader_from_file(const char *path, int type) glShaderSource(id, 1, &code, NULL); glCompileShader(id); if (shader_compile_error(id)) { - printf("Error with shader %s.\n", path); + YughError("Error with shader %s.", path); return 0; } @@ -88,7 +88,7 @@ GLuint load_shader_from_file(const char *path, int type) void shader_compile(struct mShader *shader) { - printf("Making shader with %s and %s.\n", shader->vertpath, shader->fragpath); + YughInfo("Making shader with %s and %s.", shader->vertpath, shader->fragpath); GLuint vert = load_shader_from_file(shader->vertpath, GL_VERTEX_SHADER); GLuint frag = load_shader_from_file(shader->fragpath, GL_FRAGMENT_SHADER); diff --git a/source/engine/sprite.c b/source/engine/sprite.c index 5dfd5e4..76d0da0 100644 --- a/source/engine/sprite.c +++ b/source/engine/sprite.c @@ -29,13 +29,13 @@ struct sprite *make_sprite(struct mGameObject *go) .index = arrlen(sprites) }; sprite_init(&sprite, go); - arrput(sprites, sprite); return &arrlast(sprites); } void sprite_init(struct sprite *sprite, struct mGameObject *go) { sprite->go = go; + arrput(sprites, *sprite); } void sprite_io(struct sprite *sprite, FILE *f, int read) @@ -51,8 +51,6 @@ void sprite_io(struct sprite *sprite, FILE *f, int read) fread(sprite, sizeof(*sprite), 1, f); sprite_loadtex(sprite, path); } else { - // fprintf(f, "%s", tex_get_path(sprite->tex)); - fputs(tex_get_path(sprite->tex), f); fputc('\0', f); fwrite(sprite, sizeof(*sprite), 1, f); diff --git a/source/engine/yugine.c b/source/engine/yugine.c index 5c428a7..7cdc3b9 100644 --- a/source/engine/yugine.c +++ b/source/engine/yugine.c @@ -6,6 +6,7 @@ #include "openglrender.h" #include "script.h" #include "editor.h" +#include "log.h" #include "string.h" @@ -35,7 +36,7 @@ int main(int argc, char **args) { engine_init(); const GLFWvidmode *vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); - printf("Refresh rate is %d\n", vidmode->refreshRate); + YughInfo("Refresh rate is %d", vidmode->refreshRate); renderMS = 1.0/vidmode->refreshRate;