13#include "ex_fluid_config.h"
18int load_app_state(
char* state_filename,
size_t* WIDTH,
size_t* HEIGHT,
bool* fullscreen,
char** bgmusic,
double* drawFPS,
double* logicFPS,
N_FLUID* fluid,
int* threaded) {
22 if (access(state_filename, F_OK) != 0) {
59 n_log(
LOG_ERR,
"Unable to load config file from %s", state_filename);
63 n_log(
LOG_ERR,
"There were %d errors in %s. Check the logs !", errors, state_filename);
68 for (
int it = 0; it < nb; it++) {
71 if (value) (*WIDTH) = atoi(value);
73 if (value) (*HEIGHT) = atoi(value);
75 if (value) (*fullscreen) = atoi(value);
77 if (value) (*bgmusic) = strdup(value);
79 if (value) (*drawFPS) = strtold(value, NULL);
81 if (value) (*logicFPS) = strtold(value, NULL);
83 if (value) fluid->
numIters = atoi(value);
85 if (value) fluid->
density = strtold(value, NULL);
87 if (value) fluid->
gravity = strtold(value, NULL);
93 if (value) fluid->
cScale = strtold(value, NULL);
95 if (value) (*threaded) = atoi(value);
#define __n_assert(__ptr, __ret)
macro to assert things
CONFIG_FILE * load_config_file(char *filename, int *errors)
load a config file
int destroy_config_file(CONFIG_FILE **cfg_file)
Destroy a loaded config file.
char * get_config_section_value(CONFIG_FILE *cfg_file, char *section_name, size_t section_position, char *entry, size_t entry_position)
Function to parse sections and get entries values.
size_t get_nb_config_file_sections(CONFIG_FILE *cfg_file, char *section_name)
Get the number of config file with section_name.
Structure of a config file.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
#define LOG_INFO
informational
double fluid_production_percentage
size of the produced fluid
double overRelaxation
over relaxation
size_t numIters
number of fluid processing iterations for each frame
double density
density of the fluid (not working ?)
double cScale
scale used to deduce cellX and cellY from screen/window width and height
double gravity
gravity on Y
Config file reading and writing.
fluid management port from "How to write an Eulerian fluid simulator with 200 lines of code",...
N_STR and string function declaration.