From 523f6b460dcf1f864656a9a6ccc2a54d52f385c6 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 30 Mar 2016 21:20:07 +0200 Subject: Split common.h. --- src/renderer.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/renderer.h (limited to 'src/renderer.h') diff --git a/src/renderer.h b/src/renderer.h new file mode 100644 index 0000000..0c38e6d --- /dev/null +++ b/src/renderer.h @@ -0,0 +1,62 @@ +#ifndef _RENDERER_H +#define _RENDERER_H + +#include "common.h" +#include "physics.h" + +extern float r_color_white[4]; +extern float r_color_black[4]; +extern float r_color_red[4]; +extern float r_color_blue[4]; + +typedef struct r_window_s r_window; +struct r_window_s { + SDL_Window *window; + SDL_Renderer *renderer; + SDL_Texture *font_texture; + + r_window *prev, *next; +}; + +int r_init(void); +void r_quit(void); + +r_window *r_window_create(void); +void r_window_destroy(r_window *rw); + +void r_clear(r_window *rw, float *color); +void r_flip(r_window *rw); + +void r_clip_enable(r_window *rw, float x, float y, float w, float h); +void r_clip_disable(r_window *rw); +void r_draw_line(r_window *rw, float x0, float y0, float x1, float y1, + float *color); +void r_draw_rect(r_window *rw, float x, float y, float w, float h, + float *color); + +#define TEXT_CENTERX 0x0001 +#define TEXT_RIGHTX 0x0002 +float r_text_width(float h, char *text); +void r_draw_text(r_window *rw, float x, float y, float h, char *text, + float *color, int flags); + +typedef enum { + XSECTION_XY, + XSECTION_XZ, + XSECTION_YZ +} r_xsection_type; + +typedef struct { + SDL_Texture *texture; + float aspect_ratio; +} r_xsection; + +void r_xsection_create(r_xsection *xsection); +void r_xsection_destroy(r_xsection *xsection); +int r_xsection_update(r_window *rw, r_xsection *xsection, + phy_field_info *fi, float *field, + r_xsection_type type, float frac); +void r_xsection_draw(r_window *rw, r_xsection *xsection, + float x, float y, float w, float h); + +#endif // _RENDERER_H -- cgit