-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
40,518 additions
and
35,092 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,99 +3,129 @@ | |
# ::: :::::::: # | ||
# Makefile :+: :+: :+: # | ||
# +:+ +:+ +:+ # | ||
# By: maldavid <[email protected]> +#+ +:+ +#+ # | ||
# By: kiroussa <[email protected]> +#+ +:+ +#+ # | ||
# +#+#+#+#+#+ +#+ # | ||
# Created: 2022/10/04 16:43:41 by maldavid #+# #+# # | ||
# Updated: 2024/01/10 14:20:30 by maldavid ### ########.fr # | ||
# Updated: 2024/04/24 14:59:23 by kiroussa ### ########.fr # | ||
# # | ||
# **************************************************************************** # | ||
|
||
NAME = libmlx.so | ||
NAME = libmlx.so | ||
MAKE = make --no-print-directory | ||
|
||
SRCS = $(wildcard $(addsuffix /*.cpp, ./src/core)) | ||
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/platform)) | ||
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer)) | ||
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer/**)) | ||
OS ?= $(shell uname -s) | ||
DEBUG ?= false | ||
TOOLCHAIN ?= clang | ||
IMAGES_OPTIMIZED ?= true | ||
FORCE_INTEGRATED_GPU ?= false | ||
GRAPHICS_MEMORY_DUMP ?= false | ||
PROFILER ?= false | ||
_ENABLEDFLAGS = | ||
|
||
OBJ_DIR = objs/makefile | ||
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o)) | ||
SRCS = $(wildcard $(addsuffix /*.cpp, src/core)) | ||
SRCS += $(wildcard $(addsuffix /*.cpp, src/platform)) | ||
SRCS += $(wildcard $(addsuffix /*.cpp, src/renderer)) | ||
SRCS += $(wildcard $(addsuffix /*.cpp, src/renderer/**)) | ||
|
||
OS = $(shell uname -s) | ||
DEBUG ?= false | ||
TOOLCHAIN ?= clang | ||
IMAGES_OPTIMIZED ?= true | ||
FORCE_INTEGRATED_GPU ?= false | ||
GRAPHICS_MEMORY_DUMP ?= false | ||
PROFILER ?= false | ||
OBJ_DIR = objs/make/$(shell echo $(OS) | tr '[:upper:]' '[:lower:]') | ||
OBJS := $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o)) | ||
|
||
MODE = "release" | ||
|
||
CXX = clang++ | ||
|
||
CXXFLAGS = -std=c++17 -O3 -fPIC -Wall -Wextra -Werror -DSDL_MAIN_HANDLED | ||
INCLUDES = -I./includes -I./src -I./third_party | ||
|
||
LDLIBS = | ||
CXX = clang++ | ||
CXXFLAGS = -std=c++17 -O3 -fPIC -Wall -Wextra -Werror -DSDL_MAIN_HANDLED | ||
INCLUDES = -I./includes -I./src -I./third_party | ||
|
||
ifeq ($(TOOLCHAIN), gcc) | ||
CXX = g++ | ||
CXXFLAGS += -Wno-error=cpp | ||
CXX = g++ | ||
CXXFLAGS += -Wno-error=cpp | ||
else | ||
CXXFLAGS += -Wno-error=#warning | ||
CXXFLAGS += -Wno-error=#warning | ||
endif | ||
|
||
ifeq ($(OS), Darwin) | ||
LDLIBS += -L /opt/homebrew/lib -lSDL2 | ||
CXXFLAGS += -I /opt/homebrew/include | ||
NAME = libmlx.dylib | ||
LDFLAGS += -L /opt/homebrew/lib -lSDL2 | ||
CXXFLAGS += -I /opt/homebrew/include | ||
NAME = libmlx.dylib | ||
endif | ||
|
||
ifeq ($(DEBUG), true) | ||
CXXFLAGS += -g -D DEBUG | ||
MODE = "debug" | ||
CXXFLAGS += -g3 -D DEBUG | ||
LDFLAGS += -rdynamic | ||
endif | ||
|
||
ifeq ($(FORCE_INTEGRATED_GPU), true) | ||
CXXFLAGS += -D FORCE_INTEGRATED_GPU | ||
_ENABLEDFLAGS += FORCE_INTEGRATED_GPU | ||
endif | ||
|
||
ifeq ($(IMAGES_OPTIMIZED), true) | ||
CXXFLAGS += -D IMAGE_OPTIMIZED | ||
_ENABLEDFLAGS += IMAGE_OPTIMIZED | ||
endif | ||
|
||
ifeq ($(GRAPHICS_MEMORY_DUMP), true) | ||
CXXFLAGS += -D GRAPHICS_MEMORY_DUMP | ||
_ENABLEDFLAGS += GRAPHICS_MEMORY_DUMP | ||
endif | ||
|
||
ifeq ($(PROFILER), true) | ||
CXXFLAGS += -D PROFILER | ||
_ENABLEDFLAGS += PROFILER | ||
endif | ||
|
||
CXXFLAGS += $(addprefix -D, $(_ENABLEDFLAGS)) | ||
|
||
RM = rm -rf | ||
|
||
TPUT = tput -T xterm-256color | ||
_RESET := $(shell $(TPUT) sgr0) | ||
_BOLD := $(shell $(TPUT) bold) | ||
_ITALIC := $(shell $(TPUT) sitm) | ||
_UNDER := $(shell $(TPUT) smul) | ||
_GREEN := $(shell $(TPUT) setaf 2) | ||
_YELLOW := $(shell $(TPUT) setaf 3) | ||
_RED := $(shell $(TPUT) setaf 1) | ||
_GRAY := $(shell $(TPUT) setaf 8) | ||
_PURPLE := $(shell $(TPUT) setaf 5) | ||
|
||
ifeq ($(DEBUG), true) | ||
MODE := $(_RESET)$(_PURPLE)$(_BOLD)Debug$(_RESET)$(_PURPLE) | ||
COLOR := $(_PURPLE) | ||
else | ||
MODE := $(_RESET)$(_GREEN)$(_BOLD)Release$(_RESET)$(_GREEN) | ||
COLOR := $(_GREEN) | ||
endif | ||
|
||
OBJS_TOTAL = $(words $(OBJS)) | ||
N_OBJS := $(shell find $(OBJ_DIR) -type f -name '*.o' 2>/dev/null | wc -l) | ||
OBJS_TOTAL := $(shell echo $$(( $(OBJS_TOTAL) - $(N_OBJS) ))) | ||
CURR_OBJ = 0 | ||
|
||
$(OBJ_DIR)/%.o: %.cpp | ||
@printf "\033[1;32m[compiling... "$(MODE)" "$(CXX)"]\033[1;00m "$<"\n" | ||
@mkdir -p $(dir $@) | ||
@$(eval CURR_OBJ=$(shell echo $$(( $(CURR_OBJ) + 1 )))) | ||
@$(eval PERCENT=$(shell echo $$(( $(CURR_OBJ) * 100 / $(OBJS_TOTAL) )))) | ||
@printf "$(COLOR)($(_BOLD)%3s%%$(_RESET)$(COLOR)) $(_RESET)Compiling $(_BOLD)$<$(_RESET)\n" "$(PERCENT)" | ||
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ | ||
|
||
all: $(NAME) | ||
all: _printbuildinfos | ||
@$(MAKE) $(NAME) | ||
|
||
$(NAME): $(OBJS) | ||
@printf "Linking $(_BOLD)$(NAME)$(_RESET)\n" | ||
@$(CXX) -shared -o $(NAME) $(OBJS) $(LDFLAGS) | ||
@printf "$(_BOLD)$(NAME)$(_RESET) compiled $(COLOR)$(_BOLD)successfully$(_RESET)\n" | ||
|
||
$(NAME): $(OBJ_DIR) $(OBJS) | ||
@printf "\033[1;32m[linking ... "$(MODE)"]\033[1;00m "$@"\n" | ||
@$(CXX) -shared -o $(NAME) $(OBJS) $(LDLIBS) | ||
@printf "\033[1;32m[build finished]\033[1;00m\n" | ||
_printbuildinfos: | ||
@printf "$(_PURPLE)$(_BOLD)MacroLibX $(_RESET)Compiling in $(_BOLD)$(MODE)$(_RESET) mode on $(_BOLD)$(OS)$(_RESET) | Using $(_BOLD)$(CXX)$(_RESET), flags: $(_BOLD)$(_ENABLEDFLAGS)$(_RESET)\n" | ||
|
||
$(OBJ_DIR): | ||
@mkdir -p $(sort $(addprefix $(OBJ_DIR)/, $(dir $(SRCS)))) | ||
@printf "\033[1;32m[created objs directory]\033[1;00m\n" | ||
debug: | ||
@$(MAKE) all DEBUG=true -j$(shell nproc) | ||
|
||
clean: | ||
@$(RM) $(OBJ_DIR) | ||
@printf "\033[1;32m[object files removed]\033[1;00m\n" | ||
@printf "Cleaned $(_BOLD)$(OBJ_DIR)$(_RESET)\n" | ||
|
||
fclean: clean | ||
@$(RM) $(NAME) | ||
@printf "\033[1;32m["$(NAME)" removed]\033[1;00m\n" | ||
@printf "Cleaned $(_BOLD)$(NAME)$(_RESET)\n" | ||
|
||
re: fclean all | ||
re: fclean _printbuildinfos | ||
@$(MAKE) $(NAME) | ||
|
||
.PHONY: all clean fclean re | ||
.PHONY: all clean debug fclean re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */ | ||
/* Updated: 2024/04/21 18:13:29 by maldavid ### ########.fr */ | ||
/* Updated: 2024/04/24 13:52:18 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -40,6 +40,7 @@ namespace mlx::core | |
|
||
void Application::run() noexcept | ||
{ | ||
_in->run(); | ||
while(_in->isRunning()) | ||
{ | ||
if(!_fps.update()) | ||
|
@@ -107,7 +108,10 @@ namespace mlx::core | |
else | ||
texture->destroy(); | ||
for(auto& gs : _graphics) | ||
gs->tryEraseTextureFromManager(texture); | ||
{ | ||
if(gs) | ||
gs->tryEraseTextureFromManager(texture); | ||
} | ||
_textures.erase(it); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/04/02 15:13:55 by maldavid #+# #+# */ | ||
/* Updated: 2024/01/11 04:38:53 by maldavid ### ########.fr */ | ||
/* Updated: 2024/04/22 17:34:27 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -52,7 +52,7 @@ namespace mlx | |
_proj = glm::ortho<float>(0, _width, 0, _height); | ||
_renderer->getUniformBuffer()->setData(sizeof(_proj), &_proj); | ||
|
||
static std::array<VkDescriptorSet, 2> sets = { | ||
std::array<VkDescriptorSet, 2> sets = { | ||
_renderer->getVertDescriptorSet().get(), | ||
VK_NULL_HANDLE | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/10/05 16:27:35 by maldavid #+# #+# */ | ||
/* Updated: 2024/02/25 07:51:55 by maldavid ### ########.fr */ | ||
/* Updated: 2024/04/22 17:35:23 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -45,6 +45,7 @@ namespace mlx | |
inline int getYRel() const noexcept { return _yRel; } | ||
|
||
inline bool isRunning() const noexcept { return !_end; } | ||
inline constexpr void run() noexcept { _end = false; } | ||
inline constexpr void finish() noexcept { _end = true; } | ||
|
||
inline void addWindow(std::shared_ptr<MLX_Window> window) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: kbz_8 <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/10/20 22:02:37 by kbz_8 #+# #+# */ | ||
/* Updated: 2024/03/14 16:34:53 by maldavid ### ########.fr */ | ||
/* Updated: 2024/09/14 00:04:16 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -31,6 +31,8 @@ | |
#pragma GCC diagnostic ignored "-Wmissing-field-initializers" | ||
#pragma GCC diagnostic ignored "-Wunused-parameter" | ||
#pragma GCC diagnostic ignored "-Wunused-variable" | ||
#pragma GCC diagnostic ignored "-Wunused-function" | ||
#pragma GCC diagnostic ignored "-Wparentheses" | ||
#pragma GCC diagnostic ignored "-Wparentheses" | ||
#include <renderer/core/memory.h> | ||
#pragma GCC diagnostic pop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */ | ||
/* Updated: 2024/01/20 08:20:07 by maldavid ### ########.fr */ | ||
/* Updated: 2024/04/23 20:32:54 by kiroussa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/03/31 18:03:35 by maldavid #+# #+# */ | ||
/* Updated: 2024/03/14 19:07:01 by maldavid ### ########.fr */ | ||
/* Updated: 2024/09/14 00:04:29 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -18,7 +18,14 @@ | |
#include <cstring> | ||
|
||
#define STB_IMAGE_IMPLEMENTATION | ||
#include <stb_image.h> | ||
#ifdef MLX_COMPILER_GCC | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wstringop-overflow" | ||
#include <stb_image.h> | ||
#pragma GCC diagnostic pop | ||
#else | ||
#include <stb_image.h> | ||
#endif | ||
|
||
#ifdef IMAGE_OPTIMIZED | ||
#define TILING VK_IMAGE_TILING_OPTIMAL | ||
|
Oops, something went wrong.