From 301faf3cc76f15e1951bc8b2d1ebc1f74b558818 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 12 Sep 2015 22:35:28 +0200 Subject: Some cleanup --- .gitignore | 6 ++++-- Makefile | 26 ++++++++++++++++++++++++++ README.md | 6 ++---- graytrace.cpp | 3 ++- 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 23a3c89..607449b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .DS_Store -b.sh graytrace -*.png +*.o lodepng.h +lodepng.cpp + +*.png diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..230ae9e --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +CXX = g++ +CXXFLAGS = -Wall -O2 + +.PHONY: all clean remake + +all: graytrace + +clean: + rm -f graytrace graytrace.o lodepng.o + +remake: clean all + + +graytrace: lodepng.o graytrace.cpp graytrace.o + $(CXX) $(CXXFLAGS) graytrace.o lodepng.o -o graytrace + +lodepng.o: lodepng.cpp lodepng.h + $(CXX) $(CXXFLAGS) -c -o lodepng.o lodepng.cpp + +lodepng.cpp: + @if ! test -e lodepng.cpp; then \ + /bin/echo -n Downloading lodepng...\ ; \ + curl -s 'https://raw.githubusercontent.com/lvandeve/lodepng/master/lodepng.cpp' >lodepng.cpp; \ + curl -s 'https://raw.githubusercontent.com/lvandeve/lodepng/master/lodepng.h' >lodepng.h; \ + /bin/echo done.; \ + fi diff --git a/README.md b/README.md index f2c2496..280f745 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,5 @@ A simple, experimental raytracer that doesn't support colours. I made this in my spare time and will probably continue to add features. Or not. I don't know. -It needs lodepng (as found on [lodev.org](http://lodev.org/lodepng/)). -Just compile with `lodepng.cpp` and `lodepng.h` in the same folder as the source and pass both `graytrace.cpp` and `lodepng.cpp` as arguments to the compiler. - -_- Tom Smeding_ +It uses lodepng (as found on [lodev.org](http://lodev.org/lodepng/)). +Invoking `make` on the command line should be enough; if necessary, it will download lodepng automatically. diff --git a/graytrace.cpp b/graytrace.cpp index b74d387..c09a202 100644 --- a/graytrace.cpp +++ b/graytrace.cpp @@ -123,7 +123,8 @@ public: class Primitive{ public: - bool isLight=false; + bool isLight; + Primitive(void):isLight(false){} virtual ~Primitive(void){} /* A line is represented by the formula: X = P + D * t -- cgit v1.2.3