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_WASM := $(WEB_OUTPUT).wasm
|
||||||
WEB_OUTPUT_DATA := $(WEB_OUTPUT).data
|
WEB_OUTPUT_DATA := $(WEB_OUTPUT).data
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(PLATFORM), PLATFORM_WEB)
|
ifeq ($(PLATFORM), PLATFORM_WEB)
|
||||||
LIBRAYLIB := libraylib.web.a
|
LIBRAYLIB := libraylib.web.a
|
||||||
NAME := $(NAME).html
|
NAME := $(NAME).html
|
||||||
CC := emcc
|
CC := emcc
|
||||||
AR := emar
|
AR := emar
|
||||||
CFLAGS += -v
|
CFLAGS += -v -DROOT_DIRECTORY=\"/data\"
|
||||||
LDFLAGS += -s USE_GLFW=3 \
|
LDFLAGS += -s USE_GLFW=3 \
|
||||||
-s ASYNCIFY \
|
-s ASYNCIFY \
|
||||||
-s ASSERTIONS=1 \
|
-s ASSERTIONS=1 \
|
||||||
-s SAFE_HEAP=1 \
|
-s SAFE_HEAP=1 \
|
||||||
--preload-file scenes \
|
--preload-file scenes@/data/scenes \
|
||||||
--preload-file assets \
|
--preload-file assets@/data/assets \
|
||||||
--shell-file raylib/src/shell.html \
|
--shell-file raylib/src/shell.html \
|
||||||
-DPLATFORM_WEB \
|
-DPLATFORM_WEB \
|
||||||
-s INITIAL_MEMORY=2147483648
|
-s INITIAL_MEMORY=2147483648
|
||||||
|
else
|
||||||
|
CFLAGS += -DROOT_DIRECTORY=\"$(PWD)\"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
VNC_SCRIPT := ./script/run_vnc.sh
|
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
|
# define ASPECT_RATIO 1.77777778
|
||||||
|
|
||||||
|
# ifndef ROOT_DIRECTORY
|
||||||
|
# define ROOT_DIRECTORY "/"
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifndef __EMSCRIPTEN__
|
# ifndef __EMSCRIPTEN__
|
||||||
# define SCENE_MAX_RESOLUTION_X 1
|
# define SCENE_MAX_RESOLUTION_X 1
|
||||||
# define SCENE_MAX_RESOLUTION_Y 1
|
# define SCENE_MAX_RESOLUTION_Y 1
|
||||||
@ -378,13 +382,16 @@ typedef struct s_cone
|
|||||||
} t_cone;
|
} t_cone;
|
||||||
|
|
||||||
# ifndef TEXTURE_PATH
|
# ifndef TEXTURE_PATH
|
||||||
# define TEXTURE_PATH "./assets/textures/earth.ppm"
|
# define TEXTURE_PATH ASSETS_PATH"/textures/earth.ppm"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef SKYBOX_PATH
|
# ifndef SKYBOX_PATH
|
||||||
# define SKYBOX_PATH "./assets/textures/sky.ppm"
|
# define SKYBOX_PATH ASSETS_PATH"/textures/sky.ppm"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# define ASSETS_PATH ROOT_DIRECTORY"/assets"
|
||||||
|
# define SCENES_PATH ROOT_DIRECTORY"/scenes"
|
||||||
|
|
||||||
typedef struct s_texture
|
typedef struct s_texture
|
||||||
{
|
{
|
||||||
Color *pixel;
|
Color *pixel;
|
||||||
@ -394,7 +401,7 @@ typedef struct s_texture
|
|||||||
} t_texture;
|
} t_texture;
|
||||||
|
|
||||||
# ifndef BUMP_MAP_PATH
|
# ifndef BUMP_MAP_PATH
|
||||||
# define BUMP_MAP_PATH "./assets/bump maps/earth.bump"
|
# define BUMP_MAP_PATH ASSETS_PATH"/bump maps/earth.bump"
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
typedef struct s_bump_map
|
typedef struct s_bump_map
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../../minirt.h"
|
#include "../../minirt.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
void container_item_dirent_create(t_item *item, char *title, \
|
void container_item_dirent_create(t_item *item, char *title, \
|
||||||
int type, void (*func)(void *, void *))
|
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)
|
void explorer_create(t_container *explorer, t_data *data)
|
||||||
{
|
{
|
||||||
ft_bzero(explorer, sizeof(*explorer));
|
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 = container_create("Explorer", NULL, CONTAINER_LIST);
|
||||||
explorer->data = data;
|
explorer->data = data;
|
||||||
}
|
}
|
||||||
@ -32,8 +44,10 @@ void explorer_create(t_container *explorer, t_data *data)
|
|||||||
void explorer_read_dir_loop(DIR *dir, void *param, \
|
void explorer_read_dir_loop(DIR *dir, void *param, \
|
||||||
char *cwd, t_container *explorer)
|
char *cwd, t_container *explorer)
|
||||||
{
|
{
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
t_item item;
|
t_item item;
|
||||||
|
|
||||||
|
bool is_root_dir = ft_strncmp(cwd, ROOT_DIRECTORY, ft_strlen(cwd)) == 0;
|
||||||
|
|
||||||
ft_strlcpy(explorer->title, cwd, CONTAINER_TITLE_LEN);
|
ft_strlcpy(explorer->title, cwd, CONTAINER_TITLE_LEN);
|
||||||
while (1)
|
while (1)
|
||||||
@ -41,6 +55,12 @@ void explorer_read_dir_loop(DIR *dir, void *param, \
|
|||||||
entry = readdir(dir);
|
entry = readdir(dir);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
break ;
|
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, \
|
container_item_dirent_create(&item, entry->d_name, \
|
||||||
entry->d_type, explorer_entry_func);
|
entry->d_type, explorer_entry_func);
|
||||||
ft_strlcpy(item.dirent.full_path, cwd, 1024);
|
ft_strlcpy(item.dirent.full_path, cwd, 1024);
|
||||||
|
|||||||
@ -109,7 +109,7 @@ void glyph_print( uint begin_x, \
|
|||||||
static char ***glyph = {0};
|
static char ***glyph = {0};
|
||||||
|
|
||||||
if (!glyph)
|
if (!glyph)
|
||||||
glyphs_create(&glyph, "./assets/alpha_bit_bonus");
|
glyphs_create(&glyph, ASSETS_PATH"/alpha_bit_bonus");
|
||||||
x = begin_x;
|
x = begin_x;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (text[i])
|
while (text[i])
|
||||||
|
|||||||
@ -261,7 +261,7 @@ int main(int argc, char **argv)
|
|||||||
#endif /* ifndef __EMSCRIPTEN__ */
|
#endif /* ifndef __EMSCRIPTEN__ */
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
path = "scenes/multilight.rt";
|
path = SCENES_PATH"/multilight.rt";
|
||||||
else
|
else
|
||||||
path = validate_file_extension(argc, argv);
|
path = validate_file_extension(argc, argv);
|
||||||
initialize_data(&data, path);
|
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)
|
uint rendering_loop(t_data *data)
|
||||||
{
|
{
|
||||||
if (data->should_rerender) {
|
if (data->should_rerender) {
|
||||||
ft_printf("Rendering\n");
|
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
pthread_rwlock_unlock(&data->rwlock);
|
pthread_rwlock_unlock(&data->rwlock);
|
||||||
pthread_barrier_wait(&data->barrier);
|
pthread_barrier_wait(&data->barrier);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user