fixed gcc compile error
This commit is contained in:
parent
29ab44ba76
commit
821047e391
9
Makefile
9
Makefile
@ -32,22 +32,23 @@ WEB_OUTPUT_JS := $(WEB_OUTPUT).js
|
||||
WEB_OUTPUT_WASM := $(WEB_OUTPUT).wasm
|
||||
WEB_OUTPUT_DATA := $(WEB_OUTPUT).data
|
||||
|
||||
|
||||
ifeq ($(PLATFORM), PLATFORM_WEB)
|
||||
LIBRAYLIB := libraylib.web.a
|
||||
NAME := $(NAME).html
|
||||
CC := emcc
|
||||
AR := emar
|
||||
CFLAGS += -v
|
||||
CFLAGS += -v -DROOT_DIRECTORY=\"/data\"
|
||||
LDFLAGS += -s USE_GLFW=3 \
|
||||
-s ASYNCIFY \
|
||||
-s ASSERTIONS=1 \
|
||||
-s SAFE_HEAP=1 \
|
||||
--preload-file scenes \
|
||||
--preload-file assets \
|
||||
--preload-file scenes@/data/scenes \
|
||||
--preload-file assets@/data/assets \
|
||||
--shell-file raylib/src/shell.html \
|
||||
-DPLATFORM_WEB \
|
||||
-s INITIAL_MEMORY=2147483648
|
||||
else
|
||||
CFLAGS += -DROOT_DIRECTORY=\"$(PWD)\"
|
||||
endif
|
||||
|
||||
VNC_SCRIPT := ./script/run_vnc.sh
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
13
minirt.h
13
minirt.h
@ -53,6 +53,10 @@
|
||||
|
||||
# define ASPECT_RATIO 1.77777778
|
||||
|
||||
# ifndef ROOT_DIRECTORY
|
||||
# define ROOT_DIRECTORY "/"
|
||||
# endif
|
||||
|
||||
# ifndef __EMSCRIPTEN__
|
||||
# define SCENE_MAX_RESOLUTION_X 1
|
||||
# define SCENE_MAX_RESOLUTION_Y 1
|
||||
@ -378,13 +382,16 @@ typedef struct s_cone
|
||||
} t_cone;
|
||||
|
||||
# ifndef TEXTURE_PATH
|
||||
# define TEXTURE_PATH "./assets/textures/earth.ppm"
|
||||
# define TEXTURE_PATH ASSETS_PATH"/textures/earth.ppm"
|
||||
# endif
|
||||
|
||||
# ifndef SKYBOX_PATH
|
||||
# define SKYBOX_PATH "./assets/textures/sky.ppm"
|
||||
# define SKYBOX_PATH ASSETS_PATH"/textures/sky.ppm"
|
||||
# endif
|
||||
|
||||
# define ASSETS_PATH ROOT_DIRECTORY"/assets"
|
||||
# define SCENES_PATH ROOT_DIRECTORY"/scenes"
|
||||
|
||||
typedef struct s_texture
|
||||
{
|
||||
Color *pixel;
|
||||
@ -394,7 +401,7 @@ typedef struct s_texture
|
||||
} t_texture;
|
||||
|
||||
# ifndef BUMP_MAP_PATH
|
||||
# define BUMP_MAP_PATH "./assets/bump maps/earth.bump"
|
||||
# define BUMP_MAP_PATH ASSETS_PATH"/bump maps/earth.bump"
|
||||
# endif
|
||||
|
||||
typedef struct s_bump_map
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../minirt.h"
|
||||
#include <unistd.h>
|
||||
|
||||
void container_item_dirent_create(t_item *item, char *title, \
|
||||
int type, void (*func)(void *, void *))
|
||||
@ -25,6 +26,17 @@ void container_item_dirent_create(t_item *item, char *title, \
|
||||
void explorer_create(t_container *explorer, t_data *data)
|
||||
{
|
||||
ft_bzero(explorer, sizeof(*explorer));
|
||||
char cwd[1024] = {0};
|
||||
if (getcwd(cwd, sizeof(cwd)) == NULL) {
|
||||
ft_fprintf(STDERR_FILENO, "Failed to get current directory, exiting...\n");
|
||||
lst_memory(NULL, NULL, FAIL);
|
||||
}
|
||||
if (ft_strncmp(cwd, ROOT_DIRECTORY, ft_strlen(ROOT_DIRECTORY)) != 0) {
|
||||
if (chdir(ROOT_DIRECTORY) != 0) {
|
||||
ft_fprintf(STDERR_FILENO, "Failed to change directory, exiting...\n");
|
||||
lst_memory(NULL, NULL, FAIL);
|
||||
}
|
||||
}
|
||||
*explorer = container_create("Explorer", NULL, CONTAINER_LIST);
|
||||
explorer->data = data;
|
||||
}
|
||||
@ -35,12 +47,20 @@ void explorer_read_dir_loop(DIR *dir, void *param, \
|
||||
struct dirent *entry;
|
||||
t_item item;
|
||||
|
||||
bool is_root_dir = ft_strncmp(cwd, ROOT_DIRECTORY, ft_strlen(cwd)) == 0;
|
||||
|
||||
ft_strlcpy(explorer->title, cwd, CONTAINER_TITLE_LEN);
|
||||
while (1)
|
||||
{
|
||||
entry = readdir(dir);
|
||||
if (!entry)
|
||||
break ;
|
||||
else if ( is_root_dir && (
|
||||
ft_strncmp(entry->d_name, ".", ft_strlen(entry->d_name)) == 0 ||
|
||||
ft_strncmp(entry->d_name, "..", ft_strlen(entry->d_name)) == 0
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
container_item_dirent_create(&item, entry->d_name, \
|
||||
entry->d_type, explorer_entry_func);
|
||||
ft_strlcpy(item.dirent.full_path, cwd, 1024);
|
||||
|
||||
@ -109,7 +109,7 @@ void glyph_print( uint begin_x, \
|
||||
static char ***glyph = {0};
|
||||
|
||||
if (!glyph)
|
||||
glyphs_create(&glyph, "./assets/alpha_bit_bonus");
|
||||
glyphs_create(&glyph, ASSETS_PATH"/alpha_bit_bonus");
|
||||
x = begin_x;
|
||||
i = 0;
|
||||
while (text[i])
|
||||
|
||||
@ -261,7 +261,7 @@ int main(int argc, char **argv)
|
||||
#endif /* ifndef __EMSCRIPTEN__ */
|
||||
|
||||
if (argc == 1)
|
||||
path = "scenes/multilight.rt";
|
||||
path = SCENES_PATH"/multilight.rt";
|
||||
else
|
||||
path = validate_file_extension(argc, argv);
|
||||
initialize_data(&data, path);
|
||||
|
||||
@ -89,7 +89,6 @@ void ray_check_bodys(t_pixel *pixel, t_vector ray, t_scene *scene)
|
||||
uint rendering_loop(t_data *data)
|
||||
{
|
||||
if (data->should_rerender) {
|
||||
ft_printf("Rendering\n");
|
||||
#ifndef __EMSCRIPTEN__
|
||||
pthread_rwlock_unlock(&data->rwlock);
|
||||
pthread_barrier_wait(&data->barrier);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user