From f21761fbbb02f0b58b5b54342f0c3ad3abc0003e Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 7 Apr 2019 17:49:12 +0200 Subject: Happy new year 2019 --- examples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/Makefile') diff --git a/examples/Makefile b/examples/Makefile index e14762b3..b35e39f9 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -2,7 +2,7 @@ # # raylib makefile for Desktop platforms, Raspberry Pi, Android and HTML5 # -# Copyright (c) 2013-2018 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. -- cgit v1.2.3 From 99537efccf077c0425c1de1188df632bfe96d125 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 12 Apr 2019 13:29:53 +0200 Subject: Review some examples --- examples/Makefile | 2 +- examples/core/core_input_multitouch.c | 87 ++++++++++++++++++++++++++++ examples/core/core_input_multitouch.png | Bin 0 -> 17177 bytes examples/core/core_multitouch.c | 90 ----------------------------- examples/core/core_multitouch.png | Bin 17177 -> 0 bytes examples/textures/textures_srcrec_dstrec.c | 8 +-- 6 files changed, 92 insertions(+), 95 deletions(-) create mode 100644 examples/core/core_input_multitouch.c create mode 100644 examples/core/core_input_multitouch.png delete mode 100644 examples/core/core_multitouch.c delete mode 100644 examples/core/core_multitouch.png (limited to 'examples/Makefile') diff --git a/examples/Makefile b/examples/Makefile index b35e39f9..2ceb3f7d 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -377,7 +377,7 @@ EXAMPLES = \ core/core_2d_camera \ core/core_world_screen \ core/core_vr_simulator \ - core/core_multitouch \ + core/core_input_multitouch \ shapes/shapes_logo_raylib \ shapes/shapes_basic_shapes \ shapes/shapes_colors_palette \ diff --git a/examples/core/core_input_multitouch.c b/examples/core/core_input_multitouch.c new file mode 100644 index 00000000..ef8fa7ae --- /dev/null +++ b/examples/core/core_input_multitouch.c @@ -0,0 +1,87 @@ +/******************************************************************************************* +* +* raylib [core] example - Input multitouch +* +* This example has been created using raylib 2.1 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014-2019 Berni and Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch"); + + Vector2 ballPosition = { -100.0f, -100.0f }; + Color ballColor = BEIGE; + + int touchCounter = 0; + Vector2 touchPosition; + + SetTargetFPS(60); + //--------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + ballPosition = GetMousePosition(); + + ballColor = BEIGE; + + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) ballColor = MAROON; + if (IsMouseButtonDown(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; + if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; + + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) touchCounter = 10; + if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) touchCounter = 10; + if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) touchCounter = 10; + + if (touchCounter > 0) touchCounter--; + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + // Multitouch + for (int i = 0; i < MAX_TOUCH_POINTS; ++i) + { + touchPosition = GetTouchPosition(i); // Get the touch point + + if ((touchPosition.x >= 0) && (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it + { + // Draw circle and touch index number + DrawCircleV(touchPosition, 34, ORANGE); + DrawText(FormatText("%d", i), touchPosition.x - 10, touchPosition.y - 70, 40, BLACK); + } + } + + // Draw the normal mouse location + DrawCircleV(ballPosition, 30 + (touchCounter*3), ballColor); + + DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); + DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/core/core_input_multitouch.png b/examples/core/core_input_multitouch.png new file mode 100644 index 00000000..74284f82 Binary files /dev/null and b/examples/core/core_input_multitouch.png differ diff --git a/examples/core/core_multitouch.c b/examples/core/core_multitouch.c deleted file mode 100644 index c059ac03..00000000 --- a/examples/core/core_multitouch.c +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Multitouch input -* -* This example has been created using raylib 2.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* Example by Berni -* -********************************************************************************************/ - -#include "raylib.h" -#include - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - multitouch input"); - - Vector2 ballPosition = { -100.0f, -100.0f }; - Color ballColor; - int PressedCounter = 0; - Vector2 TouchPos; - char Str[16]; - - SetTargetFPS(60); - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - ballPosition = GetMousePosition(); - - ballColor = BEIGE; - - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) ballColor = MAROON; - if (IsMouseButtonDown(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; - if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) PressedCounter = 10; - if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) PressedCounter = 10; - if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) PressedCounter = 10; - if(PressedCounter > 0) - PressedCounter--; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Multitouch - for (int i = 0; i < MAX_TOUCH_POINTS; ++i) - { - TouchPos = GetTouchPosition(i); // Get the touch point - - if( (TouchPos.x >= 0) && (TouchPos.y >= 0) ) // Make sure point is not (-1,-1) as this means there is no touch for it - { - DrawCircleV(TouchPos, 34, ORANGE); // Draw a circle there - - sprintf(Str,"%d",i); - DrawText(Str, TouchPos.x - 10, TouchPos.y - 70, 40, BLACK); // Also show its index number - } - } - - // Draw the normal mouse location - DrawCircleV(ballPosition, 30 + (PressedCounter * 3), ballColor); - - DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); - DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/examples/core/core_multitouch.png b/examples/core/core_multitouch.png deleted file mode 100644 index 74284f82..00000000 Binary files a/examples/core/core_multitouch.png and /dev/null differ diff --git a/examples/textures/textures_srcrec_dstrec.c b/examples/textures/textures_srcrec_dstrec.c index cc08eb58..298a0c65 100644 --- a/examples/textures/textures_srcrec_dstrec.c +++ b/examples/textures/textures_srcrec_dstrec.c @@ -27,13 +27,13 @@ int main() int frameHeight = scarfy.height; // NOTE: Source rectangle (part of the texture to use for drawing) - Rectangle sourceRec = { 0.0f, 0.0f, (float)frameWidth, (float)frameHeight }; + Rectangle sourceRec = { 0.0f, 0.0f, frameWidth, frameHeight }; // NOTE: Destination rectangle (screen rectangle where drawing part of texture) - Rectangle destRec = { (float)screenWidth/2, (float)screenHeight/2, (float)frameWidth*2, (float)frameHeight*2 }; + Rectangle destRec = { screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 }; // NOTE: Origin of the texture (rotation/scale point), it's relative to destination rectangle size - Vector2 origin = { (float)frameWidth, (float)frameHeight }; + Vector2 origin = { frameWidth, frameHeight }; int rotation = 0; @@ -61,7 +61,7 @@ int main() // rotation defines the texture rotation (using origin as rotation point) DrawTexturePro(scarfy, sourceRec, destRec, origin, (float)rotation, WHITE); - DrawLine((int) destRec.x, 0, (int) destRec.x, screenHeight, GRAY); + DrawLine((int)destRec.x, 0, (int)destRec.x, screenHeight, GRAY); DrawLine(0, (int)destRec.y, screenWidth, (int)destRec.y, GRAY); DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, GRAY); -- cgit v1.2.3 From 0c567cd259285fb33b3e2ab514c48322da0a0000 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 23 Apr 2019 18:10:38 +0200 Subject: 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) --- examples/Makefile | 9 +++++---- src/Makefile | 2 +- src/core.c | 3 ++- src/external/cgltf.h | 4 ++-- src/external/miniaudio.h | 2 -- src/rlgl.h | 12 ++++++++++++ templates/web_shell/shell.html | 10 +++++----- 7 files changed, 27 insertions(+), 15 deletions(-) (limited to 'examples/Makefile') diff --git a/examples/Makefile b/examples/Makefile index 2ceb3f7d..a1d45ef6 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -25,7 +25,7 @@ # Define required raylib variables PROJECT_NAME ?= raylib_examples -RAYLIB_VERSION ?= 2.0.0 +RAYLIB_VERSION ?= 2.5.0 RAYLIB_API_VERSION ?= 1 RAYLIB_PATH ?= .. @@ -118,8 +118,8 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # Emscripten required variables 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 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) @@ -249,7 +249,8 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter # --profiling # include information for code profiling # --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, # we can compile same code for ALL platforms with no change required, but, working on bigger diff --git a/src/Makefile b/src/Makefile index 997f041c..ea09aa9f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -42,7 +42,7 @@ .PHONY: all clean install uninstall # Define required raylib variables -RAYLIB_VERSION = 2.4.0 +RAYLIB_VERSION = 2.5.0 RAYLIB_API_VERSION = 2 # See below for alternatives. diff --git a/src/core.c b/src/core.c index 844994d0..5ec3b76a 100644 --- a/src/core.c +++ b/src/core.c @@ -3172,7 +3172,8 @@ static void PollInputEvents(void) // NOTE: GLFW3 joystick functionality not available in web #if defined(PLATFORM_WEB) // 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++) { diff --git a/src/external/cgltf.h b/src/external/cgltf.h index 4302e77b..85d5c985 100644 --- a/src/external/cgltf.h +++ b/src/external/cgltf.h @@ -369,7 +369,7 @@ typedef struct cgltf_light { cgltf_float spot_outer_cone_angle; } cgltf_light; -typedef struct cgltf_node { +struct cgltf_node { char* name; cgltf_node* parent; cgltf_node** children; @@ -388,7 +388,7 @@ typedef struct cgltf_node { cgltf_float rotation[4]; cgltf_float scale[3]; cgltf_float matrix[16]; -} cgltf_node; +}; typedef struct cgltf_scene { char* name; diff --git a/src/external/miniaudio.h b/src/external/miniaudio.h index a5646c71..dae605f2 100644 --- a/src/external/miniaudio.h +++ b/src/external/miniaudio.h @@ -21915,8 +21915,6 @@ extern "C" { #endif 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) { ma_device__handle_duplex_callback_capture(pDevice, (ma_uint32)frameCount, pFrames, &pDevice->webaudio.duplexRB); } else { diff --git a/src/rlgl.h b/src/rlgl.h index dd2929ca..71a1dc4b 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1559,7 +1559,19 @@ void rlglInit(int width, int height) glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES"); glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES"); //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 // NOTE: Only check on OpenGL ES, OpenGL 3.3 has NPOT textures full support as core feature diff --git a/templates/web_shell/shell.html b/templates/web_shell/shell.html index f158c432..2e891461 100644 --- a/templates/web_shell/shell.html +++ b/templates/web_shell/shell.html @@ -178,14 +178,14 @@ } + + + {{{ SCRIPT }}} + + \ No newline at end of file diff --git a/templates/advance_game/Makefile b/templates/advance_game/Makefile index 784c7dca..95fb6f6f 100644 --- a/templates/advance_game/Makefile +++ b/templates/advance_game/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/templates/simple_game/Makefile b/templates/simple_game/Makefile index a1e65772..ea732c92 100644 --- a/templates/simple_game/Makefile +++ b/templates/simple_game/Makefile @@ -236,7 +236,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/templates/standard_game/Makefile b/templates/standard_game/Makefile index bd7906b8..56b76b42 100644 --- a/templates/standard_game/Makefile +++ b/templates/standard_game/Makefile @@ -230,7 +230,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB) endif # Define a custom shell .html and output extension - CFLAGS += --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html + CFLAGS += --shell-file $(RAYLIB_PATH)\src\shell.html EXT = .html endif diff --git a/templates/web_shell/shell.html b/templates/web_shell/shell.html deleted file mode 100644 index 641cfc02..00000000 --- a/templates/web_shell/shell.html +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - - raylib HTML5 GAME - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
Downloading...
- - - - - -
- -
-
- -
- -
- - - - - - - {{{ SCRIPT }}} - - \ No newline at end of file -- cgit v1.2.3 From 63e320d40524825f5632b4bb42017035aaf793ef Mon Sep 17 00:00:00 2001 From: XiaochuanWang Date: Sun, 9 Jun 2019 01:08:10 +1000 Subject: Update Makefile a minor issue: where the location of the file "raylib.rc.data" is wrong, and this will cause an error in compilation. --- examples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/Makefile') diff --git a/examples/Makefile b/examples/Makefile index e79bc364..02b55821 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -200,7 +200,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # resource file contains windows executable icon and properties # -Wl,--subsystem,windows hides the console window - CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows + CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows endif ifeq ($(PLATFORM_OS),LINUX) ifeq ($(RAYLIB_LIBTYPE),STATIC) -- cgit v1.2.3