From 0dfd07a115ab626c97080dbe87e3c4904f091041 Mon Sep 17 00:00:00 2001 From: onelin Date: Fri, 11 Apr 2025 11:48:42 +0200 Subject: Remove old glfw window src --- src/core/include/engine/engine.h | 2 +- src/core/src/loop.c | 112 +++------------------------------------ 2 files changed, 8 insertions(+), 106 deletions(-) (limited to 'src/core') diff --git a/src/core/include/engine/engine.h b/src/core/include/engine/engine.h index d28c024..d0a61f2 100644 --- a/src/core/include/engine/engine.h +++ b/src/core/include/engine/engine.h @@ -31,7 +31,7 @@ typedef struct { /* Essential functions */ Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight, - const f32 render_scale, const u32 flags, + const u32 flags, const usize initial_memory); i32 engine_run(Instance* p, StateType initial_state, void* state_arg); diff --git a/src/core/src/loop.c b/src/core/src/loop.c index 6a91f46..cd264a7 100644 --- a/src/core/src/loop.c +++ b/src/core/src/loop.c @@ -33,6 +33,7 @@ #include #include +#include #define DEFAULT_NUM_PROCS 8 @@ -101,7 +102,7 @@ i32 cmp_int(const void* a, const void* b) { /* Creates the window, initializes IO, Rendering, Fonts and engine-specific * resources. */ Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight, - const f32 render_scale, const u32 flags, + const u32 flags, const usize initial_memory) { INFO("Engine version " ENGINE_VERSION); @@ -113,7 +114,7 @@ Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight INFO("Starting with pid %lu", pid); } #endif - v2_i32 windowsize = (v2_i32){.x = windowWidth, .y = windowHeight}; + v2_i32 windowsize = (v2_i32){.x = windowWidth, .y = windowHeight}; Instance* p = (Instance*)calloc(1, sizeof(Instance)); Window* w = (Window*)calloc(1, sizeof(Window)); @@ -122,106 +123,7 @@ Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight Resources* resources = calloc(1, sizeof(Resources)); // TODO: Initialize them :) - w = init_window_glfw(windowtitle, (ivec2){windowsize.x, windowsize.y}, flags); - // Dont forget to init the renderer - init_render_opengl(w, flags); - - - //{ /* Resource loading */ - - // /* Count resources */ - // usize n_textures = 0; - // usize n_fonts = 0; - - // if (textures != NULL) - // while (textures[n_textures] != NULL) n_textures++; - // if (fonts != NULL) - // while (fonts[n_fonts] != NULL) n_fonts++; - - // INFO("Number of textures: " TERM_COLOR_YELLOW "%d" TERM_COLOR_RESET, - // n_textures); - // INFO("Number of fonts: " TERM_COLOR_YELLOW "%d" TERM_COLOR_RESET, n_fonts); - - // /* Save the textures and fonts, if we should need to reload them later */ - // resources->texture_paths = (Asset_TextureSpec**)textures; - // resources->font_paths = (Asset_FontSpec**)fonts; - - // /* Allocate memory for textures and fonts */ - // resources->textures = (Texture**)malloc(sizeof(Texture*) * n_textures); - // //resources->fonts = (TTF_Font**)malloc(sizeof(TTF_Font*) * n_fonts); - // resources->textures_size = n_textures; - - // for (usize i = 0; i < n_textures; i++) resources->textures[i] = NULL; - // //for (usize i = 0; i < n_fonts; i++) resources->fonts[i] = NULL; - - // /* Load textures */ - // for (usize i = 0; i < n_textures; i++) { - // Texture* t = NULL; - // INFO_("loading texture \"" TERM_COLOR_YELLOW "%s" TERM_COLOR_RESET - // "\"...", - // textures[i]->path); - -//// t = load_texture(renderer, textures[i]); -//// if (t == NULL) { -//// puts(""); -//// ERROR("failed to load texture\n"); -//// exit(EXIT_FAILURE); -//// } -//// -//// if (t->tilesize < 8) { -//// puts(""); -//// ERROR("texture too small!\n"); -//// exit(EXIT_FAILURE); -//// } -//// - // //if (t->texture == NULL) { - // // puts(""); - // // ERROR("failed to load texture\n"); - // //} else { - // // printf("ok\n"); - // // resources->textures[i] = t; - // // resources->textures_len++; - // //} - // } - - // /* Load fonts */ - // for (usize i = 0; i < n_fonts; i++) { - // INFO_("loading font \"" TERM_COLOR_YELLOW "%s" TERM_COLOR_RESET "\"...", - // fonts[i]->font_path); - - // //TTF_Font* font = TTF_OpenFont(fonts[i]->font_path, fonts[i]->ptsize); - // //if (!font) { - // // ERROR("failed to load font: %s\n", TTF_GetError()); - // //} else { - // // printf("ok\n"); - // // resources->fonts[i] = font; - // // resources->fonts_len++; - // //} - // } - - // if (resources->textures_len != n_textures) { - // WARN("Done. %d/%d textures loaded.", resources->textures_len, n_textures); - // } else { - // INFO("Done. All %d textures loaded.", n_textures); - // } - - // if (resources->fonts_len != n_fonts) { - // WARN("Done. %d/%d fonts loaded.", resources->fonts_len, n_fonts); - // } else { - // INFO("Done. All %d fonts loaded.", n_fonts); - // } - - // resources->texturepaths_len = resources->textures_len; - // resources->fontpaths_len = resources->fonts_len; - //} - - //{ /* Adjust window and such */ - // /* Set actual windowsize, which might be forced by OS */ - // INFO("Adjusting window size..."); - // //windowsize = get_canvas_size(renderer); - - // INFO("Windowsize: <%d,%d>", windowsize.x, windowsize.y); - //} + w = Platform_GLFW.window_init(p, windowtitle, (ivec2){windowsize.x, windowsize.y}, flags); p->window = w; p->quit = false; @@ -319,7 +221,7 @@ i32 engine_run(Instance* p, StateType initial_state, void* state_arg) { //const f64 delta = (f64)dt / (f64)fps_cap; /* Events */ - window_poll_events(); + Platform_GLFW.window_poll(); i_flush_bindings(dt, callbacks_len, callbacks, mem->data); /* Update */ @@ -389,7 +291,7 @@ i32 engine_run(Instance* p, StateType initial_state, void* state_arg) { ticks++; } while( - !window_should_close(p->window) + !Platform_GLFW.window_should_close(p->window) && state != STATE_quit ); @@ -414,7 +316,7 @@ void engine_stop(Instance* p) { // } //} - destroy_window(p->window); + Platform_GLFW.window_destroy(p->window); free(p->resources); } -- cgit v1.3