diff --git a/build/main b/build/main new file mode 100755 index 0000000..ffdc0f6 Binary files /dev/null and b/build/main differ diff --git a/build/main.o b/build/main.o new file mode 100644 index 0000000..c0cf63c Binary files /dev/null and b/build/main.o differ diff --git a/makefile b/makefile new file mode 100644 index 0000000..18993ff --- /dev/null +++ b/makefile @@ -0,0 +1,37 @@ +# Compiler and flags +NVCC = nvcc +CXXFLAGS = -I./src -I./linalg -I./img -I./objs -std=c++17 + +# Directories +SRC_DIR = src +BUILD_DIR = build + +# Files +TARGET = $(BUILD_DIR)/main +SRC_FILES = $(wildcard $(SRC_DIR)/*.cu) +OBJ_FILES = $(patsubst $(SRC_DIR)/%.cu,$(BUILD_DIR)/%.o,$(SRC_FILES)) + +# Default target +all: $(TARGET) + +# Build the main target +$(TARGET): $(OBJ_FILES) | $(BUILD_DIR) + $(NVCC) $(CXXFLAGS) -o $@ $^ + +# Compile object files +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cu + $(NVCC) $(CXXFLAGS) -c $< -o $@ + +# Debug build +debug: CXXFLAGS += -g +debug: clean all + +# Clean build directory +clean: + rm -rf $(BUILD_DIR)/* + +# Create build directory if it doesn't exist +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +.PHONY: all clean debug diff --git a/tests/output.ppm b/output.ppm similarity index 100% rename from tests/output.ppm rename to output.ppm diff --git a/img/handler.h b/src/img/handler.h similarity index 83% rename from img/handler.h rename to src/img/handler.h index 4b032a9..9fe80f5 100644 --- a/img/handler.h +++ b/src/img/handler.h @@ -3,7 +3,7 @@ #include -void saveImage(const char* filename, unsigned char* framebuffer, int width, int height) { +void saveImage(const char* filename, unsigned char* framebuffer, int width, int height) { // TODO: Figure out a better way to do this std::ofstream imageFile(filename, std::ios::out | std::ios::binary); imageFile << "P6\n" << width << " " << height << "\n255\n"; for (int i = 0; i < width * height * 3; i++) { diff --git a/linalg/linalg.h b/src/linalg/linalg.h similarity index 100% rename from linalg/linalg.h rename to src/linalg/linalg.h diff --git a/linalg/mat.h b/src/linalg/mat.h similarity index 100% rename from linalg/mat.h rename to src/linalg/mat.h diff --git a/linalg/vec.h b/src/linalg/vec.h similarity index 100% rename from linalg/vec.h rename to src/linalg/vec.h diff --git a/main.cu b/src/main.cu similarity index 100% rename from main.cu rename to src/main.cu diff --git a/objs/sphere.h b/src/objs/sphere.h similarity index 100% rename from objs/sphere.h rename to src/objs/sphere.h diff --git a/tests/a.out b/src/tests/a.out similarity index 100% rename from tests/a.out rename to src/tests/a.out diff --git a/tests/deprecated_test.cu b/src/tests/deprecated_test.cu similarity index 100% rename from tests/deprecated_test.cu rename to src/tests/deprecated_test.cu diff --git a/tests/hello_world b/src/tests/hello_world similarity index 100% rename from tests/hello_world rename to src/tests/hello_world diff --git a/tests/hello_world.cu b/src/tests/hello_world.cu similarity index 100% rename from tests/hello_world.cu rename to src/tests/hello_world.cu diff --git a/src/tests/output.ppm b/src/tests/output.ppm new file mode 100644 index 0000000..1d7b780 Binary files /dev/null and b/src/tests/output.ppm differ diff --git a/tests/test_heavy.cu b/src/tests/test_heavy.cu similarity index 100% rename from tests/test_heavy.cu rename to src/tests/test_heavy.cu