Преглед изворни кода

WARNING: Issues on web building

Found some issues when building for web using latest emscripten 1.38.30, traced the error and found that eglGetProcAdress does not return function pointers for VAO functionality, supported by extension.

It requires more investigation but now it works (avoiding VAO usage)
pull/812/head
Ray пре 6 година
родитељ
комит
0c567cd259
7 измењених фајлова са 27 додато и 15 уклоњено
  1. +5
    -4
      examples/Makefile
  2. +1
    -1
      src/Makefile
  3. +2
    -1
      src/core.c
  4. +2
    -2
      src/external/cgltf.h
  5. +0
    -2
      src/external/miniaudio.h
  6. +12
    -0
      src/rlgl.h
  7. +5
    -5
      templates/web_shell/shell.html

+ 5
- 4
examples/Makefile Прегледај датотеку

@ -25,7 +25,7 @@
# Define required raylib variables # Define required raylib variables
PROJECT_NAME ?= raylib_examples PROJECT_NAME ?= raylib_examples
RAYLIB_VERSION ?= 2.0.0
RAYLIB_VERSION ?= 2.5.0
RAYLIB_API_VERSION ?= 1 RAYLIB_API_VERSION ?= 1
RAYLIB_PATH ?= .. RAYLIB_PATH ?= ..
@ -118,8 +118,8 @@ endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH = C:/emsdk EMSDK_PATH = C:/emsdk
EMSCRIPTEN_VERSION = 1.38.21
CLANG_VERSION = e1.38.21_64bit
EMSCRIPTEN_VERSION = 1.38.30
CLANG_VERSION = e1.38.30_64bit
PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64 PYTHON_VERSION = 2.7.13.1_64bit\python-2.7.13.amd64
NODE_VERSION = 8.9.1_64bit NODE_VERSION = 8.9.1_64bit
export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH) export PATH = $(EMSDK_PATH);$(EMSDK_PATH)\clang\$(CLANG_VERSION);$(EMSDK_PATH)\node\$(NODE_VERSION)\bin;$(EMSDK_PATH)\python\$(PYTHON_VERSION);$(EMSDK_PATH)\emscripten\$(EMSCRIPTEN_VERSION);C:\raylib\MinGW\bin:$$(PATH)
@ -249,7 +249,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter
# --profiling # include information for code profiling # --profiling # include information for code profiling
# --preload-file resources # specify a resources folder for data compilation # --preload-file resources # specify a resources folder for data compilation
CFLAGS += -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1
CFLAGS += -Os -s USE_GLFW=3 -s ASSERTIONS=2 -s WASM=1
# -Os -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1
# NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way, # NOTE: Simple raylib examples are compiled to be interpreter by emterpreter, that way,
# we can compile same code for ALL platforms with no change required, but, working on bigger # we can compile same code for ALL platforms with no change required, but, working on bigger

+ 1
- 1
src/Makefile Прегледај датотеку

@ -42,7 +42,7 @@
.PHONY: all clean install uninstall .PHONY: all clean install uninstall
# Define required raylib variables # Define required raylib variables
RAYLIB_VERSION = 2.4.0
RAYLIB_VERSION = 2.5.0
RAYLIB_API_VERSION = 2 RAYLIB_API_VERSION = 2
# See below for alternatives. # See below for alternatives.

+ 2
- 1
src/core.c Прегледај датотеку

@ -3172,7 +3172,8 @@ static void PollInputEvents(void)
// NOTE: GLFW3 joystick functionality not available in web // NOTE: GLFW3 joystick functionality not available in web
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
// Get number of gamepads connected // Get number of gamepads connected
int numGamepads = emscripten_get_num_gamepads();
int numGamepads = 0;
if (emscripten_sample_gamepad_data() == EMSCRIPTEN_RESULT_SUCCESS) numGamepads = emscripten_get_num_gamepads();
for (int i = 0; (i < numGamepads) && (i < MAX_GAMEPADS); i++) for (int i = 0; (i < numGamepads) && (i < MAX_GAMEPADS); i++)
{ {

+ 2
- 2
src/external/cgltf.h Прегледај датотеку

@ -369,7 +369,7 @@ typedef struct cgltf_light {
cgltf_float spot_outer_cone_angle; cgltf_float spot_outer_cone_angle;
} cgltf_light; } cgltf_light;
typedef struct cgltf_node {
struct cgltf_node {
char* name; char* name;
cgltf_node* parent; cgltf_node* parent;
cgltf_node** children; cgltf_node** children;
@ -388,7 +388,7 @@ typedef struct cgltf_node {
cgltf_float rotation[4]; cgltf_float rotation[4];
cgltf_float scale[3]; cgltf_float scale[3];
cgltf_float matrix[16]; cgltf_float matrix[16];
} cgltf_node;
};
typedef struct cgltf_scene { typedef struct cgltf_scene {
char* name; char* name;

+ 0
- 2
src/external/miniaudio.h Прегледај датотеку

@ -21915,8 +21915,6 @@ extern "C" {
#endif #endif
EMSCRIPTEN_KEEPALIVE void ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames) EMSCRIPTEN_KEEPALIVE void ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames)
{ {
ma_result result;
if (pDevice->type == ma_device_type_duplex) { if (pDevice->type == ma_device_type_duplex) {
ma_device__handle_duplex_callback_capture(pDevice, (ma_uint32)frameCount, pFrames, &pDevice->webaudio.duplexRB); ma_device__handle_duplex_callback_capture(pDevice, (ma_uint32)frameCount, pFrames, &pDevice->webaudio.duplexRB);
} else { } else {

+ 12
- 0
src/rlgl.h Прегледај датотеку

@ -1559,7 +1559,19 @@ void rlglInit(int width, int height)
glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES"); glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES");
glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES"); glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES");
//glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES"); // NOTE: Fails in WebGL, omitted //glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES"); // NOTE: Fails in WebGL, omitted
if (glGenVertexArrays == NULL) printf("glGenVertexArrays is NULL.\n"); // WEB: ISSUE FOUND! ...but why?
if (glBindVertexArray == NULL) printf("glBindVertexArray is NULL.\n"); // WEB: ISSUE FOUND! ...but why?
} }
// TODO: HACK REVIEW!
// For some reason on raylib 2.5, VAO usage breaks the build
// error seems related to function pointers but I can not get detailed info...
// Avoiding VAO usage is the only solution for now... :(
// Ref: https://emscripten.org/docs/porting/guidelines/function_pointer_issues.html
#if defined(PLATFORM_WEB)
vaoSupported = false;
#endif
// Check NPOT textures support // Check NPOT textures support
// NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature // NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature

+ 5
- 5
templates/web_shell/shell.html Прегледај датотеку

@ -178,14 +178,14 @@
} }
</script> </script>
<script type='text/javascript'> <script type='text/javascript'>
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner');
var statusElement = document.querySelector('#status');
var progressElement = document.querySelector('#progress');
var spinnerElement = document.querySelector('#spinner');
var Module = { var Module = {
preRun: [], preRun: [],
postRun: [], postRun: [],
print: (function() { print: (function() {
var element = document.getElementById('output');
var element = document.querySelector('#output');
if (element) element.value = ''; // clear browser cache if (element) element.value = ''; // clear browser cache
return function(text) { return function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
@ -210,7 +210,7 @@
} }
}, },
canvas: (function() { canvas: (function() {
var canvas = document.getElementById('canvas');
var canvas = document.querySelector('#canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your // As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping! // application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2

Loading…
Откажи
Сачувај