-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun
executable file
·101 lines (92 loc) · 1.95 KB
/
run
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
# input parameter:
# 0 - cleanup
# 1 - compile
# 2 - compile & package
# 3 - compile & run
# 4 - compile & run & convert
# 5 - compile & run & convert & open
# 6 - compile & run & convert & open & cleanup
# compile C++ v. 11 (Mac)
# param > 0
if [ $1 -gt 0 ]
then
clang++ -std=c++11 -stdlib=libc++ -o ray-tracer ray-tracer.cpp
fi
# package (zip) project directory
# param = 2
if [ $1 -eq 2 ]
then
mv ray-tracer rt
mkdir ray-tracer
cp rt ray-tracer/ray-tracer
cp -r library/ ray-tracer/library/
cp -r scenes/ ray-tracer/scenes/
cp -r objects/ ray-tracer/objects/
cp -r textures/ ray-tracer/textures/
cp LICENSE ray-tracer/
cp README.md ray-tracer/
cp ray-tracer.cpp ray-tracer/
cp run ray-tracer/
mkdir ray-tracer/images/
zip -r ray-tracer.zip ray-tracer/
rm -rf ray-tracer/
mv rt ray-tracer
fi
# run and time ray tracer
# param > 2
if [ $1 -gt 2 ]
then
echo "Ray tracer run time:"
time ./ray-tracer
fi
# cleanup old images
# param = 0 || 6
if [ $1 -eq 0 ]
then
rm -f images/image.png
#rm -f images/imageZ.png
#rm -f images/imageSample.png
else
if [ $1 -eq 6 ]
then
rm -f images/image.png
#rm -f images/imageZ.png
#rm -f images/imageSample.png
fi
fi
# convert images
# param > 3
if [ $1 -gt 3 ]
then
convert images/image.ppm images/image.png
#convert images/imageZ.ppm images/imageZ.png
#convert images/imageSample.ppm images/imageSample.png
fi
# open images
# param > 4
if [ $1 -gt 4 ]
then
open -a /Applications/Preview.app/ images/image.png
#open -a /Applications/Preview.app/ images/imageZ.png
#open -a /Applications/Preview.app/ images/imageSample.png
fi
# cleanup
# param = 0 || 6
if [ $1 -eq 0 ]
then
rm -f images/image.ppm
#rm -f images/imageZ.ppm
#rm -f images/imageSample.ppm
rm -f a.out
rm -f ray-tracer
else
if [ $1 -eq 6 ]
then
rm -f images/image.ppm
#rm -f images/imageZ.ppm
#rm -f images/imageSample.ppm
rm -f a.out
rm -f ray-tracer
fi
fi