diff options
Diffstat (limited to 'gui.c')
-rw-r--r-- | gui.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -49,6 +49,13 @@ struct GuiContext *init() { } void deinit(struct GuiContext *ctx) { + + // TODO this seems to end in memory access errors but ... why? + //SDL_DestroyTexture(texture); + //SDL_DestroyRenderer(renderer); + + SDL_Quit(); + free(ctx->pixels); free(ctx); } @@ -57,22 +64,18 @@ void gui_run(void) { struct GuiContext *ctx = init(); - // init SDL2 and create window SDL_Init(SDL_INIT_VIDEO); ctx->window = SDL_CreateWindow("LimoX", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE ); - // output video driver to stderr fprintf(stderr, "SDL2 video driver: %s\n", SDL_GetCurrentVideoDriver()); - // create and initialize renderer, texture and pixel buffer ctx->renderer = SDL_CreateRenderer(ctx->window, -1, 0); ctx->texture = SDL_CreateTexture(ctx->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, 640, 480); - // handle failed window creation if (ctx->window == NULL) { fprintf(stderr, "Failed to create SDL2 window!\n"); return; @@ -103,10 +106,4 @@ void gui_run(void) { deinit(ctx); - // TODO this seems to end in memory access errors but ... why? - //SDL_DestroyTexture(texture); - //SDL_DestroyRenderer(renderer); - - SDL_Quit(); - } |