summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2016-03-30 20:29:08 +0200
committerPaweł Redman <pawel.redman@gmail.com>2016-03-30 20:29:08 +0200
commit745d5a072d8669d1bc35e7c1f28b75b3484542e8 (patch)
treeecc9cbd03511764e79251ec256c81cb8796f7c36 /src/common.h
parentbc50836fdcd20fda174df392c264cc6f03030cdf (diff)
Finish ITC; implement async sim control.
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/common.h b/src/common.h
index ee9c3fe..1b8e719 100644
--- a/src/common.h
+++ b/src/common.h
@@ -149,6 +149,28 @@ 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 {
@@ -164,12 +186,12 @@ typedef struct {
float *H;
} phy_field_em;
-/*
-typedef struct {
- int num;
- void *data;
-} phy_command;
-*/
+enum {
+ PHY_CMD_QUIT,
+ PHY_CMD_PAUSE,
+ PHY_CMD_RESUME,
+ PHY_CMD_STEP
+};
typedef struct {
phy_field_info field_info;
@@ -177,6 +199,9 @@ typedef struct {
float *field_eps, *field_mu; //permittivity and permeability
float time;
+ // UI stuff
+ bool running;
+ itc_chan ctl;
SDL_mutex *rotate_lock;
} phy_sim;
@@ -253,4 +278,3 @@ void ui_renderer_window_register(r_window *rw);
void ui_event(SDL_Event *event);
void ui_draw(phy_sim *sim);
-