-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
71 lines (62 loc) · 1.52 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include <stdlib.h>
#include <utils.h>
#include "dSFMT.h"
#if defined SDL
#include <SDL2/SDL.h>
#include <GL/glew.h>
#define GL_GLEXT_PROTOTYPES
#include "program_gl.h"
#include "mySDL.h"
#endif
#include "init.h"
#include "run.h"
dsfmt_t dsfmt;
int main(int argc, char *argv[]){
//main
//////
//Initialize header
///////////////////
header *t=init_header();
dsfmt_init_gen_rand(&dsfmt,t->seed);
//Reading inputs
////////////////
if(argc==1){
usage(stdout,t->argz,*argv);
return 0;
}
printf(">>>Initialized default header\n");
input_files *input=find_configurational_files(argc,argv);
read_input(argc,argv,input,t);
//print simulation arguments
////////////////////////////
dump_args(stdout,t->argz);
#if defined SDL
//Graphics
//////////
mySDL *sdl=NULL;
float color[4]={1.0,0.0,0.0,0.333};
//Allocate memory blocks for the graphics
/////////////////////////////////////////
if(t->display){
sdl=mySDLinit((unsigned int)t->screen_geometry[0],(unsigned int)t->screen_geometry[1]);
sdl->positions=alloc(sizeof(float)*2*t->nparticle_alloc);
sdl->colors=alloc(sizeof(float)*4*t->nparticle_alloc);
sdl->n=t->nparticle;
sdl->uy=t->uy;
m128d2float(t->p->q,sdl->positions,sdl->n);
mySDLsetcolor(sdl->colors,color,sdl->n);
//Define boundary
/////////////////
sdl->box=(float[8]){0.0,0.0,t->box[0],0.0,t->box[0],t->box[1],0.0,t->box[1]};
sdl->scale=1.0/t->box[0];
mySDLresize(sdl);
}
//Run the simulation
////////////////////
run(t,sdl);
#else
run(t);
#endif
return 0;
}