fix emscripten build

This commit is contained in:
Toad King 2014-06-18 20:31:41 -04:00
parent 9fc10a3d9a
commit bb40fff99d
4 changed files with 41 additions and 20 deletions

View File

@ -3,6 +3,7 @@ TARGET = retroarch.js
OBJ = frontend/platform/platform_emscripten.o \ OBJ = frontend/platform/platform_emscripten.o \
frontend/platform/platform_null.o \ frontend/platform/platform_null.o \
frontend/frontend.o \ frontend/frontend.o \
frontend/menu/menu_input_line_cb.o \
retroarch.o \ retroarch.o \
file.o \ file.o \
file_path.o \ file_path.o \
@ -19,6 +20,7 @@ OBJ = frontend/platform/platform_emscripten.o \
gfx/gfx_common.o \ gfx/gfx_common.o \
input/input_common.o \ input/input_common.o \
input/rwebinput_input.o \ input/rwebinput_input.o \
input/keyboard_line.o \
core_options.o \ core_options.o \
patch.o \ patch.o \
compat/compat.o \ compat/compat.o \
@ -27,6 +29,7 @@ OBJ = frontend/platform/platform_emscripten.o \
cheats.o \ cheats.o \
audio/utils.o \ audio/utils.o \
audio/rwebaudio.o \ audio/rwebaudio.o \
audio/dsp_filter.o \
input/overlay.o \ input/overlay.o \
fifo_buffer.o \ fifo_buffer.o \
gfx/scaler/scaler.o \ gfx/scaler/scaler.o \
@ -39,6 +42,7 @@ OBJ = frontend/platform/platform_emscripten.o \
gfx/fonts/fonts.o \ gfx/fonts/fonts.o \
gfx/fonts/bitmapfont.o \ gfx/fonts/bitmapfont.o \
gfx/image/image_rpng.o \ gfx/image/image_rpng.o \
gfx/filter.o \
audio/resampler.o \ audio/resampler.o \
audio/sinc.o \ audio/sinc.o \
audio/cc_resampler.o \ audio/cc_resampler.o \
@ -93,7 +97,7 @@ ifeq ($(HAVE_ZLIB), 1)
OBJ += gfx/rpng/rpng.o file_extract.o OBJ += gfx/rpng/rpng.o file_extract.o
DEFINES += -DHAVE_ZLIB DEFINES += -DHAVE_ZLIB
ifeq ($(WANT_MINIZ), 1) ifeq ($(WANT_MINIZ), 1)
OBJ += deps/miniz/miniz.o OBJ += deps/rzlib/adler32.o deps/rzlib/compress.o deps/rzlib/crc32.o deps/rzlib/deflate.o deps/rzlib/gzclose.o deps/rzlib/gzlib.o deps/rzlib/gzread.o deps/rzlib/gzwrite.o deps/rzlib/inffast.o deps/rzlib/inflate.o deps/rzlib/inftrees.o deps/rzlib/trees.o deps/rzlib/uncompr.o deps/rzlib/zutil.o deps/rzlib/ioapi.o deps/rzlib/unzip.o
DEFINES += -DWANT_MINIZ DEFINES += -DWANT_MINIZ
else else
LIBS += -lz LIBS += -lz

2
deps/rzlib/gzguts.h vendored
View File

@ -32,6 +32,8 @@
#ifdef _WIN32 #ifdef _WIN32
# include <stddef.h> # include <stddef.h>
#else
# include <unistd.h>
#endif #endif
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)

View File

@ -34,7 +34,7 @@ static void emscripten_mainloop(void)
exit(0); exit(0);
} }
int main(int *argc, char *argv[]) int main(int argc, char *argv[])
{ {
emscripten_set_canvas_size(800, 600); emscripten_set_canvas_size(800, 600);
@ -42,7 +42,7 @@ int main(int *argc, char *argv[])
rarch_init_msg_queue(); rarch_init_msg_queue();
int init_ret; int init_ret;
if ((init_ret = rarch_main_init(*argc, argv))) return init_ret; if ((init_ret = rarch_main_init(argc, argv))) return init_ret;
#ifdef HAVE_MENU #ifdef HAVE_MENU
g_extern.lifecycle_state |= 1ULL << MODE_GAME; g_extern.lifecycle_state |= 1ULL << MODE_GAME;

View File

@ -42,15 +42,17 @@ static bool g_inited;
static unsigned g_fb_width; static unsigned g_fb_width;
static unsigned g_fb_height; static unsigned g_fb_height;
static void gfx_ctx_swap_interval(unsigned interval) static void gfx_ctx_swap_interval(void *data, unsigned interval)
{ {
(void)data;
// no way to control vsync in WebGL // no way to control vsync in WebGL
(void)interval; (void)interval;
} }
static void gfx_ctx_check_window(bool *quit, static void gfx_ctx_check_window(void *data, bool *quit,
bool *resize, unsigned *width, unsigned *height, unsigned frame_count) bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
{ {
(void)data;
(void)frame_count; (void)frame_count;
int iWidth, iHeight, isFullscreen; int iWidth, iHeight, isFullscreen;
@ -68,20 +70,23 @@ static void gfx_ctx_check_window(bool *quit,
*quit = false; *quit = false;
} }
static void gfx_ctx_swap_buffers(void) static void gfx_ctx_swap_buffers(void *data)
{ {
(void)data;
// no-op in emscripten, no way to force swap/wait for vsync in browsers // no-op in emscripten, no way to force swap/wait for vsync in browsers
//eglSwapBuffers(g_egl_dpy, g_egl_surf); //eglSwapBuffers(g_egl_dpy, g_egl_surf);
} }
static void gfx_ctx_set_resize(unsigned width, unsigned height) static void gfx_ctx_set_resize(void *data, unsigned width, unsigned height)
{ {
(void)data;
(void)width; (void)width;
(void)height; (void)height;
} }
static void gfx_ctx_update_window_title(void) static void gfx_ctx_update_window_title(void *data)
{ {
(void)data;
char buf[128], buf_fps[128]; char buf[128], buf_fps[128];
bool fps_draw = g_settings.fps_show; bool fps_draw = g_settings.fps_show;
gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps));
@ -90,16 +95,18 @@ static void gfx_ctx_update_window_title(void)
msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1);
} }
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height) static void gfx_ctx_get_video_size(void *data, unsigned *width, unsigned *height)
{ {
(void)data;
*width = g_fb_width; *width = g_fb_width;
*height = g_fb_height; *height = g_fb_height;
} }
static void gfx_ctx_destroy(void); static void gfx_ctx_destroy(void *data);
static bool gfx_ctx_init(void) static bool gfx_ctx_init(void *data)
{ {
(void)data;
EGLint width; EGLint width;
EGLint height; EGLint height;
@ -164,14 +171,15 @@ static bool gfx_ctx_init(void)
return true; return true;
error: error:
gfx_ctx_destroy(); gfx_ctx_destroy(data);
return false; return false;
} }
static bool gfx_ctx_set_video_mode( static bool gfx_ctx_set_video_mode(void *data,
unsigned width, unsigned height, unsigned width, unsigned height,
bool fullscreen) bool fullscreen)
{ {
(void)data;
if (g_inited) if (g_inited)
return false; return false;
@ -179,8 +187,9 @@ static bool gfx_ctx_set_video_mode(
return true; return true;
} }
static bool gfx_ctx_bind_api(enum gfx_ctx_api api, unsigned major, unsigned minor) static bool gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
{ {
(void)data;
(void)major; (void)major;
(void)minor; (void)minor;
switch (api) switch (api)
@ -192,8 +201,9 @@ static bool gfx_ctx_bind_api(enum gfx_ctx_api api, unsigned major, unsigned mino
} }
} }
static void gfx_ctx_destroy(void) static void gfx_ctx_destroy(void *data)
{ {
(void)data;
if (g_egl_dpy) if (g_egl_dpy)
{ {
eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(g_egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
@ -218,8 +228,9 @@ static void gfx_ctx_destroy(void)
g_inited = false; g_inited = false;
} }
static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data) static void gfx_ctx_input_driver(void *data, const input_driver_t **input, void **input_data)
{ {
(void)data;
*input = NULL; *input = NULL;
void *rwebinput = input_rwebinput.init(); void *rwebinput = input_rwebinput.init();
@ -231,8 +242,9 @@ static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data
} }
} }
static bool gfx_ctx_has_focus(void) static bool gfx_ctx_has_focus(void *data)
{ {
(void)data;
return g_inited; return g_inited;
} }
@ -241,18 +253,21 @@ static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
return eglGetProcAddress(symbol); return eglGetProcAddress(symbol);
} }
static float gfx_ctx_translate_aspect(unsigned width, unsigned height) static float gfx_ctx_translate_aspect(void *data, unsigned width, unsigned height)
{ {
(void)data;
return (float)width / height; return (float)width / height;
} }
static bool gfx_ctx_init_egl_image_buffer(const video_info_t *video) static bool gfx_ctx_init_egl_image_buffer(void *data, const video_info_t *video)
{ {
(void)data;
return false; return false;
} }
static bool gfx_ctx_write_egl_image(const void *frame, unsigned width, unsigned height, unsigned pitch, bool rgb32, unsigned index, void **image_handle) static bool gfx_ctx_write_egl_image(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, bool rgb32, unsigned index, void **image_handle)
{ {
(void)data;
return false; return false;
} }