diff nuklear_ui/nuklear_sdl_gles2.h @ 1825:56a1171e29b9

Allow Nuklear UI to be used when OpenGL is disabled
author Michael Pavone <pavone@retrodev.com>
date Thu, 04 Apr 2019 23:08:45 -0700
parents fa9ae059e4d3
children e07fc3d473b2
line wrap: on
line diff
--- a/nuklear_ui/nuklear_sdl_gles2.h	Wed Apr 03 00:17:46 2019 -0700
+++ b/nuklear_ui/nuklear_sdl_gles2.h	Thu Apr 04 23:08:45 2019 -0700
@@ -47,6 +47,7 @@
 
 #include <string.h>
 
+#ifndef DISABLE_OPENGL
 struct nk_sdl_device {
     struct nk_buffer cmds;
     struct nk_draw_null_texture null;
@@ -69,10 +70,13 @@
     GLfloat uv[2];
     nk_byte col[4];
 };
+#endif
 
 static struct nk_sdl {
     SDL_Window *win;
+#ifndef DISABLE_OPENGL
     struct nk_sdl_device ogl;
+#endif
     struct nk_context ctx;
     struct nk_font_atlas atlas;
 } sdl;
@@ -85,7 +89,7 @@
 #define DECLARE_PRECISION
 #endif
 
-
+#ifndef DISABLE_OPENGL
 NK_API void
 nk_sdl_device_create(void)
 {
@@ -296,6 +300,7 @@
     glDisable(GL_BLEND);
     glDisable(GL_SCISSOR_TEST);
 }
+#endif
 
 static void
 nk_sdl_clipbard_paste(nk_handle usr, struct nk_text_edit *edit)
@@ -327,10 +332,10 @@
     sdl.ctx.clip.copy = nk_sdl_clipbard_copy;
     sdl.ctx.clip.paste = nk_sdl_clipbard_paste;
     sdl.ctx.clip.userdata = nk_handle_ptr(0);
-    nk_sdl_device_create();
     return &sdl.ctx;
 }
 
+#ifndef DISABLE_OPENGL
 NK_API void
 nk_sdl_font_stash_begin(struct nk_font_atlas **atlas)
 {
@@ -350,6 +355,7 @@
         nk_style_set_font(&sdl.ctx, &sdl.atlas.default_font->handle);
 
 }
+#endif
 
 NK_API int
 nk_sdl_handle_event(SDL_Event *evt)
@@ -447,7 +453,9 @@
 {
     nk_font_atlas_clear(&sdl.atlas);
     nk_free(&sdl.ctx);
+#ifndef DISABLE_OPENGL
     nk_sdl_device_destroy();
+#endif
     memset(&sdl, 0, sizeof(sdl));
 }