diff options
author | FreeArtMan <dos21h@gmail.com> | 2015-10-01 19:54:52 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2015-10-01 19:54:52 +0100 |
commit | 240c02c5d64ee02659d0bcbbc61ef3680cbf8ea2 (patch) | |
tree | d8bc56d6d66b92b03334aec3b64b50403704eb4a /draw | |
parent | 588b76e576108a82bcf7abb660def28b4a99ba5a (diff) | |
download | radiola-240c02c5d64ee02659d0bcbbc61ef3680cbf8ea2.tar.gz radiola-240c02c5d64ee02659d0bcbbc61ef3680cbf8ea2.zip |
Added SDL waterfall prototype api
Diffstat (limited to 'draw')
-rw-r--r-- | draw/glui.c | 121 | ||||
-rw-r--r-- | draw/glui.h | 9 | ||||
-rw-r--r-- | draw/make.mk | 2 |
3 files changed, 130 insertions, 2 deletions
diff --git a/draw/glui.c b/draw/glui.c index e69de29..3e85646 100644 --- a/draw/glui.c +++ b/draw/glui.c @@ -0,0 +1,121 @@ +#include "glui.h" + +#define DEFAULT_TITLE "RADIOLA" +#define SCREEN_X 640 +#define SCREEN_Y 480 + +int glui_init( glui_t **t ) +{ + int ret=-1; + + glui_t *tui = NULL; + + tui = malloc( sizeof(glui_t) ); + if (tui == NULL) + { + return -1; + } + + memset(tui, 0, sizeof(glui_t)); + + if ( SDL_Init(SDL_INIT_VIDEO) != 0) + { + printf("Cannot init sdl\n"); + return -1; + } + + tui->win = SDL_CreateWindow("Hello World!", 100, 100, SCREEN_X, SCREEN_Y, SDL_WINDOW_SHOWN); + if (tui->win == NULL) + { + printf("Couldnt create SDL window\n"); + return -1; + } + + tui->rend = SDL_CreateRenderer( tui->win, -1, SDL_RENDERER_ACCELERATED); + + + + return ret; +} + + +//init waterfall +int glui_waterfall( glui_t **t, glui_waterfall_t **w ) +{ + int ret=-1; + + + return ret; +} + + +//first draw, draw all buffer +int glui_waterfall_draw( glui_waterfall_t *w ) +{ + int ret=-1; + + + return ret; +} + + +//redraw only changed lines +int glui_waterfall_redraw( glui_waterfall_t *w ) +{ + int ret=-1; + + + return ret; +} + + +//update params of waterfall and then need to draw not redraw +int glui_waterfall_update( glui_t *w ) +{ + int ret=-1; + + + return ret; +} + + +//push one line of data to buffer +int glui_waterfall_data( glui_t *w, int len, uint8_t *buf ) +{ + int ret=-1; + + + return ret; +} + + +//return color +uint8_t glui_waterfall_color( uint8_t d ) +{ + uint8_t c; + + + return c; +} + + +//close terminal ui +int glui_close( glui_t *t ) +{ + int ret=0; + + if ( t->rend ) + { + SDL_DestroyRenderer( t->rend ); + } + + if ( t->win != NULL ) + { + SDL_DestroyWindow( t->win ); + } + + SDL_Quit(); + + + return ret; +}
\ No newline at end of file diff --git a/draw/glui.h b/draw/glui.h index d55f931..f9f9bdf 100644 --- a/draw/glui.h +++ b/draw/glui.h @@ -8,6 +8,8 @@ #include <termios.h> #include <unistd.h> +#include <SDL2/SDL.h> + //to draw waterfall typedef struct glui_waterfall_t { @@ -19,6 +21,9 @@ typedef struct glui_waterfall_t typedef struct glui_t { + SDL_Window *win; + SDL_Renderer *rend; + glui_waterfall_t *wf; } glui_t; @@ -37,4 +42,6 @@ int glui_waterfall_data( glui_t *w, int len, uint8_t *buf ); //return color uint8_t glui_waterfall_color( uint8_t d ); //close terminal ui -int glui_close( glui_t *t );
\ No newline at end of file +int glui_close( glui_t *t ); + +#endif
\ No newline at end of file diff --git a/draw/make.mk b/draw/make.mk index 9756446..1c60780 100644 --- a/draw/make.mk +++ b/draw/make.mk @@ -1,7 +1,7 @@ DIR_DRAW = draw/ SOURCES_DRAW += draw/glui.c draw/tui.c draw/ui.c OBJECTS_DRAW += $(SOURCES_DRAW:.c=.o) -LDFLAGS += -lGL +LDFLAGS += -lGL `sdl2-config --cflags --libs` OBJECTS_DIR_DRAW += $(subst $(DIR_DRAW),$(BUILD_DIR)$(DIR_DRAW),$(OBJECTS_DRAW)) |