mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-28 02:58:35 +02:00
~ | Cross platform makefiles
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
# By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ #
|
# By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/13 19:39:57 by ycontre #+# #+# #
|
# Created: 2024/10/13 19:39:57 by ycontre #+# #+# #
|
||||||
# Updated: 2024/10/14 19:31:54 by ycontre ### ########.fr #
|
# Updated: 2024/12/23 17:41:04 by ycontre ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -46,7 +46,9 @@ ASSETS_DIR := assets
|
|||||||
SRC_ASSETS_DIR := assets_src
|
SRC_ASSETS_DIR := assets_src
|
||||||
|
|
||||||
ALL_SRCS := RT.cpp gl.cpp \
|
ALL_SRCS := RT.cpp gl.cpp \
|
||||||
Window.cpp Shader.cpp \
|
Window.cpp \
|
||||||
|
Shader.cpp \
|
||||||
|
Camera.cpp
|
||||||
|
|
||||||
SRCS := $(ALL_SRCS:%=$(SRCS_DIR)/%)
|
SRCS := $(ALL_SRCS:%=$(SRCS_DIR)/%)
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ OBJS := $(addprefix $(OBJS_DIR)/, $(SRCS:%.cpp=%.o))
|
|||||||
|
|
||||||
HEADERS := includes/RT.hpp
|
HEADERS := includes/RT.hpp
|
||||||
|
|
||||||
CC := clang -Wextra -Werror -Wall
|
CC := clang++ -Wextra -Werror -Wall
|
||||||
|
|
||||||
CFLAGS := -Ofast
|
CFLAGS := -Ofast
|
||||||
|
|
||||||
|
116
Makefile
116
Makefile
@ -1,76 +1,90 @@
|
|||||||
# **************************************************************************** #
|
ifeq ($(OS),Windows_NT)
|
||||||
# #
|
BLACK = [90m
|
||||||
# ::: :::::::: #
|
RED = [91m
|
||||||
# WMakefile :+: :+: :+: #
|
GREEN = [92m
|
||||||
# +:+ +:+ +:+ #
|
YELLOW = [93m
|
||||||
# By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ #
|
BLUE = [94m
|
||||||
# +#+#+#+#+#+ +#+ #
|
MAGENTA = [95m
|
||||||
# Created: 2024/10/14 22:33:37 by TheRed #+# #+# #
|
CYAN = [96m
|
||||||
# Updated: 2024/10/14 22:33:37 by TheRed ### ########.fr #
|
WHITE = [97m
|
||||||
# #
|
RESET = [0m
|
||||||
# **************************************************************************** #
|
|
||||||
|
|
||||||
BLACK = [90m
|
|
||||||
RED = [91m
|
|
||||||
GREEN = [92m
|
|
||||||
YELLOW = [93m
|
|
||||||
BLUE = [94m
|
|
||||||
MAGENTA = [95m
|
|
||||||
CYAN = [96m
|
|
||||||
WHITE = [97m
|
|
||||||
|
|
||||||
RESET = [0m
|
|
||||||
|
|
||||||
LINE_CLR = \33[2K\r
|
LINE_CLR = \33[2K\r
|
||||||
|
RM := del /f /s /q
|
||||||
|
DIR_DUP = if not exist "$(@D)" mkdir "$(@D)"
|
||||||
|
CC := g++
|
||||||
|
IFLAGS := -I./includes
|
||||||
|
LDFLAGS := -L./lib -lglfw3 -lopengl32 -lgdi32 -lcglm
|
||||||
|
else
|
||||||
|
BLACK = \033[30;49;3m
|
||||||
|
RED = \033[31;49;3m
|
||||||
|
GREEN = \033[32;49;3m
|
||||||
|
YELLOW = \033[33;49;3m
|
||||||
|
BLUE = \033[34;49;3m
|
||||||
|
MAGENTA = \033[35;49;3m
|
||||||
|
CYAN = \033[36;49;3m
|
||||||
|
WHITE = \033[37;49;3m
|
||||||
|
RESET = \033[0m
|
||||||
|
LINE_CLR = \33[2K\r
|
||||||
|
RM := rm -rf
|
||||||
|
DIR_DUP = mkdir -p $(@D)
|
||||||
|
CC := clang++
|
||||||
|
CFLAGS := -Ofast -Wall -Wextra -Werror
|
||||||
|
IFLAGS := -I./includes -I/usr/include
|
||||||
|
LDFLAGS := -L/usr/lib/x86_64-linux-gnu -lglfw -lGL -lGLU -lX11 -lpthread -ldl -lstdc++
|
||||||
|
FILE = $(shell ls -lR srcs/ | grep -F .c | wc -l)
|
||||||
|
CMP = 1
|
||||||
|
endif
|
||||||
|
|
||||||
NAME := RT
|
NAME := RT
|
||||||
|
|
||||||
SRCS_DIR := srcs
|
SRCS_DIR := srcs
|
||||||
|
|
||||||
OBJS_DIR := .objs
|
OBJS_DIR := .objs
|
||||||
|
|
||||||
ALL_SRCS := RT.cpp gl.cpp \
|
ALL_SRCS := RT.cpp gl.cpp \
|
||||||
Window.cpp \
|
Window.cpp \
|
||||||
Shader.cpp \
|
Shader.cpp \
|
||||||
Camera.cpp
|
Camera.cpp
|
||||||
|
|
||||||
|
|
||||||
SRCS := $(ALL_SRCS:%=$(SRCS_DIR)/%)
|
SRCS := $(ALL_SRCS:%=$(SRCS_DIR)/%)
|
||||||
|
|
||||||
|
|
||||||
OBJS := $(addprefix $(OBJS_DIR)/, $(SRCS:%.cpp=%.o))
|
OBJS := $(addprefix $(OBJS_DIR)/, $(SRCS:%.cpp=%.o))
|
||||||
|
HEADERS := includes/RT.hpp
|
||||||
CC := g++
|
|
||||||
|
|
||||||
IFLAGS := -Ofast -I./includes -L./lib -lglfw3 -lopengl32 -lgdi32 -lcglm
|
|
||||||
|
|
||||||
RM := del /f /s /q
|
|
||||||
|
|
||||||
MAKEFLAGS += --no-print-directory
|
MAKEFLAGS += --no-print-directory
|
||||||
|
|
||||||
DIR_DUP = if not exist "$(@D)" mkdir "$(@D)"
|
windows: $(OBJS) $(HEADERS)
|
||||||
|
@$(CC) $(OBJS) $(IFLAGS) $(LDFLAGS) -o $(NAME)
|
||||||
|
@echo $(WHITE) $(NAME): PROJECT COMPILED !$(RESET)
|
||||||
|
|
||||||
# RULES ********************************************************************** #
|
linux: $(OBJS) $(HEADERS)
|
||||||
|
@$(CC) $(OBJS) $(IFLAGS) $(CFLAGS) $(LDFLAGS) -o $(NAME)
|
||||||
all: $(NAME)
|
@printf "$(LINE_CLR)$(WHITE) $(NAME): PROJECT COMPILED !$(RESET)\n\n"
|
||||||
|
|
||||||
$(NAME): $(OBJS) $(HEADERS)
|
|
||||||
@$(CC) -o $(NAME) $(OBJS) $(IFLAGS)
|
|
||||||
@echo $(WHITE) $(NAME): PROJECT COMPILED !$(RESET) & echo:
|
|
||||||
|
|
||||||
$(OBJS_DIR)/%.o: %.cpp
|
$(OBJS_DIR)/%.o: %.cpp
|
||||||
@$(DIR_DUP)
|
@$(DIR_DUP)
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
@echo $(WHITE) $(NAME): $(WHITE)$<$(RESET) $(GREEN)compiling...$(RESET)
|
@echo $(WHITE) $(NAME): $(WHITE)$<$(RESET) $(GREEN)compiling...$(RESET)
|
||||||
@$(CC) -c $^ $(IFLAGS) -o $@
|
@$(CC) $(IFLAGS) -c $^ -o $@
|
||||||
|
else
|
||||||
|
@if [ $(CMP) -eq '1' ]; then printf "\n"; fi;
|
||||||
|
@printf "$(LINE_CLR)$(WHITE) $(NAME): $(CMP)/$(FILE) $(WHITE)$<$(RESET) $(GREEN)compiling...$(RESET)"
|
||||||
|
@$(CC) $(CFLAGS) $(IFLAGS) -c $^ -o $@
|
||||||
|
@$(eval CMP=$(shell echo $$(($(CMP)+1))))
|
||||||
|
@if [ $(CMP) -gt $(FILE) ]; then \
|
||||||
|
printf "$(LINE_CLR)$(WHITE) $(NAME): $$(($(CMP)-1))/$(FILE)\n$(LINE_CLR)$(GREEN) Compilation done !$(RESET)\n"; \
|
||||||
|
fi
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@$(RM) $(OBJS)
|
||||||
|
|
||||||
fclean:
|
fclean: clean
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
@echo $(WHITE)$(NAME):$(RED) cleaned.$(RESET)
|
@echo $(WHITE)$(NAME):$(RED) cleaned.$(RESET)
|
||||||
@del /f /s /q $(NAME).exe
|
@$(RM) $(NAME).exe
|
||||||
@rmdir /S /Q "$(OBJS_DIR)"
|
@rmdir /S /Q "$(OBJS_DIR)"
|
||||||
|
else
|
||||||
|
@printf "$(WHITE)$(NAME):$(RED) cleaned.$(RESET)\n"
|
||||||
|
@$(RM) $(NAME)
|
||||||
|
@$(RM) $(OBJS_DIR)
|
||||||
|
endif
|
||||||
|
|
||||||
re:
|
re: fclean linux
|
||||||
@$(MAKE) fclean
|
|
||||||
@$(MAKE) all
|
|
||||||
|
|
||||||
.PHONY: all clean fclean dclean re bonus
|
.PHONY: all clean fclean re windows linux
|
76
WMakefile
Normal file
76
WMakefile
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# WMakefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2024/10/14 22:33:37 by TheRed #+# #+# #
|
||||||
|
# Updated: 2024/10/14 22:33:37 by TheRed ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
BLACK = [90m
|
||||||
|
RED = [91m
|
||||||
|
GREEN = [92m
|
||||||
|
YELLOW = [93m
|
||||||
|
BLUE = [94m
|
||||||
|
MAGENTA = [95m
|
||||||
|
CYAN = [96m
|
||||||
|
WHITE = [97m
|
||||||
|
|
||||||
|
RESET = [0m
|
||||||
|
|
||||||
|
LINE_CLR = \33[2K\r
|
||||||
|
|
||||||
|
NAME := RT
|
||||||
|
|
||||||
|
SRCS_DIR := srcs
|
||||||
|
|
||||||
|
OBJS_DIR := .objs
|
||||||
|
|
||||||
|
ALL_SRCS := RT.cpp gl.cpp \
|
||||||
|
Window.cpp \
|
||||||
|
Shader.cpp \
|
||||||
|
Camera.cpp
|
||||||
|
|
||||||
|
|
||||||
|
SRCS := $(ALL_SRCS:%=$(SRCS_DIR)/%)
|
||||||
|
|
||||||
|
|
||||||
|
OBJS := $(addprefix $(OBJS_DIR)/, $(SRCS:%.cpp=%.o))
|
||||||
|
|
||||||
|
CC := g++
|
||||||
|
|
||||||
|
IFLAGS := -Ofast -I./includes -L./lib -lglfw3 -lopengl32 -lgdi32 -lcglm
|
||||||
|
|
||||||
|
RM := del /f /s /q
|
||||||
|
|
||||||
|
MAKEFLAGS += --no-print-directory
|
||||||
|
|
||||||
|
DIR_DUP = if not exist "$(@D)" mkdir "$(@D)"
|
||||||
|
|
||||||
|
# RULES ********************************************************************** #
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
$(NAME): $(OBJS) $(HEADERS)
|
||||||
|
@$(CC) -o $(NAME) $(OBJS) $(IFLAGS)
|
||||||
|
@echo $(WHITE) $(NAME): PROJECT COMPILED !$(RESET) & echo:
|
||||||
|
|
||||||
|
$(OBJS_DIR)/%.o: %.cpp
|
||||||
|
@$(DIR_DUP)
|
||||||
|
@echo $(WHITE) $(NAME): $(WHITE)$<$(RESET) $(GREEN)compiling...$(RESET)
|
||||||
|
@$(CC) -c $^ $(IFLAGS) -o $@
|
||||||
|
|
||||||
|
|
||||||
|
fclean:
|
||||||
|
@echo $(WHITE)$(NAME):$(RED) cleaned.$(RESET)
|
||||||
|
@del /f /s /q $(NAME).exe
|
||||||
|
@rmdir /S /Q "$(OBJS_DIR)"
|
||||||
|
|
||||||
|
re:
|
||||||
|
@$(MAKE) fclean
|
||||||
|
@$(MAKE) all
|
||||||
|
|
||||||
|
.PHONY: all clean fclean dclean re bonus
|
@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* Camera.hpp :+: :+: :+: */
|
/* Camera.hpp :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
|
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/15 13:59:57 by TheRed #+# #+# */
|
/* Created: 2024/10/15 13:59:57 by TheRed #+# #+# */
|
||||||
/* Updated: 2024/10/15 13:59:57 by TheRed ### ########.fr */
|
/* Updated: 2024/12/23 17:42:18 by ycontre ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -3,17 +3,17 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* Camera.cpp :+: :+: :+: */
|
/* Camera.cpp :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
|
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/15 14:00:38 by TheRed #+# #+# */
|
/* Created: 2024/10/15 14:00:38 by TheRed #+# #+# */
|
||||||
/* Updated: 2024/10/15 14:00:38 by TheRed ### ########.fr */
|
/* Updated: 2024/12/23 17:42:20 by ycontre ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
|
|
||||||
Camera::Camera(glm::vec3 start_pos, glm::vec3 start_up, float start_yaw, float start_pitch)
|
Camera::Camera(glm::vec3 start_pos, glm::vec3 start_up, float start_yaw, float start_pitch)
|
||||||
: _forward(glm::vec3(0.0f, 0.0f, -1.0f)), _yaw(start_yaw), _pitch(start_pitch), _position(start_pos), _up(start_up)
|
: _forward(glm::vec3(0.0f, 0.0f, -1.0f)), _position(start_pos), _up(start_up), _pitch(start_pitch), _yaw(start_yaw)
|
||||||
{
|
{
|
||||||
update_camera_vectors();
|
update_camera_vectors();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/13 16:16:24 by TheRed #+# #+# */
|
/* Created: 2024/10/13 16:16:24 by TheRed #+# #+# */
|
||||||
/* Updated: 2024/10/13 20:52:00 by ycontre ### ########.fr */
|
/* Updated: 2024/12/23 17:39:55 by ycontre ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ Window::~Window(void)
|
|||||||
void Window::keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
void Window::keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
|
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
|
||||||
(void) win; (void) key; (void) scancode; (void) mods;
|
(void) win; (void) key; (void) scancode; (void) mods; (void) action;
|
||||||
|
|
||||||
bool forward = glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS;
|
bool forward = glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS;
|
||||||
bool backward = glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS;
|
bool backward = glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS;
|
||||||
|
Reference in New Issue
Block a user