summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2016-03-30 21:20:07 +0200
committerPaweł Redman <pawel.redman@gmail.com>2016-03-30 21:20:07 +0200
commit523f6b460dcf1f864656a9a6ccc2a54d52f385c6 (patch)
treedd457448a2518ce45ac36ba427c12491f01d7e76 /src/common.h
parent745d5a072d8669d1bc35e7c1f28b75b3484542e8 (diff)
Split common.h.
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h141
1 files changed, 6 insertions, 135 deletions
diff --git a/src/common.h b/src/common.h
index 1b8e719..8933749 100644
--- a/src/common.h
+++ b/src/common.h
@@ -1,3 +1,7 @@
+#ifndef _COMMON_H
+#define _COMMON_H
+
+#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
@@ -8,21 +12,16 @@
#define PROGRAM_NAME "Symulator pól elektromagnetycznych"
-#include <stdio.h>
-#define con_printf printf
+#define con_printf printf // TODO?
#define max2(a, b) ((a) > (b) ? (a) : (b))
#define max3(a, b, c) (max2(max2(a, b), c))
#define min2(a, b) ((a) < (b) ? (a) : (b))
#define min3(a, b, c) (min2(min2(a, b), c))
-// main
-
char *va(const char *fmt, ...);
int64_t get_time(void);
-// math
-
typedef float vec_t;
typedef vec_t vec2_t[2];
typedef vec_t vec3_t[3];
@@ -149,132 +148,4 @@ static inline void mst2_dump(mst2_t M)
printf("[%f\t%f\t%f]\n", 0.0, 0.0, 1.0);
}
-// itc
-
-typedef struct itc_message_s itc_message;
-struct itc_message_s {
- int number;
- void *data;
-
- itc_message *older, *newer;
-};
-
-typedef struct {
- itc_message *newest, *oldest;
- SDL_mutex *mutex;
- SDL_sem *sem;
-} itc_chan;
-
-void itc_chan_create(itc_chan *chan);
-void itc_chan_destroy(itc_chan *chan);
-void itc_chan_push(itc_chan *chan, int number, void *data);
-int itc_chan_pop(itc_chan *chan, int *number, void **data);
-int itc_chan_pop_block(itc_chan *chan, int *number, void **data);
-
-// physics
-
-typedef struct {
- size_t width, height, depth;
- size_t zstr, ystr, xstr, size; // strides in no. of points (not bytes)
- size_t zstr1, ystr1, xstr1, size1; // same as above but for associated
- // scalar fields
- float spacing; // in meters
-} phy_field_info;
-
-typedef struct {
- float *E;
- float *H;
-} phy_field_em;
-
-enum {
- PHY_CMD_QUIT,
- PHY_CMD_PAUSE,
- PHY_CMD_RESUME,
- PHY_CMD_STEP
-};
-
-typedef struct {
- phy_field_info field_info;
- phy_field_em fields[3];
- float *field_eps, *field_mu; //permittivity and permeability
- float time;
-
- // UI stuff
- bool running;
- itc_chan ctl;
- SDL_mutex *rotate_lock;
-} phy_sim;
-
-void phy_sim_destroy(phy_sim *sim);
-int phy_sim_create(phy_sim *sim);
-void phy_sim_compute_const_fields(phy_sim *sim);
-void phy_sim_step(phy_sim *sim, float dt);
-
-int phy_thread(phy_sim *sim);
-
-// renderer
-
-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);
-
-// ui
-
-int ui_init(void);
-void ui_quit(void);
-
-void ui_renderer_window_register(r_window *rw);
-
-void ui_event(SDL_Event *event);
-void ui_draw(phy_sim *sim);
+#endif // _COMMON_H