fx: ui fixes
parent
f66f0336c2
commit
76b256ab02
|
@ -81,16 +81,16 @@ int main() {
|
||||||
|
|
||||||
// fx: load all post fx files in all subdirs. enable a few filters by default
|
// fx: load all post fx files in all subdirs. enable a few filters by default
|
||||||
fx_load("fx**.fs");
|
fx_load("fx**.fs");
|
||||||
|
fx_enable(fx_find("fxCRT2.fs"), 1);
|
||||||
fx_enable(fx_find("fxGrain.fs"), 1);
|
fx_enable(fx_find("fxGrain.fs"), 1);
|
||||||
fx_enable(fx_find("fxContrast.fs"), 1);
|
fx_enable(fx_find("fxContrast.fs"), 1);
|
||||||
fx_enable(fx_find("fxVignette.fs"), 1);
|
fx_enable(fx_find("fxVignette.fs"), 1);
|
||||||
fx_enable(fx_find("fxCRT2.fs"), 1);
|
|
||||||
|
|
||||||
// sort them
|
// sort them
|
||||||
fx_order(fx_find("fxCRT2.fs"), 1);
|
fx_order(fx_find("fxCRT2.fs"), 0);
|
||||||
fx_order(fx_find("fxGrain.fs"), 2);
|
fx_order(fx_find("fxGrain.fs"), 1);
|
||||||
fx_order(fx_find("fxContrast.fs"), 3);
|
fx_order(fx_find("fxContrast.fs"), 2);
|
||||||
fx_order(fx_find("fxVignette.fs"), 4);
|
fx_order(fx_find("fxVignette.fs"), 3);
|
||||||
|
|
||||||
// demo loop
|
// demo loop
|
||||||
while (window_swap() && !input_down(KEY_ESC)) {
|
while (window_swap() && !input_down(KEY_ESC)) {
|
||||||
|
|
|
@ -372235,6 +372235,7 @@ bool postfx_enabled(postfx *fx, int pass_number);
|
||||||
bool postfx_enable(postfx *fx, int pass_number, bool enabled);
|
bool postfx_enable(postfx *fx, int pass_number, bool enabled);
|
||||||
// bool postfx_toggle(postfx *fx, int pass_number);
|
// bool postfx_toggle(postfx *fx, int pass_number);
|
||||||
void postfx_clear(postfx *fx);
|
void postfx_clear(postfx *fx);
|
||||||
|
void postfx_order(postfx *fx, int pass, unsigned priority);
|
||||||
|
|
||||||
char* postfx_name(postfx *fx, int slot);
|
char* postfx_name(postfx *fx, int slot);
|
||||||
|
|
||||||
|
@ -372245,7 +372246,7 @@ struct passfx {
|
||||||
char *name;
|
char *name;
|
||||||
unsigned program;
|
unsigned program;
|
||||||
int uniforms[16];
|
int uniforms[16];
|
||||||
unsigned priority; // 0xFFFFFF
|
unsigned priority;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -372257,8 +372258,6 @@ struct postfx {
|
||||||
array(passfx) pass;
|
array(passfx) pass;
|
||||||
// global enable flag
|
// global enable flag
|
||||||
bool enabled;
|
bool enabled;
|
||||||
//
|
|
||||||
int num_loaded;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -372305,10 +372304,14 @@ int postfx_find(postfx *fx, const char *name) {
|
||||||
|
|
||||||
static
|
static
|
||||||
int postfx_sort_fn(const void *a, const void *b) {
|
int postfx_sort_fn(const void *a, const void *b) {
|
||||||
return ((passfx*)a)->priority - ((passfx*)b)->priority;
|
unsigned p1 = ((passfx*)a)->priority;
|
||||||
|
unsigned p2 = ((passfx*)b)->priority;
|
||||||
|
return (p1 > p2) - (p1 < p2);
|
||||||
}
|
}
|
||||||
void postfx_order(postfx *fx, int pass, unsigned priority) {
|
void postfx_order(postfx *fx, int pass, unsigned priority) {
|
||||||
if (pass < 0 || pass >= array_count(fx->pass)) return;
|
if (pass < 0 || pass >= array_count(fx->pass)) return;
|
||||||
|
if (priority >= array_count(fx->pass)) return;
|
||||||
|
fx->pass[priority].priority = pass;
|
||||||
fx->pass[pass].priority = priority;
|
fx->pass[pass].priority = priority;
|
||||||
array_sort(fx->pass, postfx_sort_fn);
|
array_sort(fx->pass, postfx_sort_fn);
|
||||||
}
|
}
|
||||||
|
@ -372321,7 +372324,7 @@ int postfx_load_from_mem( postfx *fx, const char *name, const char *fs ) {
|
||||||
array_push(fx->pass, pass);
|
array_push(fx->pass, pass);
|
||||||
passfx *p = array_back(fx->pass);
|
passfx *p = array_back(fx->pass);
|
||||||
p->name = STRDUP(name);
|
p->name = STRDUP(name);
|
||||||
p->priority = ~0u;
|
p->priority = array_count(fx->pass)-1;
|
||||||
|
|
||||||
// preload stuff
|
// preload stuff
|
||||||
static const char *vs = 0;
|
static const char *vs = 0;
|
||||||
|
@ -372403,6 +372406,14 @@ int ui_postfx(postfx *fx, int pass) {
|
||||||
int on = ui_enabled();
|
int on = ui_enabled();
|
||||||
( postfx_enabled(fx,pass) ? ui_enable : ui_disable )();
|
( postfx_enabled(fx,pass) ? ui_enable : ui_disable )();
|
||||||
int rc = ui_shader(fx->pass[pass].program);
|
int rc = ui_shader(fx->pass[pass].program);
|
||||||
|
ui_separator();
|
||||||
|
int btn = ui_buttons(2, "Move up", "Move down");
|
||||||
|
if (btn == 1) {
|
||||||
|
postfx_order(fx, pass, fx->pass[pass].priority-1);
|
||||||
|
}
|
||||||
|
else if (btn == 2) {
|
||||||
|
postfx_order(fx, pass, fx->pass[pass].priority+1);
|
||||||
|
}
|
||||||
( on ? ui_enable : ui_disable )();
|
( on ? ui_enable : ui_disable )();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -372575,7 +372586,7 @@ void fx_enable(int pass, int enabled) {
|
||||||
postfx_enable(&fx, pass, enabled);
|
postfx_enable(&fx, pass, enabled);
|
||||||
}
|
}
|
||||||
void fx_enable_all(int enabled) {
|
void fx_enable_all(int enabled) {
|
||||||
for( int i = 0; i < fx.num_loaded; ++i ) fx_enable(i, enabled);
|
for( int i = 0; i < array_count(fx.pass); ++i ) fx_enable(i, enabled);
|
||||||
}
|
}
|
||||||
char *fx_name(int pass) {
|
char *fx_name(int pass) {
|
||||||
return postfx_name(&fx, pass);
|
return postfx_name(&fx, pass);
|
||||||
|
@ -372590,10 +372601,10 @@ int ui_fx(int pass) {
|
||||||
return ui_postfx(&fx, pass);
|
return ui_postfx(&fx, pass);
|
||||||
}
|
}
|
||||||
int ui_fxs() {
|
int ui_fxs() {
|
||||||
if(!fx.num_loaded) return ui_label(ICON_MD_WARNING " No Post FXs with annotations loaded."), 0;
|
if(!array_count(fx.pass)) return ui_label(ICON_MD_WARNING " No Post FXs with annotations loaded."), 0;
|
||||||
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
for( int i = 0; i < 64; ++i ) {
|
for( int i = 0; i < array_count(fx.pass); ++i ) {
|
||||||
char *name = fx_name(i); if( !name ) break;
|
char *name = fx_name(i); if( !name ) break;
|
||||||
bool b = fx_enabled(i);
|
bool b = fx_enabled(i);
|
||||||
if( ui_bool(name, &b) ) fx_enable(i, fx_enabled(i) ^ 1);
|
if( ui_bool(name, &b) ) fx_enable(i, fx_enabled(i) ^ 1);
|
||||||
|
|
|
@ -2216,6 +2216,7 @@ bool postfx_enabled(postfx *fx, int pass_number);
|
||||||
bool postfx_enable(postfx *fx, int pass_number, bool enabled);
|
bool postfx_enable(postfx *fx, int pass_number, bool enabled);
|
||||||
// bool postfx_toggle(postfx *fx, int pass_number);
|
// bool postfx_toggle(postfx *fx, int pass_number);
|
||||||
void postfx_clear(postfx *fx);
|
void postfx_clear(postfx *fx);
|
||||||
|
void postfx_order(postfx *fx, int pass, unsigned priority);
|
||||||
|
|
||||||
char* postfx_name(postfx *fx, int slot);
|
char* postfx_name(postfx *fx, int slot);
|
||||||
|
|
||||||
|
@ -2226,7 +2227,7 @@ struct passfx {
|
||||||
char *name;
|
char *name;
|
||||||
unsigned program;
|
unsigned program;
|
||||||
int uniforms[16];
|
int uniforms[16];
|
||||||
unsigned priority; // 0xFFFFFF
|
unsigned priority;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2238,8 +2239,6 @@ struct postfx {
|
||||||
array(passfx) pass;
|
array(passfx) pass;
|
||||||
// global enable flag
|
// global enable flag
|
||||||
bool enabled;
|
bool enabled;
|
||||||
//
|
|
||||||
int num_loaded;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -2286,10 +2285,14 @@ int postfx_find(postfx *fx, const char *name) {
|
||||||
|
|
||||||
static
|
static
|
||||||
int postfx_sort_fn(const void *a, const void *b) {
|
int postfx_sort_fn(const void *a, const void *b) {
|
||||||
return ((passfx*)a)->priority - ((passfx*)b)->priority;
|
unsigned p1 = ((passfx*)a)->priority;
|
||||||
|
unsigned p2 = ((passfx*)b)->priority;
|
||||||
|
return (p1 > p2) - (p1 < p2);
|
||||||
}
|
}
|
||||||
void postfx_order(postfx *fx, int pass, unsigned priority) {
|
void postfx_order(postfx *fx, int pass, unsigned priority) {
|
||||||
if (pass < 0 || pass >= array_count(fx->pass)) return;
|
if (pass < 0 || pass >= array_count(fx->pass)) return;
|
||||||
|
if (priority >= array_count(fx->pass)) return;
|
||||||
|
fx->pass[priority].priority = pass;
|
||||||
fx->pass[pass].priority = priority;
|
fx->pass[pass].priority = priority;
|
||||||
array_sort(fx->pass, postfx_sort_fn);
|
array_sort(fx->pass, postfx_sort_fn);
|
||||||
}
|
}
|
||||||
|
@ -2302,7 +2305,7 @@ int postfx_load_from_mem( postfx *fx, const char *name, const char *fs ) {
|
||||||
array_push(fx->pass, pass);
|
array_push(fx->pass, pass);
|
||||||
passfx *p = array_back(fx->pass);
|
passfx *p = array_back(fx->pass);
|
||||||
p->name = STRDUP(name);
|
p->name = STRDUP(name);
|
||||||
p->priority = ~0u;
|
p->priority = array_count(fx->pass)-1;
|
||||||
|
|
||||||
// preload stuff
|
// preload stuff
|
||||||
static const char *vs = 0;
|
static const char *vs = 0;
|
||||||
|
@ -2384,6 +2387,14 @@ int ui_postfx(postfx *fx, int pass) {
|
||||||
int on = ui_enabled();
|
int on = ui_enabled();
|
||||||
( postfx_enabled(fx,pass) ? ui_enable : ui_disable )();
|
( postfx_enabled(fx,pass) ? ui_enable : ui_disable )();
|
||||||
int rc = ui_shader(fx->pass[pass].program);
|
int rc = ui_shader(fx->pass[pass].program);
|
||||||
|
ui_separator();
|
||||||
|
int btn = ui_buttons(2, "Move up", "Move down");
|
||||||
|
if (btn == 1) {
|
||||||
|
postfx_order(fx, pass, fx->pass[pass].priority-1);
|
||||||
|
}
|
||||||
|
else if (btn == 2) {
|
||||||
|
postfx_order(fx, pass, fx->pass[pass].priority+1);
|
||||||
|
}
|
||||||
( on ? ui_enable : ui_disable )();
|
( on ? ui_enable : ui_disable )();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -2556,7 +2567,7 @@ void fx_enable(int pass, int enabled) {
|
||||||
postfx_enable(&fx, pass, enabled);
|
postfx_enable(&fx, pass, enabled);
|
||||||
}
|
}
|
||||||
void fx_enable_all(int enabled) {
|
void fx_enable_all(int enabled) {
|
||||||
for( int i = 0; i < fx.num_loaded; ++i ) fx_enable(i, enabled);
|
for( int i = 0; i < array_count(fx.pass); ++i ) fx_enable(i, enabled);
|
||||||
}
|
}
|
||||||
char *fx_name(int pass) {
|
char *fx_name(int pass) {
|
||||||
return postfx_name(&fx, pass);
|
return postfx_name(&fx, pass);
|
||||||
|
@ -2571,10 +2582,10 @@ int ui_fx(int pass) {
|
||||||
return ui_postfx(&fx, pass);
|
return ui_postfx(&fx, pass);
|
||||||
}
|
}
|
||||||
int ui_fxs() {
|
int ui_fxs() {
|
||||||
if(!fx.num_loaded) return ui_label(ICON_MD_WARNING " No Post FXs with annotations loaded."), 0;
|
if(!array_count(fx.pass)) return ui_label(ICON_MD_WARNING " No Post FXs with annotations loaded."), 0;
|
||||||
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
for( int i = 0; i < 64; ++i ) {
|
for( int i = 0; i < array_count(fx.pass); ++i ) {
|
||||||
char *name = fx_name(i); if( !name ) break;
|
char *name = fx_name(i); if( !name ) break;
|
||||||
bool b = fx_enabled(i);
|
bool b = fx_enabled(i);
|
||||||
if( ui_bool(name, &b) ) fx_enable(i, fx_enabled(i) ^ 1);
|
if( ui_bool(name, &b) ) fx_enable(i, fx_enabled(i) ^ 1);
|
||||||
|
|
27
engine/v4k.c
27
engine/v4k.c
|
@ -19388,6 +19388,7 @@ bool postfx_enabled(postfx *fx, int pass_number);
|
||||||
bool postfx_enable(postfx *fx, int pass_number, bool enabled);
|
bool postfx_enable(postfx *fx, int pass_number, bool enabled);
|
||||||
// bool postfx_toggle(postfx *fx, int pass_number);
|
// bool postfx_toggle(postfx *fx, int pass_number);
|
||||||
void postfx_clear(postfx *fx);
|
void postfx_clear(postfx *fx);
|
||||||
|
void postfx_order(postfx *fx, int pass, unsigned priority);
|
||||||
|
|
||||||
char* postfx_name(postfx *fx, int slot);
|
char* postfx_name(postfx *fx, int slot);
|
||||||
|
|
||||||
|
@ -19398,7 +19399,7 @@ struct passfx {
|
||||||
char *name;
|
char *name;
|
||||||
unsigned program;
|
unsigned program;
|
||||||
int uniforms[16];
|
int uniforms[16];
|
||||||
unsigned priority; // 0xFFFFFF
|
unsigned priority;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19410,8 +19411,6 @@ struct postfx {
|
||||||
array(passfx) pass;
|
array(passfx) pass;
|
||||||
// global enable flag
|
// global enable flag
|
||||||
bool enabled;
|
bool enabled;
|
||||||
//
|
|
||||||
int num_loaded;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -19458,10 +19457,14 @@ int postfx_find(postfx *fx, const char *name) {
|
||||||
|
|
||||||
static
|
static
|
||||||
int postfx_sort_fn(const void *a, const void *b) {
|
int postfx_sort_fn(const void *a, const void *b) {
|
||||||
return ((passfx*)a)->priority - ((passfx*)b)->priority;
|
unsigned p1 = ((passfx*)a)->priority;
|
||||||
|
unsigned p2 = ((passfx*)b)->priority;
|
||||||
|
return (p1 > p2) - (p1 < p2);
|
||||||
}
|
}
|
||||||
void postfx_order(postfx *fx, int pass, unsigned priority) {
|
void postfx_order(postfx *fx, int pass, unsigned priority) {
|
||||||
if (pass < 0 || pass >= array_count(fx->pass)) return;
|
if (pass < 0 || pass >= array_count(fx->pass)) return;
|
||||||
|
if (priority >= array_count(fx->pass)) return;
|
||||||
|
fx->pass[priority].priority = pass;
|
||||||
fx->pass[pass].priority = priority;
|
fx->pass[pass].priority = priority;
|
||||||
array_sort(fx->pass, postfx_sort_fn);
|
array_sort(fx->pass, postfx_sort_fn);
|
||||||
}
|
}
|
||||||
|
@ -19474,7 +19477,7 @@ int postfx_load_from_mem( postfx *fx, const char *name, const char *fs ) {
|
||||||
array_push(fx->pass, pass);
|
array_push(fx->pass, pass);
|
||||||
passfx *p = array_back(fx->pass);
|
passfx *p = array_back(fx->pass);
|
||||||
p->name = STRDUP(name);
|
p->name = STRDUP(name);
|
||||||
p->priority = ~0u;
|
p->priority = array_count(fx->pass)-1;
|
||||||
|
|
||||||
// preload stuff
|
// preload stuff
|
||||||
static const char *vs = 0;
|
static const char *vs = 0;
|
||||||
|
@ -19556,6 +19559,14 @@ int ui_postfx(postfx *fx, int pass) {
|
||||||
int on = ui_enabled();
|
int on = ui_enabled();
|
||||||
( postfx_enabled(fx,pass) ? ui_enable : ui_disable )();
|
( postfx_enabled(fx,pass) ? ui_enable : ui_disable )();
|
||||||
int rc = ui_shader(fx->pass[pass].program);
|
int rc = ui_shader(fx->pass[pass].program);
|
||||||
|
ui_separator();
|
||||||
|
int btn = ui_buttons(2, "Move up", "Move down");
|
||||||
|
if (btn == 1) {
|
||||||
|
postfx_order(fx, pass, fx->pass[pass].priority-1);
|
||||||
|
}
|
||||||
|
else if (btn == 2) {
|
||||||
|
postfx_order(fx, pass, fx->pass[pass].priority+1);
|
||||||
|
}
|
||||||
( on ? ui_enable : ui_disable )();
|
( on ? ui_enable : ui_disable )();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -19728,7 +19739,7 @@ void fx_enable(int pass, int enabled) {
|
||||||
postfx_enable(&fx, pass, enabled);
|
postfx_enable(&fx, pass, enabled);
|
||||||
}
|
}
|
||||||
void fx_enable_all(int enabled) {
|
void fx_enable_all(int enabled) {
|
||||||
for( int i = 0; i < fx.num_loaded; ++i ) fx_enable(i, enabled);
|
for( int i = 0; i < array_count(fx.pass); ++i ) fx_enable(i, enabled);
|
||||||
}
|
}
|
||||||
char *fx_name(int pass) {
|
char *fx_name(int pass) {
|
||||||
return postfx_name(&fx, pass);
|
return postfx_name(&fx, pass);
|
||||||
|
@ -19743,10 +19754,10 @@ int ui_fx(int pass) {
|
||||||
return ui_postfx(&fx, pass);
|
return ui_postfx(&fx, pass);
|
||||||
}
|
}
|
||||||
int ui_fxs() {
|
int ui_fxs() {
|
||||||
if(!fx.num_loaded) return ui_label(ICON_MD_WARNING " No Post FXs with annotations loaded."), 0;
|
if(!array_count(fx.pass)) return ui_label(ICON_MD_WARNING " No Post FXs with annotations loaded."), 0;
|
||||||
|
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
for( int i = 0; i < 64; ++i ) {
|
for( int i = 0; i < array_count(fx.pass); ++i ) {
|
||||||
char *name = fx_name(i); if( !name ) break;
|
char *name = fx_name(i); if( !name ) break;
|
||||||
bool b = fx_enabled(i);
|
bool b = fx_enabled(i);
|
||||||
if( ui_bool(name, &b) ) fx_enable(i, fx_enabled(i) ^ 1);
|
if( ui_bool(name, &b) ) fx_enable(i, fx_enabled(i) ^ 1);
|
||||||
|
|
Loading…
Reference in New Issue