From cd4990834f97614178843a6589162a34c676a156 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 6 Jan 2022 21:55:20 -0500 Subject: [PATCH] sdl_renderer: Update code --- .../Makefile | 0 demo/{sdl_sdlrenderer => sdl_renderer}/main.c | 19 +++++++++++++------ .../nuklear_sdl_renderer.h} | 17 +++++++++-------- 3 files changed, 22 insertions(+), 14 deletions(-) rename demo/{sdl_sdlrenderer => sdl_renderer}/Makefile (100%) rename demo/{sdl_sdlrenderer => sdl_renderer}/main.c (96%) rename demo/{sdl_sdlrenderer/nuklear_sdl_sdlrenderer.h => sdl_renderer/nuklear_sdl_renderer.h} (98%) diff --git a/demo/sdl_sdlrenderer/Makefile b/demo/sdl_renderer/Makefile similarity index 100% rename from demo/sdl_sdlrenderer/Makefile rename to demo/sdl_renderer/Makefile diff --git a/demo/sdl_sdlrenderer/main.c b/demo/sdl_renderer/main.c similarity index 96% rename from demo/sdl_sdlrenderer/main.c rename to demo/sdl_renderer/main.c index 74dab49..77be381 100644 --- a/demo/sdl_sdlrenderer/main.c +++ b/demo/sdl_renderer/main.c @@ -9,7 +9,7 @@ #include #include -#include +#include #define NK_INCLUDE_FIXED_TYPES #define NK_INCLUDE_STANDARD_IO @@ -19,9 +19,9 @@ #define NK_INCLUDE_FONT_BAKING #define NK_INCLUDE_DEFAULT_FONT #define NK_IMPLEMENTATION -#define NK_SDL_GL2_IMPLEMENTATION +#define NK_SDL_RENDERER_IMPLEMENTATION #include "../../nuklear.h" -#include "nuklear_sdl_sdlrenderer.h" +#include "nuklear_sdl_renderer.h" #define WINDOW_WIDTH 1200 #define WINDOW_HEIGHT 800 @@ -42,6 +42,7 @@ #ifdef INCLUDE_ALL #define INCLUDE_STYLE #define INCLUDE_CALCULATOR + #define INCLUDE_CANVAS #define INCLUDE_OVERVIEW #define INCLUDE_NODE_EDITOR #endif @@ -52,6 +53,9 @@ #ifdef INCLUDE_CALCULATOR #include "../calculator.c" #endif +#ifdef INCLUDE_CANVAS + #include "../canvas.c" +#endif #ifdef INCLUDE_OVERVIEW #include "../overview.c" #endif @@ -93,7 +97,7 @@ main(int argc, char *argv[]) flags |= SDL_RENDERER_ACCELERATED; flags |= SDL_RENDERER_PRESENTVSYNC; -#if 0 +#if 0 SDL_SetHint(SDL_HINT_RENDER_BATCHING, "1"); SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); @@ -182,6 +186,9 @@ main(int argc, char *argv[]) #ifdef INCLUDE_CALCULATOR calculator(ctx); #endif + #ifdef INCLUDE_CANVAS + canvas(ctx); + #endif #ifdef INCLUDE_OVERVIEW overview(ctx); #endif @@ -192,9 +199,9 @@ main(int argc, char *argv[]) SDL_SetRenderDrawColor(renderer, bg.r * 255, bg.g * 255, bg.b * 255, bg.a * 255); SDL_RenderClear(renderer); - + nk_sdl_render(NK_ANTI_ALIASING_ON); - + SDL_RenderPresent(renderer); } diff --git a/demo/sdl_sdlrenderer/nuklear_sdl_sdlrenderer.h b/demo/sdl_renderer/nuklear_sdl_renderer.h similarity index 98% rename from demo/sdl_sdlrenderer/nuklear_sdl_sdlrenderer.h rename to demo/sdl_renderer/nuklear_sdl_renderer.h index dc969b3..03fd3e5 100644 --- a/demo/sdl_sdlrenderer/nuklear_sdl_sdlrenderer.h +++ b/demo/sdl_renderer/nuklear_sdl_renderer.h @@ -1,5 +1,5 @@ /* - * Nuklear - 1.32.0 - public domain + * Nuklear - 4.9.4 - public domain */ /* * ============================================================== @@ -8,10 +8,10 @@ * * =============================================================== */ -#ifndef NK_SDL_GL2_H_ -#define NK_SDL_GL2_H_ +#ifndef NK_SDL_RENDERER_H_ +#define NK_SDL_RENDERER_H_ -#include +#include NK_API struct nk_context* nk_sdl_init(SDL_Window *win, SDL_Renderer *renderer); NK_API void nk_sdl_font_stash_begin(struct nk_font_atlas **atlas); NK_API void nk_sdl_font_stash_end(void); @@ -19,7 +19,8 @@ NK_API int nk_sdl_handle_event(SDL_Event *evt); NK_API void nk_sdl_render(enum nk_anti_aliasing); NK_API void nk_sdl_shutdown(void); -#endif +#endif /* NK_SDL_RENDERER_H_ */ + /* * ============================================================== * @@ -27,7 +28,7 @@ NK_API void nk_sdl_shutdown(void); * * =============================================================== */ -#ifdef NK_SDL_GL2_IMPLEMENTATION +#ifdef NK_SDL_RENDERER_IMPLEMENTATION struct nk_sdl_device { struct nk_buffer cmds; @@ -112,7 +113,7 @@ nk_sdl_render(enum nk_anti_aliasing AA) /* iterate over and execute each draw command */ offset = (const nk_draw_index*)nk_buffer_memory_const(&ebuf); - + clipping_enabled = SDL_RenderIsClipEnabled(sdl.renderer); SDL_RenderGetClipRect(sdl.renderer, &saved_clip); @@ -324,4 +325,4 @@ void nk_sdl_shutdown(void) memset(&sdl, 0, sizeof(sdl)); } -#endif +#endif /* NK_SDL_RENDERER_IMPLEMENTATION */