mirror of
https://github.com/MartinOpat/cuda-based-raytrace.git
synced 2025-06-07 02:13:10 +02:00
Added makefile
This commit is contained in:
1 parent
1974d7bcc0
commit
ed3adbd4c4
16 files changed
+38
-1
No files matched your search
Executable
BIN
Binary file not shown.
Binary file not shown.
@@ -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
|
||||||
File renamed without changes.
@@ -3,7 +3,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
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);
|
std::ofstream imageFile(filename, std::ios::out | std::ios::binary);
|
||||||
imageFile << "P6\n" << width << " " << height << "\n255\n";
|
imageFile << "P6\n" << width << " " << height << "\n255\n";
|
||||||
for (int i = 0; i < width * height * 3; i++) {
|
for (int i = 0; i < width * height * 3; i++) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.