From 3489caac85e458aa8fe2abec6ed7fd92c2fd2f53 Mon Sep 17 00:00:00 2001 From: vurtun Date: Fri, 27 Mar 2015 17:19:49 +0100 Subject: [PATCH] moved opengl to demo directory --- Makefile | 2 +- opengl.c => demo/opengl.c | 8 +++----- gui.c | 20 ++++++++++---------- gui.h | 9 +-------- 4 files changed, 15 insertions(+), 24 deletions(-) rename opengl.c => demo/opengl.c (99%) diff --git a/Makefile b/Makefile index e52844be..aa8efc87 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ CFLAGS += -Wswitch-default -Wundef -Wno-unused -Wstrict-overflow=5 -Wsign-conver CFLAGS += -Winit-self -Wstrict-aliasing -fsanitize=address -fsanitize=undefined -ftrapv CFLAGS += -Wswitch-enum -Winvalid-pch -Wbad-function-cast -SRC = gui.c opengl.c +SRC = gui.c demo/opengl.c OBJ = $(SRC:.c=.o) # Modes diff --git a/opengl.c b/demo/opengl.c similarity index 99% rename from opengl.c rename to demo/opengl.c index e19eeab1..17658675 100644 --- a/opengl.c +++ b/demo/opengl.c @@ -12,7 +12,7 @@ #include #include -#include "gui.h" +#include "../gui.h" /* macros */ #define LEN(a) (sizeof(a)/sizeof(a)[0]) @@ -448,10 +448,8 @@ main(int argc, char *argv[]) gui_begin_panel(ctx, subpanel, "Error", GUI_PANEL_HEADER|GUI_PANEL_BORDER|GUI_PANEL_MOVEABLE); gui_panel_layout(subpanel, 30, 2); - if (gui_panel_button_text(subpanel, "ok", 2, GUI_BUTTON_SWITCH)) - break; - if (gui_panel_button_text(subpanel, "cancel", 6, GUI_BUTTON_SWITCH)) - break; + if (gui_panel_button_text(subpanel, "ok", 2, GUI_BUTTON_SWITCH)) break; + if (gui_panel_button_text(subpanel, "cancel", 6, GUI_BUTTON_SWITCH)) break; gui_end_panel(ctx, subpanel, NULL); gui_end(ctx, &output, NULL); /* ---------------------------------------------------------*/ diff --git a/gui.c b/gui.c index adc6ce52..cd610f55 100644 --- a/gui.c +++ b/gui.c @@ -5,6 +5,12 @@ */ #include "gui.h" +#ifndef NDEBUG +#include +#else +#define assert(expr) +#endif + #define NULL (void*)0 #define UTF_INVALID 0xFFFD #define MAX_NUMBER_BUFFER 64 @@ -20,12 +26,6 @@ #define ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0) #define ALIGN(x, mask) (void*)((gui_size)((gui_byte*)(x) + (mask-1)) & ~(mask-1)) -#ifndef NDEBUG -#include -#else -#define assert(expr) -#endif - #define col_load(c,j,k,l,m) (c).r = (j), (c).g = (k), (c).b = (l), (c).a = (m) #define vec2_load(v,a,b) (v).x = (a), (v).y = (b) #define vec2_mov(to,from) (to).x = (from).x, (to).y = (from).y @@ -303,6 +303,7 @@ gui_input_char(struct gui_input *in, const gui_glyph glyph) { gui_size len = 0; gui_long unicode; + assert(in); if (!in) return; len = utf_decode(glyph, &unicode, GUI_UTF_SIZE); if (len && ((in->text_len + len) < GUI_INPUT_MAX)) { @@ -2459,13 +2460,13 @@ gui_panel_frame_end(struct gui_panel *tab) gui_panel_end(tab); } -gui_uint +void gui_panel_end(struct gui_panel *panel) { const struct gui_config *config; assert(panel); - if (!panel) return 0; - if (panel->flags & GUI_PANEL_HIDDEN) return 0; + if (!panel) return; + if (panel->flags & GUI_PANEL_HIDDEN) return; gui_pop_clip(panel->out); panel->at_y += panel->row_height; @@ -2511,7 +2512,6 @@ gui_panel_end(struct gui_panel *panel) gui_draw_line(panel->out, panel->x + width, panel->y, panel->x + width, padding_y, config->colors[GUI_COLOR_BORDER]); } - return GUI_OK; } struct gui_context* diff --git a/gui.h b/gui.h index 8a042ddf..1e7da9d3 100644 --- a/gui.h +++ b/gui.h @@ -75,13 +75,6 @@ struct gui_input { struct gui_vec2 mouse_clicked_pos; }; -enum gui_error { - GUI_OK = 0x00, - GUI_ERROR_NOMEM = 0x01, - GUI_ERROR_INVAL = 0x02, - GUI_ERROR_INVOP = 0x04 -}; - struct gui_vertex { struct gui_vec2 pos; struct gui_texCoord uv; @@ -444,7 +437,7 @@ gui_float gui_panel_list(struct gui_panel*, gui_bool *selected, const char *item gui_size item_count, gui_float offset, gui_float item_height); void gui_panel_frame_begin(struct gui_panel *panel, struct gui_panel *tab, const char *title); void gui_panel_frame_end(struct gui_panel*); -gui_uint gui_panel_end(struct gui_panel*); +void gui_panel_end(struct gui_panel*); /* Context */ struct gui_context;