-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.c
52 lines (40 loc) · 1.16 KB
/
cli.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
#include <string.h>
#include <stdio.h>
#include "cli.h"
#include "voxelgrid.h"
#include "renderer.h"
#include "generator.h"
#include "app.h"
int cli_main (int argc, char **argv, Settings *settings)
{
log_printf(2, "Entering CLI-mode\n");
VoxelGrid *voxelgrid = NULL;
// unless the user specified a generator
// TODO: make file loader a generator as well
if(settings->generator == NULL){
// check input filename
if (strlen(settings->in_filename) == 0) {
fprintf (stderr, "Error: No input file specified\n");
suggest_help();
return 1;
}
// load voxel data from file
voxelgrid = voxelgrid_load (settings->in_filename);
}
else
{
// load voxel data from generator
voxelgrid = generator_generate(settings->generator);
}
// initialize renderer
Renderer *renderer = renderer_create();
// render
renderer_render(renderer, settings, voxelgrid);
// write output file
renderer_save(renderer, settings);
// clean up render data
renderer_free(renderer);
voxelgrid_free(voxelgrid);
// return success
return 0;
}