sdl_renderer: Update code
This commit is contained in:
parent
1f562ecb94
commit
cd4990834f
@ -9,7 +9,7 @@
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
@ -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 <SDL.h>
|
||||
#include <SDL2/SDL.h>
|
||||
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 */
|
Loading…
Reference in New Issue
Block a user