From ca6c5f4f3c88b3a1091756ae70565335f5f734d6 Mon Sep 17 00:00:00 2001 From: 0riginaln0 <74508026+0riginaln0@users.noreply.github.com> Date: Sat, 7 Dec 2024 23:28:08 +0300 Subject: [PATCH 001/793] Update BINDINGS.md | Fennel Bindings (#4585) --- BINDINGS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BINDINGS.md b/BINDINGS.md index 5d158c998..873e6af0e 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -85,6 +85,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [raylib-cobol](https://codeberg.org/glowiak/raylib-cobol) | **auto** | [COBOL](https://gnucobol.sourceforge.io) | Public domain | | [raylib-apl](https://github.com/Brian-ED/raylib-apl) | **5.0** | [Dyalog APL](https://www.dyalog.com/) | MIT | | [raylib-jai](https://github.com/ahmedqarmout2/raylib-jai) | **5.5** | [Jai](https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md) | MIT | +| [fnl-raylib](https://github.com/0riginaln0/fnl-raylib) | **5.5** | [Fennel](https://fennel-lang.org/) | MIT | ### Utility Wrapers From 2820fcc29e91aac8155ffef45560070ecfc5752d Mon Sep 17 00:00:00 2001 From: danil <61111955+danilwhale@users.noreply.github.com> Date: Sun, 8 Dec 2024 09:52:09 +0200 Subject: [PATCH 002/793] [examples] improve input_virtual_controls example (#4584) --- examples/core/core_input_virtual_controls.c | 175 +++++++++++------- examples/core/core_input_virtual_controls.png | Bin 9094 -> 1802 bytes 2 files changed, 113 insertions(+), 62 deletions(-) diff --git a/examples/core/core_input_virtual_controls.c b/examples/core/core_input_virtual_controls.c index bbbad208f..76eeafee4 100644 --- a/examples/core/core_input_virtual_controls.c +++ b/examples/core/core_input_virtual_controls.c @@ -6,7 +6,8 @@ * * Example create by GreenSnakeLinux (@GreenSnakeLinux), * lighter by oblerion (@oblerion) and -* reviewed by Ramon Santamaria (@raysan5) +* reviewed by Ramon Santamaria (@raysan5) and +* improved by danilwhale (@danilwhale) * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software @@ -17,6 +18,16 @@ #include "raylib.h" #include + +typedef enum { + BUTTON_NONE = -1, + BUTTON_UP, + BUTTON_LEFT, + BUTTON_RIGHT, + BUTTON_DOWN, + BUTTON_MAX +} PadButton; + //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ @@ -29,24 +40,38 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [core] example - input virtual controls"); - const float dpadX = 90; - const float dpadY = 300; - const float dpadRad = 25.0f;//radius of each pad - Color dpadColor = BLUE; - int dpadKeydown = -1;//-1 if not down, else 0,1,2,3 + Vector2 padPosition = { 100, 350 }; + float buttonRadius = 30; - - const float dpadCollider[4][2]= // collider array with x,y position + Vector2 buttonPositions[BUTTON_MAX] = { - {dpadX,dpadY-dpadRad*1.5f},//up - {dpadX-dpadRad*1.5f,dpadY},//left - {dpadX+dpadRad*1.5f,dpadY},//right - {dpadX,dpadY+dpadRad*1.5f}//down + { padPosition.x,padPosition.y - buttonRadius*1.5f }, // Up + { padPosition.x - buttonRadius*1.5f, padPosition.y }, // Left + { padPosition.x + buttonRadius*1.5f, padPosition.y }, // Right + { padPosition.x, padPosition.y + buttonRadius*1.5f } // Down }; - const char dpadLabel[4]="XYBA";//label of Dpad - float playerX=100; - float playerY=100; + const char *buttonLabels[BUTTON_MAX] = + { + "Y", // Up + "X", // Left + "B", // Right + "A" // Down + }; + + Color buttonLabelColors[BUTTON_MAX] = + { + YELLOW, // Up + BLUE, // Left + RED, // Right + GREEN // Down + }; + + int pressedButton = BUTTON_NONE; + Vector2 inputPosition = { 0, 0 }; + + Vector2 playerPosition = { (float)screenWidth/2, (float)screenHeight/2 }; + float playerSpeed = 75; SetTargetFPS(60); //-------------------------------------------------------------------------------------- @@ -54,63 +79,89 @@ int main(void) // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //-------------------------------------------------------------------------- - dpadKeydown = -1; //reset - int inputX = 0; - int inputY = 0; - if(GetTouchPointCount()>0) - {//use touch pos - inputX = GetTouchX(); - inputY = GetTouchY(); + // Update + //-------------------------------------------------------------------------- + if ((GetTouchPointCount() > 0)) + { + // Use touch position + inputPosition = GetTouchPosition(0); } else - {//use mouse pos - inputX = GetMouseX(); - inputY = GetMouseY(); - } - for(int i=0;i<4;i++) { - //test distance each collider and input < radius - if( fabsf(dpadCollider[i][1]-inputY) + fabsf(dpadCollider[i][0]-inputX) < dpadRad) - { - dpadKeydown = i; - break; - } + // Use mouse position + inputPosition = GetMousePosition(); } - // move player - switch(dpadKeydown){ - case 0: playerY -= 50*GetFrameTime(); - break; - case 1: playerX -= 50*GetFrameTime(); - break; - case 2: playerX += 50*GetFrameTime(); - break; - case 3: playerY += 50*GetFrameTime(); - default:; - }; - //-------------------------------------------------------------------------- - // Draw - //-------------------------------------------------------------------------- - BeginDrawing(); - ClearBackground(RAYWHITE); - for(int i=0;i<4;i++) + + // Reset pressed button to none + pressedButton = BUTTON_NONE; + + // Make sure user is pressing left mouse button if they're from desktop + if ((GetTouchPointCount() > 0) || ((GetTouchPointCount() == 0) && IsMouseButtonDown(MOUSE_BUTTON_LEFT))) + { + // Find nearest D-Pad button to the input position + for (int i = 0; i < BUTTON_MAX; i++) { - //draw all pad - DrawCircleV((Vector2) { dpadCollider[i][0], dpadCollider[i][1] }, dpadRad, dpadColor); - if(i!=dpadKeydown) + float distX = fabsf(buttonPositions[i].x - inputPosition.x); + float distY = fabsf(buttonPositions[i].y - inputPosition.y); + + if ((distX + distY < buttonRadius)) { - //draw label - DrawText(TextSubtext(dpadLabel,i,1), - (int)dpadCollider[i][0]-7, - (int)dpadCollider[i][1]-8,20,BLACK); + pressedButton = i; + break; } } + } + + // Move player according to pressed button + switch (pressedButton) + { + case BUTTON_UP: + { + playerPosition.y -= playerSpeed*GetFrameTime(); + break; + } + case BUTTON_LEFT: + { + playerPosition.x -= playerSpeed*GetFrameTime(); + break; + } + case BUTTON_RIGHT: + { + playerPosition.x += playerSpeed*GetFrameTime(); + break; + } + case BUTTON_DOWN: + { + playerPosition.y += playerSpeed*GetFrameTime(); + break; + } + default: break; + }; + + //-------------------------------------------------------------------------- + // Draw + //-------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + // Draw world + DrawCircleV(playerPosition, 50, MAROON); + + // Draw GUI + for (int i = 0; i < BUTTON_MAX; i++) + { + DrawCircleV(buttonPositions[i], buttonRadius, (i == pressedButton)? DARKGRAY : BLACK); + + DrawText(buttonLabels[i], + (int)buttonPositions[i].x - 7, (int)buttonPositions[i].y - 8, + 20, buttonLabelColors[i]); + } + + DrawText("move the player with D-Pad buttons", 10, 10, 20, DARKGRAY); - DrawRectangleRec((Rectangle) { playerX - 4, playerY - 4, 75, 28 }, RED); - DrawText("Player", (int)playerX, (int)playerY, 20, WHITE); EndDrawing(); - //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- } // De-Initialization diff --git a/examples/core/core_input_virtual_controls.png b/examples/core/core_input_virtual_controls.png index cb1444598017b9d7ff83480f66909c8523ece519..83097a54ca46ebed8c1958e4ed7854cbbd2286a6 100644 GIT binary patch literal 1802 zcmbVMdpJ~E6hC8T@+zP+%e_WKxE0ZxyhfA4(Bm@X?laUM_s_e(Z=d~JzqR&WXRZA^=d7!<{URkTB?y8R z(P`V~I>}7;fhozAKm&ew-QV z54kb}+2MxHcJ8p5p|PQ{Z-v`J5F_ySq_gPsb&vuuh>#YJ2;l&708@J&gExlAIJ}IP z1K1cR2dRP88_d8&f{Z@|FgC^`aL{{D*pKx;Ng?3k$wLGXiEJ=Ia5v^o#WE6a%$;-z zU~I^NbLC`_Zk8JXn%`xNAei?ge?Z#S;6VlZF4MQ6?vbxPy`2eqy&Y=o#aqUjli70k zJvZ=o*ZUylUrj=ku>Q#Vl%XKesr8n#RwN`cal?d7JW3s1 zv9kBm$WC5Ey=r&#=Sou0v7BU>>0C;E^j>hOZaQUj^9;XJ6793{SO~Wc7t=N@?j!fB z9_P&`=G^~7vN-?JYJ zJsg3Xq2}mk6vr*<%)XpgW0s^}e$ktfN{;grvsHZ`zp^dKpe;d#3TgQ@Ym(BNCKNRa zy7R}50QZQp@8c+Q-~vq1*xopYanVrUv1!#j8O(%%VN!TDD)gPp_Pcy)a8{ z;2X7vO|W!kDEAfD$~ajMmM@qbmPaq>(=yF{TdXp%nmS5}k|)jIrz+B`Vd-MM=>i1o}c%RK3;IaIyA~@1uP*%es&= z3j`-H=&w-Mf`x5l$6dVu7OiSyjaip6i#G@WPJxCKZ*dmT( zKQHw3D4^>Xd*XJ*EESg^dC(I~fpG56WL!k1Ho>+p{WkQ+4=RuURUNTXm zpmK}wa}>9Xng4Wk%F4i~p^K*XNk9K3f5kgYs^*mm8>%#8V2q{PId8kY^+4ReKF!R@ literal 9094 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 H{`@}x#HYs# From 93a67417b336a4e0814d37dc37b4591f03b9588c Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Sun, 8 Dec 2024 08:46:43 -0300 Subject: [PATCH 003/793] Fix examples Makefile PLATFORM define (#4582) --- examples/Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index a65a4961e..34cf36f04 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -54,10 +54,15 @@ # Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB PLATFORM ?= PLATFORM_DESKTOP -ifeq ($(PLATFORM), PLATFORM_DESKTOP) - TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW)) + TARGET_PLATFORM := $(PLATFORM) + override PLATFORM = PLATFORM_DESKTOP else - TARGET_PLATFORM = $(PLATFORM) + ifeq ($(PLATFORM), PLATFORM_DESKTOP) + TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW + else + TARGET_PLATFORM = $(PLATFORM) + endif endif # Define required raylib variables @@ -653,7 +658,7 @@ OTHERS = \ ifeq ($(TARGET_PLATFORM), PLATFORM_DESKTOP_GFLW) OTHERS += others/rlgl_standalone endif - + CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST)) From d2cd2a01524ca5b14cfa6d72255e891c76b29bd0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 8 Dec 2024 12:48:54 +0100 Subject: [PATCH 004/793] [rlgl][rmodels] Add instranceTransform shader location index #4538 (#4579) --- .../resources/shaders/glsl330/lighting_instancing.vs | 2 +- examples/shaders/shaders_mesh_instancing.c | 3 +-- src/config.h | 2 ++ src/raylib.h | 3 ++- src/rcore.c | 1 + src/rlgl.h | 7 +++++++ src/rmodels.c | 8 ++++---- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs b/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs index 3e4da1e28..32db8cdd4 100644 --- a/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs +++ b/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs @@ -25,7 +25,7 @@ void main() // Send vertex attributes to fragment shader fragPosition = vec3(instanceTransform*vec4(vertexPosition, 1.0)); fragTexCoord = vertexTexCoord; - //fragColor = vertexColor; + fragColor = vec4(1.0); fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0))); // Calculate final vertex position, note that we multiply mvp by instanceTransform diff --git a/examples/shaders/shaders_mesh_instancing.c b/examples/shaders/shaders_mesh_instancing.c index eb42cb471..1e0bf0696 100644 --- a/examples/shaders/shaders_mesh_instancing.c +++ b/examples/shaders/shaders_mesh_instancing.c @@ -61,7 +61,7 @@ int main(void) { Matrix translation = MatrixTranslate((float)GetRandomValue(-50, 50), (float)GetRandomValue(-50, 50), (float)GetRandomValue(-50, 50)); Vector3 axis = Vector3Normalize((Vector3){ (float)GetRandomValue(0, 360), (float)GetRandomValue(0, 360), (float)GetRandomValue(0, 360) }); - float angle = (float)GetRandomValue(0, 10)*DEG2RAD; + float angle = (float)GetRandomValue(0, 180)*DEG2RAD; Matrix rotation = MatrixRotate(axis, angle); transforms[i] = MatrixMultiply(rotation, translation); @@ -73,7 +73,6 @@ int main(void) // Get shader locations shader.locs[SHADER_LOC_MATRIX_MVP] = GetShaderLocation(shader, "mvp"); shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos"); - shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocationAttrib(shader, "instanceTransform"); // Set shader value: ambient light level int ambientLoc = GetShaderLocation(shader, "ambient"); diff --git a/src/config.h b/src/config.h index d8f7112eb..74e0a1353 100644 --- a/src/config.h +++ b/src/config.h @@ -151,6 +151,8 @@ #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS 7 #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8 #endif +#define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCE_TX 9 + // Default shader vertex attribute names to set location points // NOTE: When a new shader is loaded, the following locations are tried to be set for convenience diff --git a/src/raylib.h b/src/raylib.h index 641bd10e0..73c8cca5d 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -801,7 +801,8 @@ typedef enum { SHADER_LOC_MAP_BRDF, // Shader location: sampler2d texture: brdf SHADER_LOC_VERTEX_BONEIDS, // Shader location: vertex attribute: boneIds SHADER_LOC_VERTEX_BONEWEIGHTS, // Shader location: vertex attribute: boneWeights - SHADER_LOC_BONE_MATRICES // Shader location: array of matrices uniform: boneMatrices + SHADER_LOC_BONE_MATRICES, // Shader location: array of matrices uniform: boneMatrices + SHADER_LOC_VERTEX_INSTANCE_TX // Shader location: vertex attribute: instanceTransform } ShaderLocationIndex; #define SHADER_LOC_MAP_DIFFUSE SHADER_LOC_MAP_ALBEDO diff --git a/src/rcore.c b/src/rcore.c index bcff5acb0..d69fa0f6c 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1346,6 +1346,7 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode) shader.locs[SHADER_LOC_VERTEX_COLOR] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR); shader.locs[SHADER_LOC_VERTEX_BONEIDS] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS); shader.locs[SHADER_LOC_VERTEX_BONEWEIGHTS] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS); + shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] = rlGetLocationAttrib(shader.id, RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCE_TX); // Get handles to GLSL uniform locations (vertex shader) shader.locs[SHADER_LOC_MATRIX_MVP] = rlGetLocationUniform(shader.id, RL_DEFAULT_SHADER_UNIFORM_NAME_MVP); diff --git a/src/rlgl.h b/src/rlgl.h index c08623de3..b09b04b18 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -355,6 +355,9 @@ #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEWEIGHTS 8 #endif #endif +#ifndef RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCE_TX + #define RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCE_TX 9 +#endif //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -998,6 +1001,9 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad #ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS #define RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS "vertexBoneWeights" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_BONEWEIGHTS #endif +#ifndef RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCE_TX + #define RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCE_TX "instanceTransform" // Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCE_TX +#endif #ifndef RL_DEFAULT_SHADER_UNIFORM_NAME_MVP #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix @@ -4216,6 +4222,7 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId) glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR, RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR); glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT); glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2, RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2); + glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_INSTANCE_TX, RL_DEFAULT_SHADER_ATTRIB_NAME_INSTANCE_TX); #ifdef RL_SUPPORT_MESH_GPU_SKINNING glBindAttribLocation(program, RL_DEFAULT_SHADER_ATTRIB_LOCATION_BONEIDS, RL_DEFAULT_SHADER_ATTRIB_NAME_BONEIDS); diff --git a/src/rmodels.c b/src/rmodels.c index 24f4a4fc9..a159d5432 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -1734,12 +1734,12 @@ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, i // no faster, since we're transferring all the transform matrices anyway instancesVboId = rlLoadVertexBuffer(instanceTransforms, instances*sizeof(float16), false); - // Instances transformation matrices are send to shader attribute location: SHADER_LOC_MATRIX_MODEL + // Instances transformation matrices are sent to shader attribute location: SHADER_LOC_VERTEX_INSTANCE_TX for (unsigned int i = 0; i < 4; i++) { - rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i); - rlSetVertexAttribute(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i, 4, RL_FLOAT, 0, sizeof(Matrix), i*sizeof(Vector4)); - rlSetVertexAttributeDivisor(material.shader.locs[SHADER_LOC_MATRIX_MODEL] + i, 1); + rlEnableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i); + rlSetVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i, 4, RL_FLOAT, 0, sizeof(Matrix), i*sizeof(Vector4)); + rlSetVertexAttributeDivisor(material.shader.locs[SHADER_LOC_VERTEX_INSTANCE_TX] + i, 1); } rlDisableVertexBuffer(); From 732da949b72a629fbd6b7e7f9fcab3d88f8355ee Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 8 Dec 2024 11:49:07 +0000 Subject: [PATCH 005/793] Update raylib_api.* by CI --- parser/output/raylib_api.json | 5 +++++ parser/output/raylib_api.lua | 5 +++++ parser/output/raylib_api.txt | 3 ++- parser/output/raylib_api.xml | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index 3eb438392..9614f0cac 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -2543,6 +2543,11 @@ "name": "SHADER_LOC_BONE_MATRICES", "value": 28, "description": "Shader location: array of matrices uniform: boneMatrices" + }, + { + "name": "SHADER_LOC_VERTEX_INSTANCE_TX", + "value": 29, + "description": "Shader location: vertex attribute: instanceTransform" } ] }, diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index da3faf073..00547334e 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -2543,6 +2543,11 @@ return { name = "SHADER_LOC_BONE_MATRICES", value = 28, description = "Shader location: array of matrices uniform: boneMatrices" + }, + { + name = "SHADER_LOC_VERTEX_INSTANCE_TX", + value = 29, + description = "Shader location: vertex attribute: instanceTransform" } } }, diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index 5c7c38701..09dc8cfeb 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -795,7 +795,7 @@ Enum 08: MaterialMapIndex (11 values) Value[MATERIAL_MAP_IRRADIANCE]: 8 Value[MATERIAL_MAP_PREFILTER]: 9 Value[MATERIAL_MAP_BRDF]: 10 -Enum 09: ShaderLocationIndex (29 values) +Enum 09: ShaderLocationIndex (30 values) Name: ShaderLocationIndex Description: Shader location index Value[SHADER_LOC_VERTEX_POSITION]: 0 @@ -827,6 +827,7 @@ Enum 09: ShaderLocationIndex (29 values) Value[SHADER_LOC_VERTEX_BONEIDS]: 26 Value[SHADER_LOC_VERTEX_BONEWEIGHTS]: 27 Value[SHADER_LOC_BONE_MATRICES]: 28 + Value[SHADER_LOC_VERTEX_INSTANCE_TX]: 29 Enum 10: ShaderUniformDataType (9 values) Name: ShaderUniformDataType Description: Shader uniform data type diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index 81cb6a371..9e870437f 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -507,7 +507,7 @@ - + @@ -537,6 +537,7 @@ + From 2a2acff2d5208b443f6303fc18efe8946c35be06 Mon Sep 17 00:00:00 2001 From: Rico P Date: Sun, 8 Dec 2024 12:52:06 +0100 Subject: [PATCH 006/793] Make sure ShaderUniformDataType matches rlShaderUniformDataType (#4577) * Make sure ShaderUniformDataType matches rlShaderUniformDataType * Update raylib_api.* by CI --------- Co-authored-by: github-actions[bot] Co-authored-by: Ray --- parser/output/raylib_api.json | 22 +++++++++++++++++++++- parser/output/raylib_api.lua | 22 +++++++++++++++++++++- parser/output/raylib_api.txt | 9 ++++++--- parser/output/raylib_api.xml | 8 ++++++-- src/raylib.h | 4 ++++ 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index 9614f0cac..e05d8a748 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -2596,8 +2596,28 @@ "description": "Shader uniform type: ivec4 (4 int)" }, { - "name": "SHADER_UNIFORM_SAMPLER2D", + "name": "SHADER_UNIFORM_UINT", "value": 8, + "description": "Shader uniform type: unsigned int" + }, + { + "name": "SHADER_UNIFORM_UIVEC2", + "value": 9, + "description": "Shader uniform type: uivec2 (2 unsigned int)" + }, + { + "name": "SHADER_UNIFORM_UIVEC3", + "value": 10, + "description": "Shader uniform type: uivec3 (3 unsigned int)" + }, + { + "name": "SHADER_UNIFORM_UIVEC4", + "value": 11, + "description": "Shader uniform type: uivec4 (4 unsigned int)" + }, + { + "name": "SHADER_UNIFORM_SAMPLER2D", + "value": 12, "description": "Shader uniform type: sampler2d" } ] diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index 00547334e..d8a848b45 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -2596,8 +2596,28 @@ return { description = "Shader uniform type: ivec4 (4 int)" }, { - name = "SHADER_UNIFORM_SAMPLER2D", + name = "SHADER_UNIFORM_UINT", value = 8, + description = "Shader uniform type: unsigned int" + }, + { + name = "SHADER_UNIFORM_UIVEC2", + value = 9, + description = "Shader uniform type: uivec2 (2 unsigned int)" + }, + { + name = "SHADER_UNIFORM_UIVEC3", + value = 10, + description = "Shader uniform type: uivec3 (3 unsigned int)" + }, + { + name = "SHADER_UNIFORM_UIVEC4", + value = 11, + description = "Shader uniform type: uivec4 (4 unsigned int)" + }, + { + name = "SHADER_UNIFORM_SAMPLER2D", + value = 12, description = "Shader uniform type: sampler2d" } } diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index 09dc8cfeb..d3b6eb895 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -827,8 +827,7 @@ Enum 09: ShaderLocationIndex (30 values) Value[SHADER_LOC_VERTEX_BONEIDS]: 26 Value[SHADER_LOC_VERTEX_BONEWEIGHTS]: 27 Value[SHADER_LOC_BONE_MATRICES]: 28 - Value[SHADER_LOC_VERTEX_INSTANCE_TX]: 29 -Enum 10: ShaderUniformDataType (9 values) +Enum 10: ShaderUniformDataType (13 values) Name: ShaderUniformDataType Description: Shader uniform data type Value[SHADER_UNIFORM_FLOAT]: 0 @@ -839,7 +838,11 @@ Enum 10: ShaderUniformDataType (9 values) Value[SHADER_UNIFORM_IVEC2]: 5 Value[SHADER_UNIFORM_IVEC3]: 6 Value[SHADER_UNIFORM_IVEC4]: 7 - Value[SHADER_UNIFORM_SAMPLER2D]: 8 + Value[SHADER_UNIFORM_UINT]: 8 + Value[SHADER_UNIFORM_UIVEC2]: 9 + Value[SHADER_UNIFORM_UIVEC3]: 10 + Value[SHADER_UNIFORM_UIVEC4]: 11 + Value[SHADER_UNIFORM_SAMPLER2D]: 12 Enum 11: ShaderAttributeDataType (4 values) Name: ShaderAttributeDataType Description: Shader attribute data types diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index 9e870437f..e1b1f35e2 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -539,7 +539,7 @@ - + @@ -548,7 +548,11 @@ - + + + + + diff --git a/src/raylib.h b/src/raylib.h index 73c8cca5d..7482d4392 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -818,6 +818,10 @@ typedef enum { SHADER_UNIFORM_IVEC2, // Shader uniform type: ivec2 (2 int) SHADER_UNIFORM_IVEC3, // Shader uniform type: ivec3 (3 int) SHADER_UNIFORM_IVEC4, // Shader uniform type: ivec4 (4 int) + SHADER_UNIFORM_UINT, // Shader uniform type: unsigned int + SHADER_UNIFORM_UIVEC2, // Shader uniform type: uivec2 (2 unsigned int) + SHADER_UNIFORM_UIVEC3, // Shader uniform type: uivec3 (3 unsigned int) + SHADER_UNIFORM_UIVEC4, // Shader uniform type: uivec4 (4 unsigned int) SHADER_UNIFORM_SAMPLER2D // Shader uniform type: sampler2d } ShaderUniformDataType; From 83f6f3dabeb14b8f5268bf3abdcc898f50cfeb17 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 8 Dec 2024 11:52:21 +0000 Subject: [PATCH 007/793] Update raylib_api.* by CI --- parser/output/raylib_api.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index d3b6eb895..7c7b003c4 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -827,6 +827,7 @@ Enum 09: ShaderLocationIndex (30 values) Value[SHADER_LOC_VERTEX_BONEIDS]: 26 Value[SHADER_LOC_VERTEX_BONEWEIGHTS]: 27 Value[SHADER_LOC_BONE_MATRICES]: 28 + Value[SHADER_LOC_VERTEX_INSTANCE_TX]: 29 Enum 10: ShaderUniformDataType (13 values) Name: ShaderUniformDataType Description: Shader uniform data type From aeb33e6301fd614e1f38aed66ab6b219a824df3c Mon Sep 17 00:00:00 2001 From: Legendary Redfox <128002430+legendaryredfox@users.noreply.github.com> Date: Sun, 8 Dec 2024 11:24:02 -0300 Subject: [PATCH 008/793] Adding my bindings to the list (#4586) * updated raylib-lua version * Updated some bindings * removed 404 bindings * adding my bindings project to the list --- BINDINGS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 873e6af0e..ccba2dd2b 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -42,7 +42,8 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [kaylib](https://github.com/electronstudio/kaylib) | 3.7 | [Kotlin/native](https://kotlinlang.org) | **???** | | [KaylibKit](https://codeberg.org/Kenta/KaylibKit) | 4.5 | [Kotlin/native](https://kotlinlang.org) | Zlib | | [raylib-lua](https://github.com/TSnake41/raylib-lua) | 5.0 | [Lua](http://www.lua.org) | ISC | -| [raylib-matte](https://github.com/jcorks/raylib-matte) | 4.6-dev | [Matte](https://github.com/jcorks/matte) | MIT | +| [raylib-lua-bindings (WIP)](https://github.com/legendaryredfox/raylib-lua-bindings) | 5.5 | [Lua](http://www.lua.org) | ISC | +| [raylib-matte](https://github.com/jcorks/raylib-matte) | 4.6-dev | [Matte](https://github.com/jcorks/matte) | **???** | | [Raylib.nelua](https://github.com/AuzFox/Raylib.nelua) | **5.0** | [nelua](https://nelua.io) | Zlib | | [raylib-bindings](https://github.com/vaiorabbit/raylib-bindings) | 5.6-dev | [Ruby](https://www.ruby-lang.org/en) | Zlib | | [naylib](https://github.com/planetis-m/naylib) | **5.1-dev** | [Nim](https://nim-lang.org) | MIT | From b747eeefa4542cb1737997498991273d7a559d3f Mon Sep 17 00:00:00 2001 From: Legendary Redfox <128002430+legendaryredfox@users.noreply.github.com> Date: Tue, 10 Dec 2024 16:05:46 -0300 Subject: [PATCH 009/793] [documentation] Adding a related project (#4589) * updated raylib-lua version * Updated some bindings * removed 404 bindings * adding my bindings project to the list * Adding a related project * fixing the license foi ReiLua --- BINDINGS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BINDINGS.md b/BINDINGS.md index ccba2dd2b..56c7e79c1 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -43,6 +43,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [KaylibKit](https://codeberg.org/Kenta/KaylibKit) | 4.5 | [Kotlin/native](https://kotlinlang.org) | Zlib | | [raylib-lua](https://github.com/TSnake41/raylib-lua) | 5.0 | [Lua](http://www.lua.org) | ISC | | [raylib-lua-bindings (WIP)](https://github.com/legendaryredfox/raylib-lua-bindings) | 5.5 | [Lua](http://www.lua.org) | ISC | +| [ReiLua](https://github.com/nullstare/ReiLua) | 5.5 | [Lua](http://www.lua.org) | MIT | | [raylib-matte](https://github.com/jcorks/raylib-matte) | 4.6-dev | [Matte](https://github.com/jcorks/matte) | **???** | | [Raylib.nelua](https://github.com/AuzFox/Raylib.nelua) | **5.0** | [nelua](https://nelua.io) | Zlib | | [raylib-bindings](https://github.com/vaiorabbit/raylib-bindings) | 5.6-dev | [Ruby](https://www.ruby-lang.org/en) | Zlib | From 6b220f2798837687599d54c690d65dcc4a6a7161 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 12 Dec 2024 12:13:17 +0100 Subject: [PATCH 010/793] Review formating --- src/platforms/rcore_android.c | 6 +++--- src/platforms/rcore_desktop_rgfw.c | 14 +++++++------- src/platforms/rcore_desktop_sdl.c | 6 +++--- src/platforms/rcore_drm.c | 6 +++--- src/platforms/rcore_web.c | 10 +++++----- src/rcore.c | 2 +- src/rtextures.c | 5 +---- 7 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 47dc5cabc..4528c810d 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -699,7 +699,7 @@ void PollInputEvents(void) // Poll Events (registered events) until we reach TIMEOUT which indicates there are no events left to poll // NOTE: Activity is paused if not enabled (platform.appEnabled) - while ((pollResult = ALooper_pollOnce(platform.appEnabled? 0 : -1, NULL, &pollEvents, (void**)&platform.source)) > ALOOPER_POLL_TIMEOUT) + while ((pollResult = ALooper_pollOnce(platform.appEnabled? 0 : -1, NULL, &pollEvents, ((void **)&platform.source)) > ALOOPER_POLL_TIMEOUT)) { // Process this event if (platform.source != NULL) platform.source->process(platform.app, platform.source); @@ -786,7 +786,7 @@ int InitPlatform(void) while (!CORE.Window.ready) { // Process events until we reach TIMEOUT, which indicates no more events queued. - while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, (void**)&platform.source)) > ALOOPER_POLL_TIMEOUT) + while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, ((void **)&platform.source)) > ALOOPER_POLL_TIMEOUT)) { // Process this event if (platform.source != NULL) platform.source->process(platform.app, platform.source); @@ -1226,7 +1226,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event) return 1; // Handled gamepad button } - KeyboardKey key = (keycode > 0 && keycode < KEYCODE_MAP_SIZE)? mapKeycode[keycode] : KEY_NULL; + KeyboardKey key = ((keycode > 0) && (keycode < KEYCODE_MAP_SIZE))? mapKeycode[keycode] : KEY_NULL; if (key != KEY_NULL) { // Save current key and its state diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 913223511..a6ef60c9e 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -485,7 +485,7 @@ void SetWindowIcons(Image *images, int count) // Set title for window void SetWindowTitle(const char *title) { - RGFW_window_setName(platform.window, (char*)title); + RGFW_window_setName(platform.window, (char *)title); CORE.Window.title = title; } @@ -542,9 +542,9 @@ void SetWindowFocused(void) void *GetWindowHandle(void) { #ifdef RGFW_WEBASM - return (void*)platform.window->src.ctx; + return (void *)platform.window->src.ctx; #else - return (void*)platform.window->src.window; + return (void *)platform.window->src.window; #endif } @@ -587,7 +587,7 @@ Vector2 GetMonitorPosition(int monitor) { RGFW_monitor *mons = RGFW_getMonitors(); - return (Vector2){(float)mons[monitor].rect.x, (float)mons[monitor].rect.y}; + return (Vector2){ (float)mons[monitor].rect.x, (float)mons[monitor].rect.y }; } // Get selected monitor width (currently used by monitor) @@ -609,7 +609,7 @@ int GetMonitorHeight(int monitor) // Get selected monitor physical width in millimetres int GetMonitorPhysicalWidth(int monitor) { - RGFW_monitor* mons = RGFW_getMonitors(); + RGFW_monitor *mons = RGFW_getMonitors(); return (int)mons[monitor].physW; } @@ -654,7 +654,7 @@ Vector2 GetWindowScaleDPI(void) // Set clipboard text content void SetClipboardText(const char *text) { - RGFW_writeClipboard(text, (u32)strlen(text)); + RGFW_writeClipboard(text, strlen(text)); } // Get clipboard text content @@ -1336,7 +1336,7 @@ int InitPlatform(void) // Load OpenGL extensions // NOTE: GL procedures address loader is required to load extensions //---------------------------------------------------------------------------- - rlLoadExtensions((void*)RGFW_getProcAddress); + rlLoadExtensions((void *)RGFW_getProcAddress); //---------------------------------------------------------------------------- // TODO: Initialize input events system diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 99de9af22..d051ae83f 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -68,7 +68,7 @@ #define MAX_CLIPBOARD_BUFFER_LENGTH 1024 // Size of the clipboard buffer used on GetClipboardText() #endif -#if ((defined(SDL_MAJOR_VERSION) && SDL_MAJOR_VERSION == 3) && (defined(SDL_MINOR_VERSION) && SDL_MINOR_VERSION >= 1)) +#if ((defined(SDL_MAJOR_VERSION) && (SDL_MAJOR_VERSION == 3)) && (defined(SDL_MINOR_VERSION) && (SDL_MINOR_VERSION >= 1))) #ifndef PLATFORM_DESKTOP_SDL3 #define PLATFORM_DESKTOP_SDL3 #endif @@ -405,7 +405,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID) // Since SDL2 doesn't have this function we leave a stub // SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3) -void* SDL_GetClipboardData(const char *mime_type, size_t *size) +void *SDL_GetClipboardData(const char *mime_type, size_t *size) { TRACELOG(LOG_WARNING, "Getting clipboard data that is not text is only available in SDL3"); @@ -1971,7 +1971,7 @@ void ClosePlatform(void) // Scancode to keycode mapping static KeyboardKey ConvertScancodeToKey(SDL_Scancode sdlScancode) { - if (sdlScancode >= 0 && sdlScancode < SCANCODE_MAPPED_NUM) + if ((sdlScancode >= 0) && (sdlScancode < SCANCODE_MAPPED_NUM)) { return mapScancodeToKey[sdlScancode]; } diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index e9a236868..425b1d4a6 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -1529,7 +1529,7 @@ static void ConfigureEvdevDevice(char *device) platform.absRange.height = absinfo[ABS_Y].info.maximum - absinfo[ABS_Y].info.minimum; } } - else if (isGamepad && !isMouse && !isKeyboard && platform.gamepadCount < MAX_GAMEPADS) + else if (isGamepad && !isMouse && !isKeyboard && (platform.gamepadCount < MAX_GAMEPADS)) { deviceKindStr = "gamepad"; int index = platform.gamepadCount++; @@ -1893,7 +1893,7 @@ static int FindExactConnectorMode(const drmModeConnector *connector, uint width, TRACELOG(LOG_TRACE, "DISPLAY: DRM Mode %d %ux%u@%u %s", i, mode->hdisplay, mode->vdisplay, mode->vrefresh, (mode->flags & DRM_MODE_FLAG_INTERLACE)? "interlaced" : "progressive"); - if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && (!allowInterlaced)) continue; + if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && !allowInterlaced) continue; if ((mode->hdisplay == width) && (mode->vdisplay == height) && (mode->vrefresh == fps)) return i; } @@ -1923,7 +1923,7 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt continue; } - if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && (!allowInterlaced)) + if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && !allowInterlaced) { TRACELOG(LOG_TRACE, "DISPLAY: DRM shouldn't choose an interlaced mode"); continue; diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index d0be02514..d28ed55c2 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -319,7 +319,7 @@ void ToggleBorderlessWindowed(void) // Set window state: maximized, if resizable void MaximizeWindow(void) { - if (glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE && !(CORE.Window.flags & FLAG_WINDOW_MAXIMIZED)) + if ((glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE) && !(CORE.Window.flags & FLAG_WINDOW_MAXIMIZED)) { platform.unmaximizedWidth = CORE.Window.screen.width; platform.unmaximizedHeight = CORE.Window.screen.height; @@ -342,7 +342,7 @@ void MinimizeWindow(void) // Set window state: not minimized/maximized void RestoreWindow(void) { - if (glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE && (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED)) + if ((glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE) && (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED)) { if (platform.unmaximizedWidth && platform.unmaximizedHeight) glfwSetWindowSize(platform.handle, platform.unmaximizedWidth, platform.unmaximizedHeight); @@ -1664,10 +1664,10 @@ static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent * int height = EM_ASM_INT( return window.innerHeight; ); if (width < (int)CORE.Window.screenMin.width) width = CORE.Window.screenMin.width; - else if (width > (int)CORE.Window.screenMax.width && CORE.Window.screenMax.width > 0) width = CORE.Window.screenMax.width; + else if ((width > (int)CORE.Window.screenMax.width) && (CORE.Window.screenMax.width > 0)) width = CORE.Window.screenMax.width; if (height < (int)CORE.Window.screenMin.height) height = CORE.Window.screenMin.height; - else if (height > (int)CORE.Window.screenMax.height && CORE.Window.screenMax.height > 0) height = CORE.Window.screenMax.height; + else if ((height > (int)CORE.Window.screenMax.height) && (CORE.Window.screenMax.height > 0)) height = CORE.Window.screenMax.height; emscripten_set_canvas_element_size("#canvas", width, height); @@ -1722,7 +1722,7 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE for (int i = 0; i < gamepadEvent->numButtons; ++i) TRACELOGD("Button %d: Digital: %d, Analog: %g", i, gamepadEvent->digitalButton[i], gamepadEvent->analogButton[i]); */ - if ((gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS)) + if (gamepadEvent->connected && (gamepadEvent->index < MAX_GAMEPADS)) { CORE.Input.Gamepad.ready[gamepadEvent->index] = true; sprintf(CORE.Input.Gamepad.name[gamepadEvent->index], "%s", gamepadEvent->id); diff --git a/src/rcore.c b/src/rcore.c index d69fa0f6c..571abf97c 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -2063,7 +2063,7 @@ const char *GetDirectoryPath(const char *filePath) // In case provided path does not contain a root drive letter (C:\, D:\) nor leading path separator (\, /), // we add the current directory path to dirPath - if (filePath[1] != ':' && filePath[0] != '\\' && filePath[0] != '/') + if ((filePath[1] != ':') && (filePath[0] != '\\') && (filePath[0] != '/')) { // For security, we set starting path to current directory, // obtained path will be concatenated to this diff --git a/src/rtextures.c b/src/rtextures.c index 57ee57604..06f81e577 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -833,10 +833,7 @@ Image GenImageGradientLinear(int width, int height, int direction, Color start, // bottom-right or vice-versa), pixel (0, 0) is the farthest point on the gradient // (i.e. the pixel which should become one of the gradient's ends color); while for // directions that lie in the second or fourth quadrant, that point is pixel (width, 0). - float maxPosValue = - ((signbit(sinDir) != 0) == (signbit(cosDir) != 0)) - ? fabsf(startingPos) - : fabsf(startingPos+width*cosDir); + float maxPosValue = ((signbit(sinDir) != 0) == (signbit(cosDir) != 0))? fabsf(startingPos) : fabsf(startingPos + width*cosDir); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) From 1f704be4e4aba6b25e56bde3c30cc136b6e94049 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 12 Dec 2024 12:13:38 +0100 Subject: [PATCH 011/793] Review comments spacing for better alignment --- src/raylib.h | 125 +++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 63 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index 7482d4392..dcaaa44c7 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1155,20 +1155,19 @@ RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int * RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree() RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree() RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree() -RLAPI unsigned int ComputeCRC32(unsigned char *data, int dataSize); // Compute CRC32 hash code -RLAPI unsigned int *ComputeMD5(unsigned char *data, int dataSize); // Compute MD5 hash code, returns static int[4] (16 bytes) -RLAPI unsigned int *ComputeSHA1(unsigned char *data, int dataSize); // Compute SHA1 hash code, returns static int[5] (20 bytes) - +RLAPI unsigned int ComputeCRC32(unsigned char *data, int dataSize); // Compute CRC32 hash code +RLAPI unsigned int *ComputeMD5(unsigned char *data, int dataSize); // Compute MD5 hash code, returns static int[4] (16 bytes) +RLAPI unsigned int *ComputeSHA1(unsigned char *data, int dataSize); // Compute SHA1 hash code, returns static int[5] (20 bytes) // Automation events functionality -RLAPI AutomationEventList LoadAutomationEventList(const char *fileName); // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS -RLAPI void UnloadAutomationEventList(AutomationEventList list); // Unload automation events list from file -RLAPI bool ExportAutomationEventList(AutomationEventList list, const char *fileName); // Export automation events list as text file -RLAPI void SetAutomationEventList(AutomationEventList *list); // Set automation event list to record to -RLAPI void SetAutomationEventBaseFrame(int frame); // Set automation event internal base frame to start recording -RLAPI void StartAutomationEventRecording(void); // Start recording automation events (AutomationEventList must be set) -RLAPI void StopAutomationEventRecording(void); // Stop recording automation events -RLAPI void PlayAutomationEvent(AutomationEvent event); // Play a recorded automation event +RLAPI AutomationEventList LoadAutomationEventList(const char *fileName); // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS +RLAPI void UnloadAutomationEventList(AutomationEventList list); // Unload automation events list from file +RLAPI bool ExportAutomationEventList(AutomationEventList list, const char *fileName); // Export automation events list as text file +RLAPI void SetAutomationEventList(AutomationEventList *list); // Set automation event list to record to +RLAPI void SetAutomationEventBaseFrame(int frame); // Set automation event internal base frame to start recording +RLAPI void StartAutomationEventRecording(void); // Start recording automation events (AutomationEventList must be set) +RLAPI void StopAutomationEventRecording(void); // Stop recording automation events +RLAPI void PlayAutomationEvent(AutomationEvent event); // Play a recorded automation event //------------------------------------------------------------------------------------ // Input Handling Functions (Module: core) @@ -1186,16 +1185,16 @@ RLAPI const char *GetKeyName(int key); // Get name of a Q RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC) // Input-related functions: gamepads -RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available -RLAPI const char *GetGamepadName(int gamepad); // Get gamepad internal name id -RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once -RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed -RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once -RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Check if a gamepad button is NOT being pressed -RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed -RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad -RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis -RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB) +RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available +RLAPI const char *GetGamepadName(int gamepad); // Get gamepad internal name id +RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once +RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed +RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once +RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Check if a gamepad button is NOT being pressed +RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed +RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad +RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis +RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB) RLAPI void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration); // Set gamepad vibration for both motors (duration in seconds) // Input-related functions: mouse @@ -1224,19 +1223,19 @@ RLAPI int GetTouchPointCount(void); // Get number of t //------------------------------------------------------------------------------------ // Gestures and Touch Handling Functions (Module: rgestures) //------------------------------------------------------------------------------------ -RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags -RLAPI bool IsGestureDetected(unsigned int gesture); // Check if a gesture have been detected -RLAPI int GetGestureDetected(void); // Get latest detected gesture -RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in seconds -RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector -RLAPI float GetGestureDragAngle(void); // Get gesture drag angle -RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta -RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle +RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags +RLAPI bool IsGestureDetected(unsigned int gesture); // Check if a gesture have been detected +RLAPI int GetGestureDetected(void); // Get latest detected gesture +RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in seconds +RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector +RLAPI float GetGestureDragAngle(void); // Get gesture drag angle +RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta +RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle //------------------------------------------------------------------------------------ // Camera System Functions (Module: rcamera) //------------------------------------------------------------------------------------ -RLAPI void UpdateCamera(Camera *camera, int mode); // Update camera position for selected mode +RLAPI void UpdateCamera(Camera *camera, int mode); // Update camera position for selected mode RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom); // Update camera movement/rotation //------------------------------------------------------------------------------------ @@ -1245,9 +1244,9 @@ RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, f // Set texture and rectangle to be used on shapes drawing // NOTE: It can be useful when using basic shapes and one single font, // defining a font char white rectangle would allow drawing everything in a single draw call -RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Set texture and rectangle to be used on shapes drawing -RLAPI Texture2D GetShapesTexture(void); // Get texture that is used for shapes drawing -RLAPI Rectangle GetShapesTextureRectangle(void); // Get texture source rectangle that is used for shapes drawing +RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Set texture and rectangle to be used on shapes drawing +RLAPI Texture2D GetShapesTexture(void); // Get texture that is used for shapes drawing +RLAPI Rectangle GetShapesTextureRectangle(void); // Get texture source rectangle that is used for shapes drawing // Basic shapes drawing functions RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel using geometry [Can be slow, use with care] @@ -1289,11 +1288,11 @@ RLAPI void DrawPolyLines(Vector2 center, int sides, float radius, float rotation RLAPI void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color); // Draw a polygon outline of n sides with extended parameters // Splines drawing functions -RLAPI void DrawSplineLinear(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Linear, minimum 2 points -RLAPI void DrawSplineBasis(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: B-Spline, minimum 4 points -RLAPI void DrawSplineCatmullRom(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Catmull-Rom, minimum 4 points -RLAPI void DrawSplineBezierQuadratic(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...] -RLAPI void DrawSplineBezierCubic(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...] +RLAPI void DrawSplineLinear(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Linear, minimum 2 points +RLAPI void DrawSplineBasis(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: B-Spline, minimum 4 points +RLAPI void DrawSplineCatmullRom(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Catmull-Rom, minimum 4 points +RLAPI void DrawSplineBezierQuadratic(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...] +RLAPI void DrawSplineBezierCubic(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...] RLAPI void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color); // Draw spline segment: Linear, 2 points RLAPI void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: B-Spline, 4 points RLAPI void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: Catmull-Rom, 4 points @@ -1492,15 +1491,15 @@ RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint); RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found // Text codepoints management functions (unicode characters) -RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array -RLAPI void UnloadUTF8(char *text); // Unload UTF-8 text encoded from codepoints array -RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter -RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory -RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string -RLAPI int GetCodepoint(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure -RLAPI int GetCodepointNext(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure -RLAPI int GetCodepointPrevious(const char *text, int *codepointSize); // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure -RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size); // Encode one codepoint into UTF-8 byte array (array length returned as parameter) +RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array +RLAPI void UnloadUTF8(char *text); // Unload UTF-8 text encoded from codepoints array +RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter +RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory +RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string +RLAPI int GetCodepoint(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure +RLAPI int GetCodepointNext(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure +RLAPI int GetCodepointPrevious(const char *text, int *codepointSize); // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure +RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size); // Encode one codepoint into UTF-8 byte array (array length returned as parameter) // Text strings management functions (no UTF-8 strings, only byte chars) // NOTE: Some strings allocate memory internally for returned strings, just be careful! @@ -1515,14 +1514,14 @@ RLAPI const char *TextJoin(const char **textList, int count, const char *delimit RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor! RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string -RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string -RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string -RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string -RLAPI const char *TextToSnake(const char *text); // Get Snake case notation version of provided string -RLAPI const char *TextToCamel(const char *text); // Get Camel case notation version of provided string +RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string +RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string +RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string +RLAPI const char *TextToSnake(const char *text); // Get Snake case notation version of provided string +RLAPI const char *TextToCamel(const char *text); // Get Camel case notation version of provided string -RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported) -RLAPI float TextToFloat(const char *text); // Get float value from text (negative values not supported) +RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported) +RLAPI float TextToFloat(const char *text); // Get float value from text (negative values not supported) //------------------------------------------------------------------------------------ // Basic 3d Shapes Drawing Functions (Module: models) @@ -1615,14 +1614,14 @@ RLAPI void UnloadModelAnimations(ModelAnimation *animations, int animCount); RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match // Collision detection functions -RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres -RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes -RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere -RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere -RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box -RLAPI RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh -RLAPI RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle -RLAPI RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad +RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres +RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes +RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere +RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere +RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box +RLAPI RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh +RLAPI RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle +RLAPI RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad //------------------------------------------------------------------------------------ // Audio Loading and Playing Functions (Module: audio) From 8a5a95c13a899564b98483f356d51a3024586870 Mon Sep 17 00:00:00 2001 From: __hexmaster111 Date: Fri, 13 Dec 2024 02:21:13 -0600 Subject: [PATCH 012/793] Removed inaccurate comment about negitves not being supported with TextToFloat And TextToInt Methods (#4596) --- src/raylib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index dcaaa44c7..7e1a1f838 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1520,8 +1520,8 @@ RLAPI const char *TextToPascal(const char *text); RLAPI const char *TextToSnake(const char *text); // Get Snake case notation version of provided string RLAPI const char *TextToCamel(const char *text); // Get Camel case notation version of provided string -RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported) -RLAPI float TextToFloat(const char *text); // Get float value from text (negative values not supported) +RLAPI int TextToInteger(const char *text); // Get integer value from text +RLAPI float TextToFloat(const char *text); // Get float value from text //------------------------------------------------------------------------------------ // Basic 3d Shapes Drawing Functions (Module: models) From 0a26d9a26f1ddd734ee844bc6730dc91aad4c1c3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Dec 2024 08:21:27 +0000 Subject: [PATCH 013/793] Update raylib_api.* by CI --- parser/output/raylib_api.json | 4 ++-- parser/output/raylib_api.lua | 4 ++-- parser/output/raylib_api.txt | 4 ++-- parser/output/raylib_api.xml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index e05d8a748..853f591d4 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -9801,7 +9801,7 @@ }, { "name": "TextToInteger", - "description": "Get integer value from text (negative values not supported)", + "description": "Get integer value from text", "returnType": "int", "params": [ { @@ -9812,7 +9812,7 @@ }, { "name": "TextToFloat", - "description": "Get float value from text (negative values not supported)", + "description": "Get float value from text", "returnType": "float", "params": [ { diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index d8a848b45..2983456f3 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -6969,7 +6969,7 @@ return { }, { name = "TextToInteger", - description = "Get integer value from text (negative values not supported)", + description = "Get integer value from text", returnType = "int", params = { {type = "const char *", name = "text"} @@ -6977,7 +6977,7 @@ return { }, { name = "TextToFloat", - description = "Get float value from text (negative values not supported)", + description = "Get float value from text", returnType = "float", params = { {type = "const char *", name = "text"} diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index 7c7b003c4..038b43e17 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -3757,12 +3757,12 @@ Function 438: TextToCamel() (1 input parameters) Function 439: TextToInteger() (1 input parameters) Name: TextToInteger Return type: int - Description: Get integer value from text (negative values not supported) + Description: Get integer value from text Param[1]: text (type: const char *) Function 440: TextToFloat() (1 input parameters) Name: TextToFloat Return type: float - Description: Get float value from text (negative values not supported) + Description: Get float value from text Param[1]: text (type: const char *) Function 441: DrawLine3D() (3 input parameters) Name: DrawLine3D diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index e1b1f35e2..734f96465 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -2487,10 +2487,10 @@ - + - + From 93a1e75741175b9a2136593064b3714e79a363e2 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Fri, 13 Dec 2024 00:21:45 -0800 Subject: [PATCH 014/793] Disable the threading example in MSVC for release and debug build (was disabled for dll builds already) (#4594) --- projects/VS2022/raylib.sln | 4 ---- 1 file changed, 4 deletions(-) diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln index 5142c14a1..feb0f2c35 100644 --- a/projects/VS2022/raylib.sln +++ b/projects/VS2022/raylib.sln @@ -693,16 +693,12 @@ Global {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x64.ActiveCfg = Debug|x64 - {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x64.Build.0 = Debug|x64 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x86.ActiveCfg = Debug|Win32 - {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x86.Build.0 = Debug|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x86.Build.0 = Release.DLL|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x64.ActiveCfg = Release|x64 - {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x64.Build.0 = Release|x64 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x86.ActiveCfg = Release|Win32 - {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x86.Build.0 = Release|Win32 {6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 {6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 {6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 From d0504800d2c5a5e722a65a9023ddadca17f930bc Mon Sep 17 00:00:00 2001 From: Per Hallsmark Date: Sun, 15 Dec 2024 11:16:08 +0100 Subject: [PATCH 015/793] install rcamera.h (#4603) Signed-off-by: Per Hallsmark --- build.zig | 1 + src/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/build.zig b/build.zig index 866e70034..66e8fab4f 100644 --- a/build.zig +++ b/build.zig @@ -401,6 +401,7 @@ pub fn build(b: *std.Build) !void { const lib = try compileRaylib(b, target, optimize, Options.getOptions(b)); lib.installHeader(b.path("src/raylib.h"), "raylib.h"); + lib.installHeader(b.path("src/rcamera.h"), "rcamera.h"); lib.installHeader(b.path("src/raymath.h"), "raymath.h"); lib.installHeader(b.path("src/rlgl.h"), "rlgl.h"); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9735e267f..a7313a0b4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,7 @@ endif() # Used as public API to be included into other projects set(raylib_public_headers raylib.h + rcamera.h rlgl.h raymath.h ) From 79facde3535af1f35942eec38f02f2851de618ab Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Mon, 16 Dec 2024 00:51:42 +0100 Subject: [PATCH 016/793] fix `rlActiveDrawBuffers` for OpenGL ES 3 (#4605) --- src/rlgl.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/rlgl.h b/src/rlgl.h index b09b04b18..857e97511 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1890,16 +1890,6 @@ void rlActiveDrawBuffers(int count) else { unsigned int buffers[8] = { -#if defined(GRAPHICS_API_OPENGL_ES3) - GL_COLOR_ATTACHMENT0_EXT, - GL_COLOR_ATTACHMENT1_EXT, - GL_COLOR_ATTACHMENT2_EXT, - GL_COLOR_ATTACHMENT3_EXT, - GL_COLOR_ATTACHMENT4_EXT, - GL_COLOR_ATTACHMENT5_EXT, - GL_COLOR_ATTACHMENT6_EXT, - GL_COLOR_ATTACHMENT7_EXT, -#else GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, @@ -1908,14 +1898,9 @@ void rlActiveDrawBuffers(int count) GL_COLOR_ATTACHMENT5, GL_COLOR_ATTACHMENT6, GL_COLOR_ATTACHMENT7, -#endif }; -#if defined(GRAPHICS_API_OPENGL_ES3) - glDrawBuffersEXT(count, buffers); -#else glDrawBuffers(count, buffers); -#endif } } else TRACELOG(LOG_WARNING, "GL: One color buffer active by default"); From bdfbd6e8cc77b755d6552f90028ba8262d79ab92 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Mon, 16 Dec 2024 18:19:00 -0300 Subject: [PATCH 017/793] Fix maximizing, minimizing and restoring windows for SDL2 (#4607) --- src/platforms/rcore_desktop_sdl.c | 48 +++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index d051ae83f..de93a1f5e 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -497,20 +497,21 @@ void ToggleBorderlessWindowed(void) void MaximizeWindow(void) { SDL_MaximizeWindow(platform.window); - CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED; + if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED; } // Set window state: minimized void MinimizeWindow(void) { SDL_MinimizeWindow(platform.window); - CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; + if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; } // Set window state: not minimized/maximized void RestoreWindow(void) { - SDL_ShowWindow(platform.window); + SDL_RestoreWindow(platform.window); + // CORE.Window.flags will be removed on PollInputEvents() } // Set window configuration state using flags @@ -1448,6 +1449,22 @@ void PollInputEvents(void) CORE.Window.currentFbo.width = width; CORE.Window.currentFbo.height = height; CORE.Window.resizedLastFrame = true; + + #ifndef PLATFORM_DESKTOP_SDL3 + // Manually detect if the window was maximized (due to SDL2 restore being unreliable on some platforms) to remove the FLAG_WINDOW_MAXIMIZED accordingly + if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0) + { + int borderTop = 0; + int borderLeft = 0; + int borderBottom = 0; + int borderRight = 0; + SDL_GetWindowBordersSize(platform.window, &borderTop, &borderLeft, &borderBottom, &borderRight); + SDL_Rect usableBounds; + SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(platform.window), &usableBounds); + + if ((width + borderLeft + borderRight != usableBounds.w) && (height + borderTop + borderBottom != usableBounds.h)) CORE.Window.flags &= ~FLAG_WINDOW_MAXIMIZED; + } + #endif } break; case SDL_WINDOWEVENT_ENTER: { @@ -1457,13 +1474,32 @@ void PollInputEvents(void) { CORE.Input.Mouse.cursorOnScreen = false; } break; - case SDL_WINDOWEVENT_HIDDEN: case SDL_WINDOWEVENT_MINIMIZED: + { + if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; + } break; + case SDL_WINDOWEVENT_MAXIMIZED: + { + if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED; + } break; + case SDL_WINDOWEVENT_RESTORED: + { + if ((SDL_GetWindowFlags(platform.window) & SDL_WINDOW_MINIMIZED) == 0) + { + if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; + } + + #ifdef PLATFORM_DESKTOP_SDL3 + if ((SDL_GetWindowFlags(platform.window) & SDL_WINDOW_MAXIMIZED) == 0) + { + if ((CORE.Window.flags & SDL_WINDOW_MAXIMIZED) > 0) CORE.Window.flags &= ~SDL_WINDOW_MAXIMIZED; + } + #endif + } break; + case SDL_WINDOWEVENT_HIDDEN: case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_SHOWN: case SDL_WINDOWEVENT_FOCUS_GAINED: - case SDL_WINDOWEVENT_MAXIMIZED: - case SDL_WINDOWEVENT_RESTORED: #if defined(PLATFORM_DESKTOP_SDL3) break; #else From 714cd5ef5c88a878aaa77e835e0260ed0b1d6d0b Mon Sep 17 00:00:00 2001 From: JupiterRider <60042618+JupiterRider@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:38:11 +0100 Subject: [PATCH 018/793] add SetGamepadVibration to rgfw and template (#4612) --- src/platforms/rcore_desktop_rgfw.c | 6 ++++++ src/platforms/rcore_template.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index a6ef60c9e..3cf005f25 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -780,6 +780,12 @@ int SetGamepadMappings(const char *mappings) return 0; } +// Set gamepad vibration +void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration) +{ + TRACELOG(LOG_WARNING, "GamepadSetVibration() not available on target platform"); +} + // Set mouse position XY void SetMousePosition(int x, int y) { diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 891c4ab34..9eca9726a 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -381,6 +381,12 @@ int SetGamepadMappings(const char *mappings) return 0; } +// Set gamepad vibration +void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration) +{ + TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform"); +} + // Set mouse position XY void SetMousePosition(int x, int y) { From cdaff163cb8f2d0bb23e993be51190f4c07fb1b8 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Wed, 18 Dec 2024 07:39:30 -0300 Subject: [PATCH 019/793] Fix show, hide, focus and unfocus window/flags states for SDL2 (#4610) --- src/platforms/rcore_desktop_sdl.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index de93a1f5e..b7f00bc76 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -1427,7 +1427,7 @@ void PollInputEvents(void) // Window events are also polled (Minimized, maximized, close...) - #ifndef PLATFORM_DESKTOP_SDL3 + #ifndef PLATFORM_DESKTOP_SDL3 // SDL3 states: // The SDL_WINDOWEVENT_* events have been moved to top level events, // and SDL_WINDOWEVENT has been removed. @@ -1437,7 +1437,7 @@ void PollInputEvents(void) { switch (event.window.event) { - #endif + #endif case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_SIZE_CHANGED: { @@ -1466,6 +1466,7 @@ void PollInputEvents(void) } #endif } break; + case SDL_WINDOWEVENT_ENTER: { CORE.Input.Mouse.cursorOnScreen = true; @@ -1474,6 +1475,7 @@ void PollInputEvents(void) { CORE.Input.Mouse.cursorOnScreen = false; } break; + case SDL_WINDOWEVENT_MINIMIZED: { if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; @@ -1496,13 +1498,26 @@ void PollInputEvents(void) } #endif } break; + case SDL_WINDOWEVENT_HIDDEN: - case SDL_WINDOWEVENT_FOCUS_LOST: + { + if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) == 0) CORE.Window.flags |= FLAG_WINDOW_HIDDEN; + } break; case SDL_WINDOWEVENT_SHOWN: + { + if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN; + } break; + case SDL_WINDOWEVENT_FOCUS_GAINED: - #if defined(PLATFORM_DESKTOP_SDL3) - break; - #else + { + if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED; + } break; + case SDL_WINDOWEVENT_FOCUS_LOST: + { + if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0) CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED; + } break; + + #ifndef PLATFORM_DESKTOP_SDL3 default: break; } } break; From 35c24084130f14397ab252b91f115a8fedfd9b7b Mon Sep 17 00:00:00 2001 From: Kirandeep-Singh-Khehra <107160937+Kirandeep-Singh-Khehra@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:09:50 +0530 Subject: [PATCH 020/793] [rmodels] Optimized `UpdateModelAnimationBones()` function (#4602) - Updating bones only once instead for each mesh. - Updating only one `model.meshes[].boneMatrices` and then using deep copy for other meshes instead of calculating for each bone in each mesh. **Other points:** - Makes it a clean base/template/reference for bone updation functions. Because if using this as template then some calculations done in one mesh can affect bones in other mesh in next iteration(doubles the effect in for next mesh). Signed-off-by: Kirandeep-Singh-Khehra --- src/rmodels.c | 66 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/src/rmodels.c b/src/rmodels.c index a159d5432..cf799aa58 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -2270,38 +2270,62 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) { if (frame >= anim.frameCount) frame = frame%anim.frameCount; + // Get first mesh which have bones + int firstMeshWithBones = -1; + for (int i = 0; i < model.meshCount; i++) { if (model.meshes[i].boneMatrices) { assert(model.meshes[i].boneCount == anim.boneCount); - - for (int boneId = 0; boneId < model.meshes[i].boneCount; boneId++) + if (firstMeshWithBones == -1) { - Vector3 inTranslation = model.bindPose[boneId].translation; - Quaternion inRotation = model.bindPose[boneId].rotation; - Vector3 inScale = model.bindPose[boneId].scale; + firstMeshWithBones = i; + } + } + } - Vector3 outTranslation = anim.framePoses[frame][boneId].translation; - Quaternion outRotation = anim.framePoses[frame][boneId].rotation; - Vector3 outScale = anim.framePoses[frame][boneId].scale; + // Update all bones and boneMatrices of first mesh with bones. + for (int boneId = 0; boneId < anim.boneCount; boneId++) + { + Vector3 inTranslation = model.bindPose[boneId].translation; + Quaternion inRotation = model.bindPose[boneId].rotation; + Vector3 inScale = model.bindPose[boneId].scale; - Vector3 invTranslation = Vector3RotateByQuaternion(Vector3Negate(inTranslation), QuaternionInvert(inRotation)); - Quaternion invRotation = QuaternionInvert(inRotation); - Vector3 invScale = Vector3Divide((Vector3){ 1.0f, 1.0f, 1.0f }, inScale); + Vector3 outTranslation = anim.framePoses[frame][boneId].translation; + Quaternion outRotation = anim.framePoses[frame][boneId].rotation; + Vector3 outScale = anim.framePoses[frame][boneId].scale; - Vector3 boneTranslation = Vector3Add( - Vector3RotateByQuaternion(Vector3Multiply(outScale, invTranslation), - outRotation), outTranslation); - Quaternion boneRotation = QuaternionMultiply(outRotation, invRotation); - Vector3 boneScale = Vector3Multiply(outScale, invScale); + Vector3 invTranslation = Vector3RotateByQuaternion(Vector3Negate(inTranslation), QuaternionInvert(inRotation)); + Quaternion invRotation = QuaternionInvert(inRotation); + Vector3 invScale = Vector3Divide((Vector3){ 1.0f, 1.0f, 1.0f }, inScale); - Matrix boneMatrix = MatrixMultiply(MatrixMultiply( - QuaternionToMatrix(boneRotation), - MatrixTranslate(boneTranslation.x, boneTranslation.y, boneTranslation.z)), - MatrixScale(boneScale.x, boneScale.y, boneScale.z)); + Vector3 boneTranslation = Vector3Add( + Vector3RotateByQuaternion(Vector3Multiply(outScale, invTranslation), + outRotation), outTranslation); + Quaternion boneRotation = QuaternionMultiply(outRotation, invRotation); + Vector3 boneScale = Vector3Multiply(outScale, invScale); - model.meshes[i].boneMatrices[boneId] = boneMatrix; + Matrix boneMatrix = MatrixMultiply(MatrixMultiply( + QuaternionToMatrix(boneRotation), + MatrixTranslate(boneTranslation.x, boneTranslation.y, boneTranslation.z)), + MatrixScale(boneScale.x, boneScale.y, boneScale.z)); + + model.meshes[firstMeshWithBones].boneMatrices[boneId] = boneMatrix; + } + + // Update remaining meshes with bones (Use Deep copy because shallow copy results in double free with 'UnloadModel()') + if (firstMeshWithBones != -1) + { + for (int i = firstMeshWithBones + 1; i < model.meshCount; i++) + { + if (model.meshes[i].boneMatrices) + { + memcpy( + model.meshes[i].boneMatrices, + model.meshes[firstMeshWithBones].boneMatrices, + model.meshes[i].boneCount * sizeof(model.meshes[i].boneMatrices[0]) + ); } } } From f76734fc5059a58d6026d17ff0da985d8a228d5b Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Dec 2024 11:43:43 +0100 Subject: [PATCH 021/793] REVIEWED: `UpdateModelAnimationBones()`, break on first mesh found and formating --- src/rmodels.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rmodels.c b/src/rmodels.c index cf799aa58..43997c318 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -2281,6 +2281,7 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) if (firstMeshWithBones == -1) { firstMeshWithBones = i; + break; } } } @@ -2314,18 +2315,17 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) model.meshes[firstMeshWithBones].boneMatrices[boneId] = boneMatrix; } - // Update remaining meshes with bones (Use Deep copy because shallow copy results in double free with 'UnloadModel()') + // Update remaining meshes with bones + // NOTE: Using deep copy because shallow copy results in double free with 'UnloadModel()' if (firstMeshWithBones != -1) { for (int i = firstMeshWithBones + 1; i < model.meshCount; i++) { if (model.meshes[i].boneMatrices) { - memcpy( - model.meshes[i].boneMatrices, + memcpy(model.meshes[i].boneMatrices, model.meshes[firstMeshWithBones].boneMatrices, - model.meshes[i].boneCount * sizeof(model.meshes[i].boneMatrices[0]) - ); + model.meshes[i].boneCount * sizeof(model.meshes[i].boneMatrices[0])); } } } @@ -2338,6 +2338,7 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) { UpdateModelAnimationBones(model,anim,frame); + for (int m = 0; m < model.meshCount; m++) { Mesh mesh = model.meshes[m]; @@ -2346,8 +2347,9 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) int boneId = 0; int boneCounter = 0; float boneWeight = 0.0; - bool updated = false; // Flag to check when anim vertex information is updated + bool updated = false; // Flag to check when anim vertex information is updated const int vValues = mesh.vertexCount*3; + for (int vCounter = 0; vCounter < vValues; vCounter += 3) { mesh.animVertices[vCounter] = 0; From de6c09ee7aab56adb625eb6d2611f7e974af7c47 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Dec 2024 11:45:55 +0100 Subject: [PATCH 022/793] WARNING: REVIEWED: Use `libraylib.web.a` naming on PLATFORM_WEB This change allows to have in same directory (currently `raylib/src`) two raylib build versions: Desktop and Web --- examples/Makefile | 2 +- examples/Makefile.Web | 2 +- src/Makefile | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 34cf36f04..57a772229 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -482,7 +482,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) endif ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a + LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a endif # Define source code object files required diff --git a/examples/Makefile.Web b/examples/Makefile.Web index dd5dc6881..92bcfa229 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -365,7 +365,7 @@ ifeq ($(PLATFORM),PLATFORM_DRM) endif ifeq ($(PLATFORM),PLATFORM_WEB) # Libraries for web (HTML5) compiling - LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a + LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a endif # Define source code object files required diff --git a/src/Makefile b/src/Makefile index 7dde52fbd..1e3ddb791 100644 --- a/src/Makefile +++ b/src/Makefile @@ -662,8 +662,8 @@ raylib: $(OBJS) ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) # Compile raylib libray for web #$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc - $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS) - @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).a)!" + $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(OBJS) + @echo "raylib library generated (lib$(RAYLIB_LIB_NAME).web.a)!" else ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW)) From 58004723d8c0b4fe211b3a20815a9a1f8f20b601 Mon Sep 17 00:00:00 2001 From: Colleague Riley Date: Wed, 18 Dec 2024 03:03:42 -0800 Subject: [PATCH 023/793] [rcore][RGFW] Add new backend option: `PLATFORM_WEB_RGFW` and update RGFW (#4480) * add PLATFORM_WEB_RGFW * fix some bugs * fix web_rgfw gamepad * send fake screensize * fix gamepad bugs (linux) | add L3 + R3 (gamepad) * fix? * update RGFW (again) * update raylib (merge) * fix xinput stuff * delete makefile added by mistake * update RGFW * update RGFW (rename joystick to gamepad to avoid misunderstandings * update RGFW (fix X11 bug) * update RGFW * use RL_MALLOC for RGFW * update RGFW (fixes xdnd bug) * fix some formating --- examples/Makefile | 37 +- examples/Makefile.Web | 25 +- src/Makefile | 20 +- src/external/RGFW.h | 1630 +++++++++++++++------------- src/platforms/rcore_desktop_rgfw.c | 279 ++--- src/rcore.c | 17 +- 6 files changed, 1049 insertions(+), 959 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 57a772229..c02cad434 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -20,6 +20,8 @@ # - Linux (X11 desktop mode) # - macOS/OSX (x64, arm64 (not tested)) # - Others (not tested) +# > PLATFORM_WEB_RGFW: +# - HTML5 (WebAssembly) # > PLATFORM_WEB: # - HTML5 (WebAssembly) # > PLATFORM_DRM: @@ -51,7 +53,7 @@ # Define required environment variables #------------------------------------------------------------------------------------------------ -# Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB +# Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB, PLATFORM_WEB_RGFW PLATFORM ?= PLATFORM_DESKTOP ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW)) @@ -107,7 +109,7 @@ BUILD_WEB_RESOURCES ?= TRUE BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources # Determine PLATFORM_OS when required -ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB)) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW)) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! # ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) @@ -158,7 +160,7 @@ endif # Define raylib release directory for compiled library RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(PLATFORM_OS),WINDOWS) # Emscripten required variables EMSDK_PATH ?= C:/raylib/emsdk @@ -184,8 +186,8 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) CC = clang endif endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) - # HTML5 emscripten compiler +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) + # HTML5 emscripten compiler # WARNING: To compile to HTML5, code must be redesigned # to use emscripten.h and emscripten_set_main_loop() CC = emcc @@ -203,7 +205,7 @@ endif ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) MAKE = mingw32-make endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(OS),Windows_NT) MAKE = mingw32-make else @@ -231,11 +233,11 @@ CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result ifeq ($(BUILD_MODE),DEBUG) CFLAGS += -g -D_DEBUG - ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) + ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) CFLAGS += -sASSERTIONS=1 --profiling endif -else - ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +else + ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) CFLAGS += -O3 else @@ -325,7 +327,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL) endif LDFLAGS += -L$(SDL_LIBRARY_PATH) endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 # -sUSE_GLFW=3 # Use glfw3 library (context/input management) @@ -341,9 +343,14 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation # --source-map-base # allow debugging in browser with source map - LDFLAGS += -sUSE_GLFW=3 -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 - # Build using asyncify + ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) + LDFLAGS += -sUSE_GLFW=3 + endif + + LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1 + + # Build using asyncify ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) LDFLAGS += -sASYNCIFY endif @@ -480,7 +487,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) # NOTE: Required packages: libasound2-dev (ALSA) LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # Libraries for web (HTML5) compiling LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a endif @@ -681,7 +688,7 @@ others: $(OTHERS) %: %.c ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) $(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$< -else ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +else ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) $(MAKE) -f Makefile.Web $@ else $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -D$(TARGET_PLATFORM) @@ -710,7 +717,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) find . -type f -executable -delete rm -fv *.o endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(PLATFORM_OS),WINDOWS) del *.wasm *.html *.js *.data else diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 92bcfa229..a4470e09f 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -65,7 +65,7 @@ BUILD_WEB_HEAP_SIZE ?= 134217728 USE_WEBGL2 ?= FALSE # Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected -ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB)) +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB PLATFORM_WEB_RGFW)) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! # ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) @@ -116,7 +116,7 @@ endif # Define raylib release directory for compiled library RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src -ifeq ($(PLATFORM),PLATFORM_WEB) +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(PLATFORM_OS),WINDOWS) # Emscripten required variables EMSDK_PATH ?= C:/raylib/emsdk @@ -142,7 +142,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) CC = clang endif endif -ifeq ($(PLATFORM),PLATFORM_WEB) +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # HTML5 emscripten compiler # WARNING: To compile to HTML5, code must be redesigned # to use emscripten.h and emscripten_set_main_loop() @@ -161,7 +161,7 @@ endif ifeq ($(PLATFORM),PLATFORM_ANDROID) MAKE = mingw32-make endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(OS),Windows_NT) MAKE = mingw32-make else @@ -189,11 +189,11 @@ CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result ifeq ($(BUILD_MODE),DEBUG) CFLAGS += -g -D_DEBUG - ifeq ($(PLATFORM),PLATFORM_WEB) + ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) CFLAGS += -sASSERTIONS=1 --profiling endif else - ifeq ($(PLATFORM),PLATFORM_WEB) + ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) CFLAGS += -O3 else @@ -263,7 +263,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH) endif endif -ifeq ($(PLATFORM),PLATFORM_WEB) +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 # -sUSE_GLFW=3 # Use glfw3 library (context/input management) @@ -279,7 +279,12 @@ ifeq ($(PLATFORM),PLATFORM_WEB) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation # --source-map-base # allow debugging in browser with source map - LDFLAGS += -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall + + ifeq ($(PLATFORM),PLATFORM_WEB) + LDFLAGS += -sUSE_GLFW=3 + endif + + LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall # Build using asyncify ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) @@ -363,7 +368,7 @@ ifeq ($(PLATFORM),PLATFORM_DRM) # NOTE: Required packages: libasound2-dev (ALSA) LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic endif -ifeq ($(PLATFORM),PLATFORM_WEB) +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # Libraries for web (HTML5) compiling LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a endif @@ -1225,7 +1230,7 @@ ifeq ($(PLATFORM),PLATFORM_DRM) find . -type f -executable -delete rm -fv *.o endif -ifeq ($(PLATFORM),PLATFORM_WEB) +ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) del *.o *.html *.js endif @echo Cleaning done diff --git a/src/Makefile b/src/Makefile index 1e3ddb791..4797b587f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,6 +20,8 @@ # - Linux (X11 desktop mode) # - macOS/OSX (x64, arm64 (not tested)) # - Others (not tested) +# > PLATFORM_WEB_RGFW: +# - HTML5 (WebAssembly) # > PLATFORM_WEB: # - HTML5 (WebAssembly) # > PLATFORM_DRM: @@ -130,7 +132,7 @@ HOST_PLATFORM_OS ?= WINDOWS PLATFORM_OS ?= WINDOWS # Determine PLATFORM_OS when required -ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_ANDROID)) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW PLATFORM_ANDROID)) # No uname.exe on MinGW!, but OS=Windows_NT on Windows! # ifeq ($(UNAME),Msys) -> Windows ifeq ($(OS),Windows_NT) @@ -172,7 +174,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) PLATFORM_SHELL = sh endif endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(PLATFORM_OS),LINUX) ifndef PLATFORM_SHELL PLATFORM_SHELL = sh @@ -180,7 +182,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) endif endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) ifeq ($(PLATFORM_OS), WINDOWS) # Emscripten required variables EMSDK_PATH ?= C:/raylib/emsdk @@ -254,7 +256,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) # On DRM OpenGL ES 2.0 must be used GRAPHICS = GRAPHICS_API_OPENGL_ES2 endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 GRAPHICS = GRAPHICS_API_OPENGL_ES2 #GRAPHICS = GRAPHICS_API_OPENGL_ES3 @@ -288,7 +290,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM) AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar endif endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # HTML5 emscripten compiler CC = emcc AR = emar @@ -331,7 +333,7 @@ ifneq ($(RAYLIB_CONFIG_FLAGS), NONE) CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS) endif -ifeq ($(TARGET_PLATFORM), PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # NOTE: When using multi-threading in the user code, it requires -pthread enabled CFLAGS += -std=gnu99 else @@ -347,7 +349,7 @@ ifeq ($(RAYLIB_BUILD_MODE),DEBUG) endif ifeq ($(RAYLIB_BUILD_MODE),RELEASE) - ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) + ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) CFLAGS += -Os endif ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) @@ -366,7 +368,7 @@ endif ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) CFLAGS += -Werror=implicit-function-declaration endif -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 # -sUSE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker! @@ -659,7 +661,7 @@ all: raylib # Compile raylib library # NOTE: Release directory is created if not exist raylib: $(OBJS) -ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) +ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # Compile raylib libray for web #$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc $(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(OBJS) diff --git a/src/external/RGFW.h b/src/external/RGFW.h index 978536f2d..2a10eda2c 100644 --- a/src/external/RGFW.h +++ b/src/external/RGFW.h @@ -59,9 +59,72 @@ #define RGFW_EXPORT - Use when building RGFW #define RGFW_IMPORT - Use when linking with RGFW (not as a single-header) - #define RGFW_STD_INT - force the use stdint.h (for systems that might not have stdint.h (msvc)) + #define RGFW_USE_INT - force the use c-types rather than stdint.h (for systems that might not have stdint.h (msvc)) */ +/* +Example to get you started : + +linux : gcc main.c -lX11 -lXrandr -lGL +windows : gcc main.c -lopengl32 -lwinmm -lshell32 -lgdi32 +macos : gcc main.c -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo + +#define RGFW_IMPLEMENTATION +#include "RGFW.h" + +u8 icon[4 * 3 * 3] = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF}; + +int main() { + RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(500, 500, 500, 500), (u64)0); + + RGFW_window_setIcon(win, icon, RGFW_AREA(3, 3), 4); + + for (;;) { + RGFW_window_checkEvent(win); // NOTE: checking events outside of a while loop may cause input lag + if (win->event.type == RGFW_quit || RGFW_isPressed(win, RGFW_Escape)) + break; + + RGFW_window_swapBuffers(win); + + glClearColor(0xFF, 0XFF, 0xFF, 0xFF); + glClear(GL_COLOR_BUFFER_BIT); + } + + RGFW_window_close(win); +} + + compiling : + + if you wish to compile the library all you have to do is create a new file with this in it + + rgfw.c + #define RGFW_IMPLEMENTATION + #include "RGFW.h" + + You may also want to add + `#define RGFW_EXPORT` when compiling and + `#define RGFW_IMPORT`when linking RGFW on it's own: + this reduces inline functions and prevents bloat in the object file + + then you can use gcc (or whatever compile you wish to use) to compile the library into object file + + ex. gcc -c RGFW.c -fPIC + + after you compile the library into an object file, you can also turn the object file into an static or shared library + + (commands ar and gcc can be replaced with whatever equivalent your system uses) + static : ar rcs RGFW.a RGFW.o + shared : + windows: + gcc -shared RGFW.o -lwinmm -lopengl32 -lshell32 -lgdi32 -o RGFW.dll + linux: + gcc -shared RGFW.o -lX11 -lGL -lXrandr -o RGFW.so + macos: + gcc -shared RGFW.o -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo +*/ + + + /* Credits : EimaMei/Sacode : Much of the code for creating windows using winapi, Wrote the Silicon library, helped with MacOS Support, siliapp.h -> referencing @@ -88,6 +151,7 @@ Joshua Rowe (omnisci3nce) - bug fix, review (macOS) @lesleyrs -> bug fix, review (OpenGL) Nick Porcino (meshula) - testing, organization, review (MacOS, examples) + @DarekParodia -> code review (X11) (C++) */ #if _MSC_VER @@ -168,15 +232,15 @@ #define RGFW_HEADER #if !defined(u8) - #if ((defined(_MSC_VER) || defined(__SYMBIAN32__)) && !defined(RGFW_STD_INT)) /* MSVC might not have stdint.h */ + #ifdef RGFW_USE_INT /* optional for any system that might not have stdint.h */ typedef unsigned char u8; typedef signed char i8; typedef unsigned short u16; typedef signed short i16; - typedef unsigned int u32; - typedef signed int i32; - typedef unsigned long u64; - typedef signed long i64; + typedef unsigned long int u32; + typedef signed long int i32; + typedef unsigned long long u64; + typedef signed long long i64; #else /* use stdint standard types instead of c ""standard"" types */ #include @@ -344,12 +408,12 @@ typedef RGFW_ENUM(u8, RGFW_event_types) { RGFW_Event.button holds which mouse button was pressed */ - RGFW_jsButtonPressed, /*!< a joystick button was pressed */ - RGFW_jsButtonReleased, /*!< a joystick button was released */ - RGFW_jsAxisMove, /*!< an axis of a joystick was moved*/ - /*! joystick event note - RGFW_Event.joystick holds which joystick was altered, if any - RGFW_Event.button holds which joystick button was pressed + RGFW_gpButtonPressed, /*!< a gamepad button was pressed */ + RGFW_gpButtonReleased, /*!< a gamepad button was released */ + RGFW_gpAxisMove, /*!< an axis of a gamepad was moved*/ + /*! gamepad event note + RGFW_Event.gamepad holds which gamepad was altered, if any + RGFW_Event.button holds which gamepad button was pressed RGFW_Event.axis holds the data of all the axis RGFW_Event.axisCount says how many axis there are @@ -398,24 +462,26 @@ typedef RGFW_ENUM(u8, RGFW_event_types) { #define RGFW_CAPSLOCK (1L << 1) #define RGFW_NUMLOCK (1L << 2) -/*! joystick button codes (based on xbox/playstation), you may need to change these values per controller */ -#ifndef RGFW_joystick_codes - typedef RGFW_ENUM(u8, RGFW_joystick_codes) { - RGFW_JS_A = 0, /*!< or PS X button */ - RGFW_JS_B = 1, /*!< or PS circle button */ - RGFW_JS_Y = 2, /*!< or PS triangle button */ - RGFW_JS_X = 3, /*!< or PS square button */ - RGFW_JS_START = 9, /*!< start button */ - RGFW_JS_SELECT = 8, /*!< select button */ - RGFW_JS_HOME = 10, /*!< home button */ - RGFW_JS_UP = 13, /*!< dpad up */ - RGFW_JS_DOWN = 14, /*!< dpad down*/ - RGFW_JS_LEFT = 15, /*!< dpad left */ - RGFW_JS_RIGHT = 16, /*!< dpad right */ - RGFW_JS_L1 = 4, /*!< left bump */ - RGFW_JS_L2 = 5, /*!< left trigger*/ - RGFW_JS_R1 = 6, /*!< right bumper */ - RGFW_JS_R2 = 7, /*!< right trigger */ +/*! gamepad button codes (based on xbox/playstation), you may need to change these values per controller */ +#ifndef RGFW_gamepad_codes + typedef RGFW_ENUM(u8, RGFW_gamepad_codes) { + RGFW_GP_A = 0, /*!< or PS X button */ + RGFW_GP_B = 1, /*!< or PS circle button */ + RGFW_GP_Y = 2, /*!< or PS triangle button */ + RGFW_GP_X = 3, /*!< or PS square button */ + RGFW_GP_START = 9, /*!< start button */ + RGFW_GP_SELECT = 8, /*!< select button */ + RGFW_GP_HOME = 10, /*!< home button */ + RGFW_GP_UP = 13, /*!< dpad up */ + RGFW_GP_DOWN = 14, /*!< dpad down*/ + RGFW_GP_LEFT = 15, /*!< dpad left */ + RGFW_GP_RIGHT = 16, /*!< dpad right */ + RGFW_GP_L1 = 4, /*!< left bump */ + RGFW_GP_L2 = 5, /*!< left trigger*/ + RGFW_GP_R1 = 6, /*!< right bumper */ + RGFW_GP_R2 = 7, /*!< right trigger */ + RGFW_GP_L3 = 11, /* left thumb stick */ + RGFW_GP_R3 = 12 /*!< right thumb stick */ }; #endif @@ -450,7 +516,7 @@ typedef RGFW_ENUM(u8, RGFW_event_types) { char name[128]; /*!< monitor name */ RGFW_rect rect; /*!< monitor Workarea */ float scaleX, scaleY; /*!< monitor content scale*/ - float physW, physH; /*!< monitor physical size */ + float physW, physH; /*!< monitor physical size in inches*/ } RGFW_monitor; /* @@ -487,12 +553,14 @@ typedef struct RGFW_Event { u8 lockState; - u8 button; /* !< which mouse button was pressed */ + u8 button; /* !< which mouse (or gamepad) button was pressed */ double scroll; /*!< the raw mouse scroll value */ - u16 joystick; /*! which joystick this event applies to (if applicable to any) */ + u16 gamepad; /*! which gamepad this event applies to (if applicable to any) */ u8 axisesCount; /*!< number of axises */ - RGFW_point axis[2]; /*!< x, y of axises (-100 to 100) */ + + u8 whichAxis; /* which axis was effected */ + RGFW_point axis[4]; /*!< x, y of axises (-100 to 100) */ u64 frameTime, frameTime2; /*!< this is used for counting the fps */ } RGFW_Event; @@ -630,6 +698,8 @@ RGFWDEF void RGFW_setClassName(char* name); /*! this has to be set before createWindow is called, else the fulscreen size is used */ RGFWDEF void RGFW_setBufferSize(RGFW_area size); /*!< the buffer cannot be resized (by RGFW) */ +/* NOTE: (windows)If the executable has an icon resource named RGFW_ICON, it will be set as the initial icon for the window.*/ + RGFWDEF RGFW_window* RGFW_createWindow( const char* name, /* name of the window */ RGFW_rect rect, /* rect of window */ @@ -869,10 +939,10 @@ typedef void (* RGFW_windowrefreshfunc)(RGFW_window* win); typedef void (* RGFW_keyfunc)(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed); /*! RGFW_mouseButtonPressed / RGFW_mouseButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */ typedef void (* RGFW_mousebuttonfunc)(RGFW_window* win, u8 button, double scroll, b8 pressed); -/*! RGFW_jsButtonPressed / RGFW_jsButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */ -typedef void (* RGFW_jsButtonfunc)(RGFW_window* win, u16 joystick, u8 button, b8 pressed); -/*! RGFW_jsAxisMove, the window that got the event, the joystick in question, the axis values and the amount of axises */ -typedef void (* RGFW_jsAxisfunc)(RGFW_window* win, u16 joystick, RGFW_point axis[2], u8 axisesCount); +/*!gp /gp, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */ +typedef void (* RGFW_gpButtonfunc)(RGFW_window* win, u16 gamepad, u8 button, b8 pressed); +/*! RGFW_gpAxisMove, the window that got the event, the gamepad in question, the axis values and the amount of axises */ +typedef void (* RGFW_gpAxisfunc)(RGFW_window* win, u16 gamepad, RGFW_point axis[2], u8 axisesCount); /*! RGFW_dnd, the window that had the drop, the drop data and the amount files dropped returns previous callback function (if it was set) */ @@ -904,9 +974,9 @@ RGFWDEF RGFW_keyfunc RGFW_setKeyCallback(RGFW_keyfunc func); /*! set callback for a mouse button (press / release ) event returns previous callback function (if it was set) */ RGFWDEF RGFW_mousebuttonfunc RGFW_setMouseButtonCallback(RGFW_mousebuttonfunc func); /*! set callback for a controller button (press / release ) event returns previous callback function (if it was set) */ -RGFWDEF RGFW_jsButtonfunc RGFW_setjsButtonCallback(RGFW_jsButtonfunc func); -/*! set callback for a joystick axis mov event returns previous callback function (if it was set) */ -RGFWDEF RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func); +RGFWDEF RGFW_gpButtonfunc RGFW_setgpButtonCallback(RGFW_gpButtonfunc func); +/*! set callback for a gamepad axis mov event returns previous callback function (if it was set) */ +RGFWDEF RGFW_gpAxisfunc RGFW_setgpAxisCallback(RGFW_gpAxisfunc func); /** @} */ @@ -937,15 +1007,15 @@ RGFWDEF RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func); /** @} */ -/** * @defgroup joystick +/** * @defgroup gamepad * @{ */ -/*! joystick count starts at 0*/ -/*!< register joystick to window based on a number (the number is based on when it was connected eg. /dev/js0)*/ -RGFWDEF u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber); -RGFWDEF u16 RGFW_registerJoystickF(RGFW_window* win, char* file); +/*! gamepad count starts at 0*/ +/*!< register gamepad to window based on a number (the number is based on when it was connected eg. /dev/js0)*/ +RGFWDEF u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber); +RGFWDEF u16 RGFW_registerGamepadF(RGFW_window* win, char* file); -RGFWDEF u32 RGFW_isPressedJS(RGFW_window* win, u16 controller, u8 button); +RGFWDEF u32 RGFW_isPressedGP(RGFW_window* win, u16 controller, u8 button); /** @} */ @@ -1144,63 +1214,6 @@ typedef RGFW_ENUM(u8, RGFW_mouseIcons) { /** @} */ #endif /* RGFW_HEADER */ - -/* -Example to get you started : - -linux : gcc main.c -lX11 -lXcursor -lGL -windows : gcc main.c -lopengl32 -lshell32 -lgdi32 -macos : gcc main.c -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo - -#define RGFW_IMPLEMENTATION -#include "RGFW.h" - -u8 icon[4 * 3 * 3] = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF}; - -int main() { - RGFW_window* win = RGFW_createWindow("name", RGFW_RECT(500, 500, 500, 500), (u64)0); - - RGFW_window_setIcon(win, icon, RGFW_AREA(3, 3), 4); - - for (;;) { - RGFW_window_checkEvent(win); // NOTE: checking events outside of a while loop may cause input lag - if (win->event.type == RGFW_quit || RGFW_isPressed(win, RGFW_Escape)) - break; - - RGFW_window_swapBuffers(win); - - glClearColor(0xFF, 0XFF, 0xFF, 0xFF); - glClear(GL_COLOR_BUFFER_BIT); - } - - RGFW_window_close(win); -} - - compiling : - - if you wish to compile the library all you have to do is create a new file with this in it - - rgfw.c - #define RGFW_IMPLEMENTATION - #include "RGFW.h" - - then you can use gcc (or whatever compile you wish to use) to compile the library into object file - - ex. gcc -c RGFW.c -fPIC - - after you compile the library into an object file, you can also turn the object file into an static or shared library - - (commands ar and gcc can be replaced with whatever equivalent your system uses) - static : ar rcs RGFW.a RGFW.o - shared : - windows: - gcc -shared RGFW.o -lwinmm -lopengl32 -lshell32 -lgdi32 -o RGFW.dll - linux: - gcc -shared RGFW.o -lX11 -lXcursor -lGL -lXrandr -o RGFW.so - macos: - gcc -shared RGFW.o -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo -*/ - #ifdef RGFW_X11 #define RGFW_OS_BASED_VALUE(l, w, m, h, ww) l #elif defined(RGFW_WINDOWS) @@ -1442,11 +1455,11 @@ char RGFW_keyCodeToCharAuto(u32 keycode, u8 lockState) { return RGFW_keyCodeToCh this is the end of keycode data */ -/* joystick data */ -u8 RGFW_jsPressed[4][16]; /*!< if a key is currently pressed or not (per joystick) */ +/* gamepad data */ +u8 RGFW_gpPressed[4][16]; /*!< if a key is currently pressed or not (per gamepad) */ -i32 RGFW_joysticks[4]; /*!< limit of 4 joysticks at a time */ -u16 RGFW_joystickCount; /*!< the actual amount of joysticks */ +i32 RGFW_gamepads[4]; /*!< limit of 4 gamepads at a time */ +u16 RGFW_gamepadCount; /*!< the actual amount of gamepads */ /* event callback defines start here @@ -1468,8 +1481,8 @@ void RGFW_dndInitfuncEMPTY(RGFW_window* win, RGFW_point point) {RGFW_UNUSED(win) void RGFW_windowrefreshfuncEMPTY(RGFW_window* win) {RGFW_UNUSED(win); } void RGFW_keyfuncEMPTY(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(keycode); RGFW_UNUSED(keyName); RGFW_UNUSED(lockState); RGFW_UNUSED(pressed);} void RGFW_mousebuttonfuncEMPTY(RGFW_window* win, u8 button, double scroll, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(button); RGFW_UNUSED(scroll); RGFW_UNUSED(pressed);} -void RGFW_jsButtonfuncEMPTY(RGFW_window* win, u16 joystick, u8 button, b8 pressed){RGFW_UNUSED(win); RGFW_UNUSED(joystick); RGFW_UNUSED(button); RGFW_UNUSED(pressed); } -void RGFW_jsAxisfuncEMPTY(RGFW_window* win, u16 joystick, RGFW_point axis[2], u8 axisesCount){RGFW_UNUSED(win); RGFW_UNUSED(joystick); RGFW_UNUSED(axis); RGFW_UNUSED(axisesCount); } +void RGFW_gpButtonfuncEMPTY(RGFW_window* win, u16 gamepad, u8 button, b8 pressed){RGFW_UNUSED(win); RGFW_UNUSED(gamepad); RGFW_UNUSED(button); RGFW_UNUSED(pressed); } +void RGFW_gpAxisfuncEMPTY(RGFW_window* win, u16 gamepad, RGFW_point axis[2], u8 axisesCount){RGFW_UNUSED(win); RGFW_UNUSED(gamepad); RGFW_UNUSED(axis); RGFW_UNUSED(axisesCount); } #ifdef RGFW_ALLOC_DROPFILES void RGFW_dndfuncEMPTY(RGFW_window* win, char** droppedFiles, u32 droppedFilesCount) {RGFW_UNUSED(win); RGFW_UNUSED(droppedFiles); RGFW_UNUSED(droppedFilesCount);} @@ -1488,8 +1501,8 @@ RGFW_dndfunc RGFW_dndCallback = RGFW_dndfuncEMPTY; RGFW_dndInitfunc RGFW_dndInitCallback = RGFW_dndInitfuncEMPTY; RGFW_keyfunc RGFW_keyCallback = RGFW_keyfuncEMPTY; RGFW_mousebuttonfunc RGFW_mouseButtonCallback = RGFW_mousebuttonfuncEMPTY; -RGFW_jsButtonfunc RGFW_jsButtonCallback = RGFW_jsButtonfuncEMPTY; -RGFW_jsAxisfunc RGFW_jsAxisCallback = RGFW_jsAxisfuncEMPTY; +RGFW_gpButtonfunc RGFW_gpButtonCallback = RGFW_gpButtonfuncEMPTY; +RGFW_gpAxisfunc RGFW_gpAxisCallback = RGFW_gpAxisfuncEMPTY; void RGFW_window_checkEvents(RGFW_window* win, i32 waitMS) { RGFW_window_eventWait(win, waitMS); @@ -1560,14 +1573,14 @@ RGFW_mousebuttonfunc RGFW_setMouseButtonCallback(RGFW_mousebuttonfunc func) { RGFW_mouseButtonCallback = func; return prev; } -RGFW_jsButtonfunc RGFW_setjsButtonCallback(RGFW_jsButtonfunc func) { - RGFW_jsButtonfunc prev = (RGFW_jsButtonCallback == RGFW_jsButtonfuncEMPTY) ? NULL : RGFW_jsButtonCallback; - RGFW_jsButtonCallback = func; +RGFW_gpButtonfunc RGFW_setgpButtonCallback(RGFW_gpButtonfunc func) { + RGFW_gpButtonfunc prev = (RGFW_gpButtonCallback == RGFW_gpButtonfuncEMPTY) ? NULL : RGFW_gpButtonCallback; + RGFW_gpButtonCallback = func; return prev; } -RGFW_jsAxisfunc RGFW_setjsAxisCallback(RGFW_jsAxisfunc func) { - RGFW_jsAxisfunc prev = (RGFW_jsAxisCallback == RGFW_jsAxisfuncEMPTY) ? NULL : RGFW_jsAxisCallback; - RGFW_jsAxisCallback = func; +RGFW_gpAxisfunc RGFW_setgpAxisCallback(RGFW_gpAxisfunc func) { + RGFW_gpAxisfunc prev = (RGFW_gpAxisCallback == RGFW_gpAxisfuncEMPTY) ? NULL : RGFW_gpAxisCallback; + RGFW_gpAxisCallback = func; return prev; } /* @@ -1629,7 +1642,7 @@ RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) { win->r = rect; win->event.inFocus = 1; win->event.droppedFilesCount = 0; - RGFW_joystickCount = 0; + RGFW_gamepadCount = 0; win->_winArgs = 0; win->event.lockState = 0; @@ -1640,7 +1653,7 @@ RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) { void RGFW_window_scaleToMonitor(RGFW_window* win) { RGFW_monitor monitor = RGFW_window_getMonitor(win); - RGFW_window_resize(win, RGFW_AREA((u32)(monitor.scaleX * (float)win->r.w), (u32)(monitor.scaleX * (float)win->r.h))); + RGFW_window_resize(win, RGFW_AREA((u32)(monitor.scaleX * (float)win->r.w), (u32)(monitor.scaleY * (float)win->r.h))); } #endif @@ -1808,9 +1821,9 @@ u32 RGFW_window_checkFPS(RGFW_window* win, u32 fpsCap) { return output_fps; } -u32 RGFW_isPressedJS(RGFW_window* win, u16 c, u8 button) { +u32 RGFW_isPressedGP(RGFW_window* win, u16 c, u8 button) { RGFW_UNUSED(win); - return RGFW_jsPressed[c][button]; + return RGFW_gpPressed[c][button]; } #if defined(RGFW_X11) || defined(RGFW_WINDOWS) @@ -2261,48 +2274,56 @@ This is where OS specific stuff starts #if defined(RGFW_WAYLAND) || defined(RGFW_X11) int RGFW_eventWait_forceStop[] = {0, 0, 0}; /* for wait events */ + + #ifdef __linux__ #include #include #include - - RGFW_Event* RGFW_linux_updateJoystick(RGFW_window* win) { - static int xAxis = 0, yAxis = 0; + + RGFW_Event* RGFW_linux_updateGamepad(RGFW_window* win) { u8 i; - for (i = 0; i < RGFW_joystickCount; i++) { + for (i = 0; i < RGFW_gamepadCount; i++) { struct js_event e; - if (RGFW_joysticks[i] == 0) + if (RGFW_gamepads[i] == 0) continue; - i32 flags = fcntl(RGFW_joysticks[i], F_GETFL, 0); - fcntl(RGFW_joysticks[i], F_SETFL, flags | O_NONBLOCK); + i32 flags = fcntl(RGFW_gamepads[i], F_GETFL, 0); + fcntl(RGFW_gamepads[i], F_SETFL, flags | O_NONBLOCK); ssize_t bytes; - while ((bytes = read(RGFW_joysticks[i], &e, sizeof(e))) > 0) { + while ((bytes = read(RGFW_gamepads[i], &e, sizeof(e))) > 0) { switch (e.type) { case JS_EVENT_BUTTON: - win->event.type = e.value ? RGFW_jsButtonPressed : RGFW_jsButtonReleased; + win->event.type = e.value ? RGFW_gpButtonPressed : RGFW_gpButtonReleased; win->event.button = e.number; - RGFW_jsPressed[i][e.number] = e.value; - RGFW_jsButtonCallback(win, i, e.number, e.value); + RGFW_gpPressed[i][e.number + 1] = e.value; + RGFW_gpButtonCallback(win, i, e.number, e.value); + return &win->event; - case JS_EVENT_AXIS: - ioctl(RGFW_joysticks[i], JSIOCGAXES, &win->event.axisesCount); + case JS_EVENT_AXIS: { + size_t axis = e.number / 2; + if (axis == 2) axis = 1; - if ((e.number == 0 || e.number % 2) && e.number != 1) - xAxis = e.value; - else - yAxis = e.value; + ioctl(RGFW_gamepads[i], JSIOCGAXES, &win->event.axisesCount); + win->event.axisesCount = 2; + + if (axis < 3) { + if (e.number == 0 || e.number == 3) + win->event.axis[axis].x = (e.value / 32767.0f) * 100; + else if (e.number == 1 || e.number == 4) { + win->event.axis[axis].y = (e.value / 32767.0f) * 100; + } + } - win->event.axis[e.number / 2].x = xAxis; - win->event.axis[e.number / 2].y = yAxis; - win->event.type = RGFW_jsAxisMove; - win->event.joystick = i; - RGFW_jsAxisCallback(win, i, win->event.axis, win->event.axisesCount); + win->event.type = RGFW_gpAxisMove; + win->event.gamepad = i; + win->event.whichAxis = axis; + RGFW_gpAxisCallback(win, i, win->event.axis, win->event.axisesCount); return &win->event; - + } default: break; } } @@ -2647,580 +2668,594 @@ Start of Linux / Unix defines } if (args & RGFW_NO_RESIZE) { /* make it so the user can't resize the window*/ - XSizeHints* sh = XAllocSizeHints(); - sh->flags = (1L << 4) | (1L << 5); - sh->min_width = sh->max_width = win->r.w; - sh->min_height = sh->max_height = win->r.h; + XSizeHints sh = {0}; + sh.flags = (1L << 4) | (1L << 5); + sh.min_width = sh.max_width = win->r.w; + sh.min_height = sh.max_height = win->r.h; - XSetWMSizeHints((Display*) win->src.display, (Drawable) win->src.window, sh, XA_WM_NORMAL_HINTS); - XFree(sh); + XSetWMSizeHints((Display*) win->src.display, (Drawable) win->src.window, &sh, XA_WM_NORMAL_HINTS); + + win->_winArgs |= RGFW_NO_RESIZE; } - if (args & RGFW_NO_BORDER) { - RGFW_window_setBorder(win, 0); - } + if (args & RGFW_NO_BORDER) { + RGFW_window_setBorder(win, 0); + } - XSelectInput((Display*) win->src.display, (Drawable) win->src.window, event_mask); /*!< tell X11 what events we want*/ + XSelectInput((Display*) win->src.display, (Drawable) win->src.window, event_mask); /*!< tell X11 what events we want*/ - /* make it so the user can't close the window until the program does*/ - if (wm_delete_window == 0) - wm_delete_window = XInternAtom((Display*) win->src.display, "WM_DELETE_WINDOW", False); + /* make it so the user can't close the window until the program does*/ + if (wm_delete_window == 0) + wm_delete_window = XInternAtom((Display*) win->src.display, "WM_DELETE_WINDOW", False); - XSetWMProtocols((Display*) win->src.display, (Drawable) win->src.window, &wm_delete_window, 1); + XSetWMProtocols((Display*) win->src.display, (Drawable) win->src.window, &wm_delete_window, 1); - /* connect the context to the window*/ + /* connect the context to the window*/ #ifdef RGFW_OPENGL - if ((args & RGFW_NO_INIT_API) == 0) - glXMakeCurrent((Display*) win->src.display, (Drawable) win->src.window, (GLXContext) win->src.ctx); + if ((args & RGFW_NO_INIT_API) == 0) + glXMakeCurrent((Display*) win->src.display, (Drawable) win->src.window, (GLXContext) win->src.ctx); #endif - /* set the background*/ - XStoreName((Display*) win->src.display, (Drawable) win->src.window, name); /*!< set the name*/ + /* set the background*/ + XStoreName((Display*) win->src.display, (Drawable) win->src.window, name); /*!< set the name*/ - XMapWindow((Display*) win->src.display, (Drawable) win->src.window); /* draw the window*/ - XMoveWindow((Display*) win->src.display, (Drawable) win->src.window, win->r.x, win->r.y); /*!< move the window to it's proper cords*/ + XMapWindow((Display*) win->src.display, (Drawable) win->src.window); /* draw the window*/ + XMoveWindow((Display*) win->src.display, (Drawable) win->src.window, win->r.x, win->r.y); /*!< move the window to it's proper cords*/ - if (args & RGFW_ALLOW_DND) { /* init drag and drop atoms and turn on drag and drop for this window */ - win->_winArgs |= RGFW_ALLOW_DND; + if (args & RGFW_ALLOW_DND) { /* init drag and drop atoms and turn on drag and drop for this window */ + win->_winArgs |= RGFW_ALLOW_DND; - XdndTypeList = XInternAtom((Display*) win->src.display, "XdndTypeList", False); - XdndSelection = XInternAtom((Display*) win->src.display, "XdndSelection", False); + XdndTypeList = XInternAtom((Display*) win->src.display, "XdndTypeList", False); + XdndSelection = XInternAtom((Display*) win->src.display, "XdndSelection", False); - /* client messages */ - XdndEnter = XInternAtom((Display*) win->src.display, "XdndEnter", False); - XdndPosition = XInternAtom((Display*) win->src.display, "XdndPosition", False); - XdndStatus = XInternAtom((Display*) win->src.display, "XdndStatus", False); - XdndLeave = XInternAtom((Display*) win->src.display, "XdndLeave", False); - XdndDrop = XInternAtom((Display*) win->src.display, "XdndDrop", False); - XdndFinished = XInternAtom((Display*) win->src.display, "XdndFinished", False); + /* client messages */ + XdndEnter = XInternAtom((Display*) win->src.display, "XdndEnter", False); + XdndPosition = XInternAtom((Display*) win->src.display, "XdndPosition", False); + XdndStatus = XInternAtom((Display*) win->src.display, "XdndStatus", False); + XdndLeave = XInternAtom((Display*) win->src.display, "XdndLeave", False); + XdndDrop = XInternAtom((Display*) win->src.display, "XdndDrop", False); + XdndFinished = XInternAtom((Display*) win->src.display, "XdndFinished", False); - /* actions */ - XdndActionCopy = XInternAtom((Display*) win->src.display, "XdndActionCopy", False); + /* actions */ + XdndActionCopy = XInternAtom((Display*) win->src.display, "XdndActionCopy", False); - XtextUriList = XInternAtom((Display*) win->src.display, "text/uri-list", False); - XtextPlain = XInternAtom((Display*) win->src.display, "text/plain", False); + XtextUriList = XInternAtom((Display*) win->src.display, "text/uri-list", False); + XtextPlain = XInternAtom((Display*) win->src.display, "text/plain", False); - XdndAware = XInternAtom((Display*) win->src.display, "XdndAware", False); - const u8 version = 5; + XdndAware = XInternAtom((Display*) win->src.display, "XdndAware", False); + const u8 version = 5; - XChangeProperty((Display*) win->src.display, (Window) win->src.window, - XdndAware, 4, 32, - PropModeReplace, &version, 1); /*!< turns on drag and drop */ + XChangeProperty((Display*) win->src.display, (Window) win->src.window, + XdndAware, 4, 32, + PropModeReplace, &version, 1); /*!< turns on drag and drop */ + } + + #ifdef RGFW_EGL + if ((args & RGFW_NO_INIT_API) == 0) + RGFW_createOpenGLContext(win); + #endif + + RGFW_window_setMouseDefault(win); + + RGFW_windowsOpen++; + + return win; /*return newly created window*/ } - #ifdef RGFW_EGL - if ((args & RGFW_NO_INIT_API) == 0) - RGFW_createOpenGLContext(win); - #endif + RGFW_area RGFW_getScreenSize(void) { + assert(RGFW_root != NULL); - RGFW_window_setMouseDefault(win); - - RGFW_windowsOpen++; - - return win; /*return newly created window*/ - } - - RGFW_area RGFW_getScreenSize(void) { - assert(RGFW_root != NULL); - - Screen* scrn = DefaultScreenOfDisplay((Display*) RGFW_root->src.display); - return RGFW_AREA(scrn->width, scrn->height); - } - - RGFW_point RGFW_getGlobalMousePoint(void) { - assert(RGFW_root != NULL); - - RGFW_point RGFWMouse; - - i32 x, y; - u32 z; - Window window1, window2; - XQueryPointer((Display*) RGFW_root->src.display, XDefaultRootWindow((Display*) RGFW_root->src.display), &window1, &window2, &RGFWMouse.x, &RGFWMouse.y, &x, &y, &z); - - return RGFWMouse; - } - - RGFW_point RGFW_window_getMousePoint(RGFW_window* win) { - assert(win != NULL); - - RGFW_point RGFWMouse; - - i32 x, y; - u32 z; - Window window1, window2; - XQueryPointer((Display*) win->src.display, win->src.window, &window1, &window2, &x, &y, &RGFWMouse.x, &RGFWMouse.y, &z); - - return RGFWMouse; - } - - int xAxis = 0, yAxis = 0; - - RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { - assert(win != NULL); - - static struct { - long source, version; - i32 format; - } xdnd; - - if (win->event.type == 0) - RGFW_resetKey(); - - if (win->event.type == RGFW_quit) { - return NULL; + Screen* scrn = DefaultScreenOfDisplay((Display*) RGFW_root->src.display); + return RGFW_AREA(scrn->width, scrn->height); } - win->event.type = 0; + RGFW_point RGFW_getGlobalMousePoint(void) { + assert(RGFW_root != NULL); + + RGFW_point RGFWMouse; + + i32 x, y; + u32 z; + Window window1, window2; + XQueryPointer((Display*) RGFW_root->src.display, XDefaultRootWindow((Display*) RGFW_root->src.display), &window1, &window2, &RGFWMouse.x, &RGFWMouse.y, &x, &y, &z); + + return RGFWMouse; + } + + RGFW_point RGFW_window_getMousePoint(RGFW_window* win) { + assert(win != NULL); + + RGFW_point RGFWMouse; + + i32 x, y; + u32 z; + Window window1, window2; + XQueryPointer((Display*) win->src.display, win->src.window, &window1, &window2, &x, &y, &RGFWMouse.x, &RGFWMouse.y, &z); + + return RGFWMouse; + } + + int xAxis = 0, yAxis = 0; + + RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { + assert(win != NULL); + + static struct { + long source, version; + i32 format; + } xdnd; + + if (win->event.type == 0) + RGFW_resetKey(); + + if (win->event.type == RGFW_quit) { + return NULL; + } + + win->event.type = 0; #ifdef __linux__ - RGFW_Event* event = RGFW_linux_updateJoystick(win); - if (event != NULL) - return event; + RGFW_Event* event = RGFW_linux_updateGamepad(win); + if (event != NULL) + return event; #endif - XPending(win->src.display); + XPending(win->src.display); - XEvent E; /*!< raw X11 event */ + XEvent E; /*!< raw X11 event */ - /* if there is no unread qued events, get a new one */ - if ((QLength(win->src.display) || XEventsQueued((Display*) win->src.display, QueuedAlready) + XEventsQueued((Display*) win->src.display, QueuedAfterReading)) - && win->event.type != RGFW_quit - ) - XNextEvent((Display*) win->src.display, &E); - else { - return NULL; - } - - u32 i; - win->event.type = 0; - - - switch (E.type) { - case KeyPress: - case KeyRelease: { - win->event.repeat = RGFW_FALSE; - /* check if it's a real key release */ - if (E.type == KeyRelease && XEventsQueued((Display*) win->src.display, QueuedAfterReading)) { /* get next event if there is one*/ - XEvent NE; - XPeekEvent((Display*) win->src.display, &NE); - - if (E.xkey.time == NE.xkey.time && E.xkey.keycode == NE.xkey.keycode) /* check if the current and next are both the same*/ - win->event.repeat = RGFW_TRUE; + /* if there is no unread qued events, get a new one */ + if ((QLength(win->src.display) || XEventsQueued((Display*) win->src.display, QueuedAlready) + XEventsQueued((Display*) win->src.display, QueuedAfterReading)) + && win->event.type != RGFW_quit + ) + XNextEvent((Display*) win->src.display, &E); + else { + return NULL; } - /* set event key data */ - KeySym sym = (KeySym)XkbKeycodeToKeysym((Display*) win->src.display, E.xkey.keycode, 0, E.xkey.state & ShiftMask ? 1 : 0); - win->event.keyCode = RGFW_apiKeyCodeToRGFW(E.xkey.keycode); - - char* str = (char*)XKeysymToString(sym); - if (str != NULL) - strncpy(win->event.keyName, str, 16); + u32 i; + win->event.type = 0; + XEvent reply = { ClientMessage }; - win->event.keyName[15] = '\0'; + switch (E.type) { + case KeyPress: + case KeyRelease: { + win->event.repeat = RGFW_FALSE; + /* check if it's a real key release */ + if (E.type == KeyRelease && XEventsQueued((Display*) win->src.display, QueuedAfterReading)) { /* get next event if there is one*/ + XEvent NE; + XPeekEvent((Display*) win->src.display, &NE); - RGFW_keyboard[win->event.keyCode].prev = RGFW_isPressed(win, win->event.keyCode); - - /* get keystate data */ - win->event.type = (E.type == KeyPress) ? RGFW_keyPressed : RGFW_keyReleased; - - XKeyboardState keystate; - XGetKeyboardControl((Display*) win->src.display, &keystate); - - RGFW_updateLockState(win, (keystate.led_mask & 1), (keystate.led_mask & 2)); - RGFW_keyboard[win->event.keyCode].current = (E.type == KeyPress); - RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, (E.type == KeyPress)); - break; - } - case ButtonPress: - case ButtonRelease: - win->event.type = RGFW_mouseButtonPressed + (E.type == ButtonRelease); // the events match - - switch(win->event.button) { - case RGFW_mouseScrollUp: - win->event.scroll = 1; - break; - case RGFW_mouseScrollDown: - win->event.scroll = -1; - break; - default: break; - } - - win->event.button = E.xbutton.button; - RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current; - - if (win->event.repeat == RGFW_FALSE) - win->event.repeat = RGFW_isPressed(win, win->event.keyCode); - - RGFW_mouseButtons[win->event.button].current = (E.type == ButtonPress); - RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, (E.type == ButtonPress)); - break; - - case MotionNotify: - win->event.point.x = E.xmotion.x; - win->event.point.y = E.xmotion.y; - - if ((win->_winArgs & RGFW_HOLD_MOUSE)) { - win->event.point.y = E.xmotion.y; - - win->event.point.x = win->_lastMousePoint.x - abs(win->event.point.x); - win->event.point.y = win->_lastMousePoint.y - abs(win->event.point.y); - } - - win->_lastMousePoint = RGFW_POINT(E.xmotion.x, E.xmotion.y); - - win->event.type = RGFW_mousePosChanged; - RGFW_mousePosCallback(win, win->event.point); - break; - - case GenericEvent: { - /* MotionNotify is used for mouse events if the mouse isn't held */ - if (!(win->_winArgs & RGFW_HOLD_MOUSE)) { - XFreeEventData(win->src.display, &E.xcookie); - break; - } - - XGetEventData(win->src.display, &E.xcookie); - if (E.xcookie.evtype == XI_RawMotion) { - XIRawEvent *raw = (XIRawEvent *)E.xcookie.data; - if (raw->valuators.mask_len == 0) { - XFreeEventData(win->src.display, &E.xcookie); - break; + if (E.xkey.time == NE.xkey.time && E.xkey.keycode == NE.xkey.keycode) /* check if the current and next are both the same*/ + win->event.repeat = RGFW_TRUE; } - double deltaX = 0.0f; - double deltaY = 0.0f; - - /* check if relative motion data exists where we think it does */ - if (XIMaskIsSet(raw->valuators.mask, 0) != 0) - deltaX += raw->raw_values[0]; - if (XIMaskIsSet(raw->valuators.mask, 1) != 0) - deltaY += raw->raw_values[1]; - - win->event.point = RGFW_POINT((i32)deltaX, (i32)deltaY); + /* set event key data */ + KeySym sym = (KeySym)XkbKeycodeToKeysym((Display*) win->src.display, E.xkey.keycode, 0, E.xkey.state & ShiftMask ? 1 : 0); + win->event.keyCode = RGFW_apiKeyCodeToRGFW(E.xkey.keycode); - RGFW_window_moveMouse(win, RGFW_POINT(win->r.x + (win->r.w / 2), win->r.y + (win->r.h / 2))); + char* str = (char*)XKeysymToString(sym); + if (str != NULL) + strncpy(win->event.keyName, str, 16); + + win->event.keyName[15] = '\0'; + + RGFW_keyboard[win->event.keyCode].prev = RGFW_isPressed(win, win->event.keyCode); + + /* get keystate data */ + win->event.type = (E.type == KeyPress) ? RGFW_keyPressed : RGFW_keyReleased; + + XKeyboardState keystate; + XGetKeyboardControl((Display*) win->src.display, &keystate); + + RGFW_updateLockState(win, (keystate.led_mask & 1), (keystate.led_mask & 2)); + RGFW_keyboard[win->event.keyCode].current = (E.type == KeyPress); + RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, (E.type == KeyPress)); + break; + } + case ButtonPress: + case ButtonRelease: + win->event.type = RGFW_mouseButtonPressed + (E.type == ButtonRelease); // the events match + + switch(win->event.button) { + case RGFW_mouseScrollUp: + win->event.scroll = 1; + break; + case RGFW_mouseScrollDown: + win->event.scroll = -1; + break; + default: break; + } + + win->event.button = E.xbutton.button; + RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current; + + if (win->event.repeat == RGFW_FALSE) + win->event.repeat = RGFW_isPressed(win, win->event.keyCode); + + RGFW_mouseButtons[win->event.button].current = (E.type == ButtonPress); + RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, (E.type == ButtonPress)); + break; + + case MotionNotify: + win->event.point.x = E.xmotion.x; + win->event.point.y = E.xmotion.y; + + if ((win->_winArgs & RGFW_HOLD_MOUSE)) { + win->event.point.y = E.xmotion.y; + + win->event.point.x = win->_lastMousePoint.x - abs(win->event.point.x); + win->event.point.y = win->_lastMousePoint.y - abs(win->event.point.y); + } + + win->_lastMousePoint = RGFW_POINT(E.xmotion.x, E.xmotion.y); win->event.type = RGFW_mousePosChanged; RGFW_mousePosCallback(win, win->event.point); - } + break; - XFreeEventData(win->src.display, &E.xcookie); - break; - } - - case Expose: - win->event.type = RGFW_windowRefresh; - RGFW_windowRefreshCallback(win); - break; + case GenericEvent: { + /* MotionNotify is used for mouse events if the mouse isn't held */ + if (!(win->_winArgs & RGFW_HOLD_MOUSE)) { + XFreeEventData(win->src.display, &E.xcookie); + break; + } + + XGetEventData(win->src.display, &E.xcookie); + if (E.xcookie.evtype == XI_RawMotion) { + XIRawEvent *raw = (XIRawEvent *)E.xcookie.data; + if (raw->valuators.mask_len == 0) { + XFreeEventData(win->src.display, &E.xcookie); + break; + } - case ClientMessage: - /* if the client closed the window*/ - if (E.xclient.data.l[0] == (i64) wm_delete_window) { - win->event.type = RGFW_quit; - RGFW_windowQuitCallback(win); + double deltaX = 0.0f; + double deltaY = 0.0f; + + /* check if relative motion data exists where we think it does */ + if (XIMaskIsSet(raw->valuators.mask, 0) != 0) + deltaX += raw->raw_values[0]; + if (XIMaskIsSet(raw->valuators.mask, 1) != 0) + deltaY += raw->raw_values[1]; + + win->event.point = RGFW_POINT((i32)deltaX, (i32)deltaY); + + RGFW_window_moveMouse(win, RGFW_POINT(win->r.x + (win->r.w / 2), win->r.y + (win->r.h / 2))); + + win->event.type = RGFW_mousePosChanged; + RGFW_mousePosCallback(win, win->event.point); + } + + XFreeEventData(win->src.display, &E.xcookie); break; } - /* reset DND values */ - if (win->event.droppedFilesCount) { - for (i = 0; i < win->event.droppedFilesCount; i++) - win->event.droppedFiles[i][0] = '\0'; - } - - win->event.droppedFilesCount = 0; - - if ((win->_winArgs & RGFW_ALLOW_DND) == 0) + case Expose: + win->event.type = RGFW_windowRefresh; + RGFW_windowRefreshCallback(win); break; - XEvent reply = { ClientMessage }; - reply.xclient.window = xdnd.source; - reply.xclient.format = 32; - reply.xclient.data.l[0] = (long) win->src.window; - reply.xclient.data.l[1] = 0; - reply.xclient.data.l[2] = None; - - if (E.xclient.message_type == XdndEnter) { - unsigned long count; - Atom* formats; - Atom real_formats[6]; - - Bool list = E.xclient.data.l[1] & 1; - - xdnd.source = E.xclient.data.l[0]; - xdnd.version = E.xclient.data.l[1] >> 24; - xdnd.format = None; - - if (xdnd.version > 5) + case ClientMessage: + /* if the client closed the window*/ + if (E.xclient.data.l[0] == (i64) wm_delete_window) { + win->event.type = RGFW_quit; + RGFW_windowQuitCallback(win); break; - - if (list) { - Atom actualType; - i32 actualFormat; - unsigned long bytesAfter; - - XGetWindowProperty((Display*) win->src.display, - xdnd.source, - XdndTypeList, - 0, - LONG_MAX, - False, - 4, - &actualType, - &actualFormat, - &count, - &bytesAfter, - (u8**) &formats); - } else { - count = 0; - - if (E.xclient.data.l[2] != None) - real_formats[count++] = E.xclient.data.l[2]; - if (E.xclient.data.l[3] != None) - real_formats[count++] = E.xclient.data.l[3]; - if (E.xclient.data.l[4] != None) - real_formats[count++] = E.xclient.data.l[4]; - - formats = real_formats; + } + + /* reset DND values */ + if (win->event.droppedFilesCount) { + for (i = 0; i < win->event.droppedFilesCount; i++) + win->event.droppedFiles[i][0] = '\0'; } - unsigned long i; - for (i = 0; i < count; i++) { - if (formats[i] == XtextUriList || formats[i] == XtextPlain) { - xdnd.format = formats[i]; - break; - } - } + win->event.droppedFilesCount = 0; - if (list) { - XFree(formats); - } - - break; - } - if (E.xclient.message_type == XdndPosition) { - const i32 xabs = (E.xclient.data.l[2] >> 16) & 0xffff; - const i32 yabs = (E.xclient.data.l[2]) & 0xffff; - Window dummy; - i32 xpos, ypos; - - if (xdnd.version > 5) + if ((win->_winArgs & RGFW_ALLOW_DND) == 0) break; - XTranslateCoordinates((Display*) win->src.display, - XDefaultRootWindow((Display*) win->src.display), - (Window) win->src.window, - xabs, yabs, - &xpos, &ypos, - &dummy); - - win->event.point.x = xpos; - win->event.point.y = ypos; - reply.xclient.window = xdnd.source; - reply.xclient.message_type = XdndStatus; + reply.xclient.format = 32; + reply.xclient.data.l[0] = (long) win->src.window; + reply.xclient.data.l[1] = 0; + reply.xclient.data.l[2] = None; + + if (E.xclient.message_type == XdndEnter) { + unsigned long count; + Atom* formats; + Atom real_formats[6]; + + Bool list = E.xclient.data.l[1] & 1; + + xdnd.source = E.xclient.data.l[0]; + xdnd.version = E.xclient.data.l[1] >> 24; + + xdnd.format = None; + + if (xdnd.version > 5) + break; + + if (list) { + Atom actualType; + i32 actualFormat; + unsigned long bytesAfter; + + XGetWindowProperty((Display*) win->src.display, + xdnd.source, + XdndTypeList, + 0, + LONG_MAX, + False, + 4, + &actualType, + &actualFormat, + &count, + &bytesAfter, + (u8**) &formats); + } else { + count = 0; + + if (E.xclient.data.l[2] != None) + real_formats[count++] = E.xclient.data.l[2]; + if (E.xclient.data.l[3] != None) + real_formats[count++] = E.xclient.data.l[3]; + if (E.xclient.data.l[4] != None) + real_formats[count++] = E.xclient.data.l[4]; + + formats = real_formats; + } + + unsigned long i; + for (i = 0; i < count; i++) { + if (formats[i] == XtextUriList || formats[i] == XtextPlain) { + xdnd.format = formats[i]; + break; + } + } + + if (list) { + XFree(formats); + } + + break; + } + if (E.xclient.message_type == XdndPosition) { + const i32 xabs = (E.xclient.data.l[2] >> 16) & 0xffff; + const i32 yabs = (E.xclient.data.l[2]) & 0xffff; + Window dummy; + i32 xpos, ypos; + + if (xdnd.version > 5) + break; + + XTranslateCoordinates((Display*) win->src.display, + XDefaultRootWindow((Display*) win->src.display), + (Window) win->src.window, + xabs, yabs, + &xpos, &ypos, + &dummy); + + win->event.point.x = xpos; + win->event.point.y = ypos; + + reply.xclient.window = xdnd.source; + reply.xclient.message_type = XdndStatus; + + if (xdnd.format) { + reply.xclient.data.l[1] = 1; + if (xdnd.version >= 2) + reply.xclient.data.l[4] = XdndActionCopy; + } + + XSendEvent((Display*) win->src.display, xdnd.source, False, NoEventMask, &reply); + XFlush((Display*) win->src.display); + break; + } + + if (E.xclient.message_type != XdndDrop) + break; + + if (xdnd.version > 5) + break; + + win->event.type = RGFW_dnd_init; if (xdnd.format) { - reply.xclient.data.l[1] = 1; - if (xdnd.version >= 2) - reply.xclient.data.l[4] = XdndActionCopy; + Time time = CurrentTime; + + if (xdnd.version >= 1) + time = E.xclient.data.l[2]; + + XConvertSelection((Display*) win->src.display, + XdndSelection, + xdnd.format, + XdndSelection, + (Window) win->src.window, + time); + } else if (xdnd.version >= 2) { + XEvent reply = { ClientMessage }; + + XSendEvent((Display*) win->src.display, xdnd.source, + False, NoEventMask, &reply); + XFlush((Display*) win->src.display); } - XSendEvent((Display*) win->src.display, xdnd.source, False, NoEventMask, &reply); - XFlush((Display*) win->src.display); + RGFW_dndInitCallback(win, win->event.point); break; - } - - if (E.xclient.message_type != XdndDrop) - break; - - if (xdnd.version > 5) - break; - - win->event.type = RGFW_dnd_init; - - if (xdnd.format) { - Time time = CurrentTime; - - if (xdnd.version >= 1) - time = E.xclient.data.l[2]; - - XConvertSelection((Display*) win->src.display, - XdndSelection, - xdnd.format, - XdndSelection, - (Window) win->src.window, - time); - } else if (xdnd.version >= 2) { - XEvent reply = { ClientMessage }; - - XSendEvent((Display*) win->src.display, xdnd.source, - False, NoEventMask, &reply); - XFlush((Display*) win->src.display); - } - - RGFW_dndInitCallback(win, win->event.point); - break; - case SelectionNotify: { - /* this is only for checking for xdnd drops */ - if (E.xselection.property != XdndSelection || !(win->_winArgs | RGFW_ALLOW_DND)) - break; - - char* data; - unsigned long result; - - Atom actualType; - i32 actualFormat; - unsigned long bytesAfter; - - XGetWindowProperty((Display*) win->src.display, E.xselection.requestor, E.xselection.property, 0, LONG_MAX, False, E.xselection.target, &actualType, &actualFormat, &result, &bytesAfter, (u8**) &data); - - if (result == 0) - break; - - /* - SOURCED FROM GLFW _glfwParseUriList - Copyright (c) 2002-2006 Marcus Geelnard - Copyright (c) 2006-2019 Camilla Löwy - */ - - const char* prefix = (const char*)"file://"; - - char* line; - - win->event.droppedFilesCount = 0; - - win->event.type = RGFW_dnd; - - while ((line = strtok(data, "\r\n"))) { - char path[RGFW_MAX_PATH]; - - data = NULL; - - if (line[0] == '#') - continue; - - char* l; - for (l = line; 1; l++) { - if ((l - line) > 7) - break; - else if (*l != prefix[(l - line)]) - break; - else if (*l == '\0' && prefix[(l - line)] == '\0') { - line += 7; - while (*line != '/') - line++; - break; - } else if (*l == '\0') - break; - } - - win->event.droppedFilesCount++; - - size_t index = 0; - while (*line) { - if (line[0] == '%' && line[1] && line[2]) { - const char digits[3] = { line[1], line[2], '\0' }; - path[index] = (char) strtol(digits, NULL, 16); - line += 2; - } else - path[index] = *line; - - index++; - line++; - } - path[index] = '\0'; - strncpy(win->event.droppedFiles[win->event.droppedFilesCount - 1], path, index + 1); - } - - if (data) - XFree(data); - - if (xdnd.version >= 2) { - reply.xclient.message_type = XdndFinished; - reply.xclient.data.l[1] = result; - reply.xclient.data.l[2] = XdndActionCopy; - - XSendEvent((Display*) win->src.display, xdnd.source, False, NoEventMask, &reply); - XFlush((Display*) win->src.display); - } - - RGFW_dndCallback(win, win->event.droppedFiles, win->event.droppedFilesCount); - break; - } - case FocusIn: - win->event.inFocus = 1; - win->event.type = RGFW_focusIn; - RGFW_focusCallback(win, 1); - break; - - break; - case FocusOut: - win->event.inFocus = 0; - win->event.type = RGFW_focusOut; - RGFW_focusCallback(win, 0); - break; - - case EnterNotify: { - win->event.type = RGFW_mouseEnter; - win->event.point.x = E.xcrossing.x; - win->event.point.y = E.xcrossing.y; - RGFW_mouseNotifyCallBack(win, win->event.point, 1); - break; - } - - case LeaveNotify: { - win->event.type = RGFW_mouseLeave; - RGFW_mouseNotifyCallBack(win, win->event.point, 0); - break; - } - - case ConfigureNotify: { - /* detect resize */ - if (E.xconfigure.width != win->r.w || E.xconfigure.height != win->r.h) { - win->event.type = RGFW_windowResized; - win->r = RGFW_RECT(win->r.x, win->r.y, E.xconfigure.width, E.xconfigure.height); - RGFW_windowResizeCallback(win, win->r); + case SelectionNotify: { + /* this is only for checking for xdnd drops */ + if (E.xselection.property != XdndSelection || !(win->_winArgs | RGFW_ALLOW_DND)) break; - } - - /* detect move */ - if (E.xconfigure.x != win->r.x || E.xconfigure.y != win->r.y) { - win->event.type = RGFW_windowMoved; - win->r = RGFW_RECT(E.xconfigure.x, E.xconfigure.y, win->r.w, win->r.h); - RGFW_windowMoveCallback(win, win->r); + + char* data; + unsigned long result; + + Atom actualType; + i32 actualFormat; + unsigned long bytesAfter; + + XGetWindowProperty((Display*) win->src.display, E.xselection.requestor, E.xselection.property, 0, LONG_MAX, False, E.xselection.target, &actualType, &actualFormat, &result, &bytesAfter, (u8**) &data); + + if (result == 0) break; - } + + /* + SOURCED FROM GLFW _glfwParseUriList + Copyright (c) 2002-2006 Marcus Geelnard + Copyright (c) 2006-2019 Camilla Löwy + */ + + const char* prefix = (const char*)"file://"; + + char* line; + + win->event.droppedFilesCount = 0; + + win->event.type = RGFW_dnd; + + while ((line = strtok(data, "\r\n"))) { + char path[RGFW_MAX_PATH]; + + data = NULL; + + if (line[0] == '#') + continue; + + char* l; + for (l = line; 1; l++) { + if ((l - line) > 7) + break; + else if (*l != prefix[(l - line)]) + break; + else if (*l == '\0' && prefix[(l - line)] == '\0') { + line += 7; + while (*line != '/') + line++; + break; + } else if (*l == '\0') + break; + } + + win->event.droppedFilesCount++; + + size_t index = 0; + while (*line) { + if (line[0] == '%' && line[1] && line[2]) { + const char digits[3] = { line[1], line[2], '\0' }; + path[index] = (char) strtol(digits, NULL, 16); + line += 2; + } else + path[index] = *line; + + index++; + line++; + } + path[index] = '\0'; + strncpy(win->event.droppedFiles[win->event.droppedFilesCount - 1], path, index + 1); + } + + if (data) + XFree(data); + + if (xdnd.version >= 2) { + XEvent reply = { ClientMessage }; + reply.xclient.format = 32; + reply.xclient.message_type = XdndFinished; + reply.xclient.data.l[1] = result; + reply.xclient.data.l[2] = XdndActionCopy; + + XSendEvent((Display*) win->src.display, xdnd.source, False, NoEventMask, &reply); + XFlush((Display*) win->src.display); + } + + RGFW_dndCallback(win, win->event.droppedFiles, win->event.droppedFilesCount); + break; + } + case FocusIn: + win->event.inFocus = 1; + win->event.type = RGFW_focusIn; + RGFW_focusCallback(win, 1); + break; break; - } - default: { - break; - } + case FocusOut: + win->event.inFocus = 0; + win->event.type = RGFW_focusOut; + RGFW_focusCallback(win, 0); + break; + + case EnterNotify: { + win->event.type = RGFW_mouseEnter; + win->event.point.x = E.xcrossing.x; + win->event.point.y = E.xcrossing.y; + RGFW_mouseNotifyCallBack(win, win->event.point, 1); + break; + } + + case LeaveNotify: { + win->event.type = RGFW_mouseLeave; + RGFW_mouseNotifyCallBack(win, win->event.point, 0); + break; + } + + case ConfigureNotify: { + /* detect resize */ + if (E.xconfigure.width != win->r.w || E.xconfigure.height != win->r.h) { + win->event.type = RGFW_windowResized; + win->r = RGFW_RECT(win->r.x, win->r.y, E.xconfigure.width, E.xconfigure.height); + RGFW_windowResizeCallback(win, win->r); + break; + } + + /* detect move */ + if (E.xconfigure.x != win->r.x || E.xconfigure.y != win->r.y) { + win->event.type = RGFW_windowMoved; + win->r = RGFW_RECT(E.xconfigure.x, E.xconfigure.y, win->r.w, win->r.h); + RGFW_windowMoveCallback(win, win->r); + break; + } + + break; + } + default: { + break; + } + } + + XFlush((Display*) win->src.display); + + if (win->event.type) + return &win->event; + else + return NULL; } - XFlush((Display*) win->src.display); + void RGFW_window_move(RGFW_window* win, RGFW_point v) { + assert(win != NULL); + win->r.x = v.x; + win->r.y = v.y; - if (win->event.type) - return &win->event; - else - return NULL; - } - - void RGFW_window_move(RGFW_window* win, RGFW_point v) { - assert(win != NULL); - win->r.x = v.x; - win->r.y = v.y; - - XMoveWindow((Display*) win->src.display, (Window) win->src.window, v.x, v.y); - } + XMoveWindow((Display*) win->src.display, (Window) win->src.window, v.x, v.y); + } - void RGFW_window_resize(RGFW_window* win, RGFW_area a) { - assert(win != NULL); - win->r.w = a.w; - win->r.h = a.h; + void RGFW_window_resize(RGFW_window* win, RGFW_area a) { + assert(win != NULL); + win->r.w = a.w; + win->r.h = a.h; - XResizeWindow((Display*) win->src.display, (Window) win->src.window, a.w, a.h); + + XResizeWindow((Display*) win->src.display, (Window) win->src.window, a.w, a.h); + + if (!(win->_winArgs & RGFW_NO_RESIZE)) + return; + + XSizeHints sh = {0}; + sh.flags = (1L << 4) | (1L << 5); + sh.min_width = sh.max_width = a.w; + sh.min_height = sh.max_height = a.h; + + XSetWMSizeHints((Display*) win->src.display, (Drawable) win->src.window, &sh, XA_WM_NORMAL_HINTS); } void RGFW_window_setMinSize(RGFW_window* win, RGFW_area a) { @@ -3727,8 +3762,8 @@ Start of Linux / Unix defines RGFW_area size = RGFW_getScreenSize(); monitor.rect = RGFW_RECT(0, 0, size.w, size.h); - monitor.physW = DisplayWidthMM(display, screen); - monitor.physH = DisplayHeightMM(display, screen); + monitor.physW = DisplayWidthMM(display, screen) / 25.4; + monitor.physH = DisplayHeightMM(display, screen) / 25.4; XGetSystemContentScale(display, &monitor.scaleX, &monitor.scaleY); XRRScreenResources* sr = XRRGetScreenResourcesCurrent(display, RootWindow(display, screen)); @@ -3741,8 +3776,8 @@ Start of Linux / Unix defines } if (ci == NULL) { - float dpi_width = round((double)monitor.rect.w/(((double)monitor.physW)/25.4)); - float dpi_height = round((double)monitor.rect.h/(((double)monitor.physH)/25.4)); + float dpi_width = round((double)monitor.rect.w/(double)monitor.physW); + float dpi_height = round((double)monitor.rect.h/(double)monitor.physH); monitor.scaleX = (float) (dpi_width) / (float) 96; monitor.scaleY = (float) (dpi_height) / (float) 96; @@ -3752,24 +3787,24 @@ Start of Linux / Unix defines } XRROutputInfo* info = XRRGetOutputInfo (display, sr, sr->outputs[screen]); - monitor.physW = info->mm_width; - monitor.physH = info->mm_height; + monitor.physW = info->mm_width / 25.4; + monitor.physH = info->mm_height / 25.4; monitor.rect.x = ci->x; monitor.rect.y = ci->y; monitor.rect.w = ci->width; monitor.rect.h = ci->height; - float dpi_width = round((double)monitor.rect.w/(((double)monitor.physW)/25.4)); - float dpi_height = round((double)monitor.rect.h/(((double)monitor.physH)/25.4)); + float dpi_width = round((double)monitor.rect.w/(double)monitor.physW); + float dpi_height = round((double)monitor.rect.h/(double)monitor.physH); monitor.scaleX = (float) (dpi_width) / (float) 96; monitor.scaleY = (float) (dpi_height) / (float) 96; - if (monitor.scaleX > 1 && monitor.scaleX < 1.1) + if (isinf(monitor.scaleX) || (monitor.scaleX > 1 && monitor.scaleX < 1.1)) monitor.scaleX = 1; - if (monitor.scaleY > 1 && monitor.scaleY < 1.1) + if (isinf(monitor.scaleY) || (monitor.scaleY > 1 && monitor.scaleY < 1.1)) monitor.scaleY = 1; XRRFreeCrtcInfo(ci); @@ -3951,8 +3986,8 @@ Start of Linux / Unix defines } u8 i; - for (i = 0; i < RGFW_joystickCount; i++) - close(RGFW_joysticks[i]); + for (i = 0; i < RGFW_gamepadCount; i++) + close(RGFW_gamepads[i]); } /* set cleared display / window to NULL for error checking */ @@ -3975,43 +4010,43 @@ Start of Linux / Unix defines #include #include #include - u16 RGFW_registerJoystickF(RGFW_window* win, char* file) { + u16 RGFW_registerGamepadF(RGFW_window* win, char* file) { assert(win != NULL); #ifdef __linux__ i32 js = open(file, O_RDONLY); - if (js && RGFW_joystickCount < 4) { - RGFW_joystickCount++; + if (js && RGFW_gamepadCount < 4) { + RGFW_gamepadCount++; - RGFW_joysticks[RGFW_joystickCount - 1] = open(file, O_RDONLY); + RGFW_gamepads[RGFW_gamepadCount - 1] = open(file, O_RDONLY); u8 i; for (i = 0; i < 16; i++) - RGFW_jsPressed[RGFW_joystickCount - 1][i] = 0; + RGFW_gpPressed[RGFW_gamepadCount - 1][i] = 0; } else { #ifdef RGFW_PRINT_ERRORS RGFW_error = 1; - fprintf(stderr, "Error RGFW_registerJoystickF : Cannot open file %s\n", file); + fprintf(stderr, "Error RGFW_registerGamepadF : Cannot open file %s\n", file); #endif } - return RGFW_joystickCount - 1; + return RGFW_gamepadCount - 1; #endif } - u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) { + u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) { assert(win != NULL); #ifdef __linux__ char file[15]; - sprintf(file, "/dev/input/js%i", jsNumber); + sprintf(file, "/dev/input/js%i", gpNumber); - return RGFW_registerJoystickF(win, file); + return RGFW_registerGamepadF(win, file); #endif } @@ -4047,7 +4082,7 @@ Start of Linux / Unix defines { ConnectionNumber(win->src.display), POLLIN, 0 }, #endif { RGFW_eventWait_forceStop[0], POLLIN, 0 }, - #ifdef __linux__ /* blank space for 4 joystick files*/ + #ifdef __linux__ /* blank space for 4 gamepad files*/ { -1, POLLIN, 0 }, {-1, POLLIN, 0 }, {-1, POLLIN, 0 }, {-1, POLLIN, 0} #endif }; @@ -4055,11 +4090,11 @@ Start of Linux / Unix defines u8 index = 2; #if defined(__linux__) - for (i = 0; i < RGFW_joystickCount; i++) { - if (RGFW_joysticks[i] == 0) + for (i = 0; i < RGFW_gamepadCount; i++) { + if (RGFW_gamepads[i] == 0) continue; - fds[index].fd = RGFW_joysticks[i]; + fds[index].fd = RGFW_gamepads[i]; index++; } #endif @@ -4745,7 +4780,7 @@ static const struct wl_callback_listener wl_surface_frame_listener = { } #ifdef __linux__ - RGFW_Event* event = RGFW_linux_updateJoystick(win); + RGFW_Event* event = RGFW_linux_updateGamepad(win); if (event != NULL) return event; #endif @@ -5071,7 +5106,7 @@ static const struct wl_callback_listener wl_surface_frame_listener = { #define wglGetSwapIntervalEXT wglGetSwapIntervalEXTSrc - void* RGFWjoystickApi = NULL; + void* RGFWgamepadApi = NULL; /* these two wgl functions need to be preloaded */ typedef HGLRC (WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hdc, HGLRC hglrc, const int *attribList); @@ -5186,22 +5221,29 @@ static HMODULE wglinstance = NULL; u32 i; static const char* names[] = { "xinput1_4.dll", - "xinput1_3.dll", "xinput9_1_0.dll", "xinput1_2.dll", "xinput1_1.dll" }; - for (i = 0; i < sizeof(names) / sizeof(const char*); i++) { + for (i = 0; i < sizeof(names) / sizeof(const char*) && (XInputGetStateSRC == NULL || XInputGetStateSRC != NULL); i++) { RGFW_XInput_dll = LoadLibraryA(names[i]); - if (RGFW_XInput_dll) { + if (RGFW_XInput_dll == NULL) + continue; + + if (XInputGetStateSRC == NULL) XInputGetStateSRC = (PFN_XInputGetState)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetState"); - - if (XInputGetStateSRC == NULL) - printf("Failed to load XInputGetState"); - } + + if (XInputGetKeystrokeSRC == NULL) + XInputGetKeystrokeSRC = (PFN_XInputGetKeystroke)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetKeystroke"); } + + if (XInputGetStateSRC == NULL) + printf("RGFW ERR: Failed to load XInputGetState\n"); + if (XInputGetKeystrokeSRC == NULL) + printf("RGFW ERR: Failed to load XInputGetKeystroke\n"); + } #endif @@ -5276,7 +5318,9 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (RGFW_Shcore_dll == NULL) { RGFW_Shcore_dll = LoadLibraryA("shcore.dll"); GetDpiForMonitorSRC = (PFN_GetDpiForMonitor)(void*)GetProcAddress(RGFW_Shcore_dll, "GetDpiForMonitor"); - SetProcessDPIAware(); + #if (_WIN32_WINNT >= 0x0600) + SetProcessDPIAware(); + #endif } #endif @@ -5319,6 +5363,11 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ Class.hCursor = LoadCursor(NULL, IDC_ARROW); Class.lpfnWndProc = WndProc; + Class.hIcon = LoadImageA(GetModuleHandleW(NULL), "RGFW_ICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + if (Class.hIcon == NULL) { + Class.hIcon = LoadImageA(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + } + RegisterClassA(&Class); DWORD window_style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN; @@ -5331,7 +5380,8 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (!(args & RGFW_NO_RESIZE)) window_style |= WS_SIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME; } else - window_style |= WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX; + window_style |= WS_POPUP | WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX; + HWND dummyWin = CreateWindowA(Class.lpszClassName, name, window_style, win->r.x, win->r.y, win->r.w, win->r.h, 0, 0, inh, 0); @@ -5623,26 +5673,27 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ u8 RGFW_xinput2RGFW[] = { - RGFW_JS_A, /* or PS X button */ - RGFW_JS_B, /* or PS circle button */ - RGFW_JS_X, /* or PS square button */ - RGFW_JS_Y, /* or PS triangle button */ - RGFW_JS_R1, /* right bumper */ - RGFW_JS_L1, /* left bump */ - RGFW_JS_L2, /* left trigger*/ - RGFW_JS_R2, /* right trigger */ + RGFW_GP_A, /* or PS X button */ + RGFW_GP_B, /* or PS circle button */ + RGFW_GP_X, /* or PS square button */ + RGFW_GP_Y, /* or PS triangle button */ + RGFW_GP_R1, /* right bumper */ + RGFW_GP_L1, /* left bump */ + RGFW_GP_L2, /* left trigger*/ + RGFW_GP_R2, /* right trigger */ 0, 0, 0, 0, 0, 0, 0, 0, - RGFW_JS_UP, /* dpad up */ - RGFW_JS_DOWN, /* dpad down*/ - RGFW_JS_LEFT, /* dpad left */ - RGFW_JS_RIGHT, /* dpad right */ - RGFW_JS_START, /* start button */ - RGFW_JS_SELECT/* select button */ + RGFW_GP_UP, /* dpad up */ + RGFW_GP_DOWN, /* dpad down*/ + RGFW_GP_LEFT, /* dpad left */ + RGFW_GP_RIGHT, /* dpad right */ + RGFW_GP_START, /* start button */ + RGFW_GP_SELECT,/* select button */ + RGFW_GP_L3, + RGFW_GP_R3, }; static i32 RGFW_checkXInput(RGFW_window* win, RGFW_Event* e) { RGFW_UNUSED(win) - size_t i; for (i = 0; i < 4; i++) { XINPUT_KEYSTROKE keystroke; @@ -5655,14 +5706,14 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if ((keystroke.Flags & XINPUT_KEYSTROKE_REPEAT) == 0 && result != ERROR_EMPTY) { if (result != ERROR_SUCCESS) return 0; - - if (keystroke.VirtualKey > VK_PAD_BACK) + + if (keystroke.VirtualKey > VK_PAD_RTHUMB_PRESS) continue; - - // RGFW_jsButtonPressed + 1 = RGFW_jsButtonReleased - e->type = RGFW_jsButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); + + //gp + 1 = RGFW_gpButtonReleased + e->type = RGFW_gpButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); e->button = RGFW_xinput2RGFW[keystroke.VirtualKey - 0x5800]; - RGFW_jsPressed[i][e->button] = !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); + RGFW_gpPressed[i][e->button] = !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN); return 1; } @@ -5672,6 +5723,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ XInputGetState((DWORD) i, &state) == ERROR_DEVICE_NOT_CONNECTED ) return 0; + #define INPUT_DEADZONE ( 0.24f * (float)(0x7FFF) ) // Default to 24% of the +/- 32767 range. This is a reasonable default value but can be altered if needed. if ((state.Gamepad.sThumbLX < INPUT_DEADZONE && @@ -5693,20 +5745,26 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ } e->axisesCount = 2; - RGFW_point axis1 = RGFW_POINT(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY); - RGFW_point axis2 = RGFW_POINT(state.Gamepad.sThumbRX, state.Gamepad.sThumbRY); + RGFW_point axis1 = RGFW_POINT(((float)state.Gamepad.sThumbLX / 32768.0f) * 100, ((float)state.Gamepad.sThumbLY / -32768.0f) * 100); + RGFW_point axis2 = RGFW_POINT(((float)state.Gamepad.sThumbRX / 32768.0f) * 100, ((float)state.Gamepad.sThumbRY / -32768.0f) * 100); - if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y || axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) { - e->type = RGFW_jsAxisMove; + if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y){ + win->event.whichAxis = 0; + + e->type = RGFW_gpAxisMove; e->axis[0] = axis1; - e->axis[1] = axis2; return 1; } - e->axis[0] = axis1; - e->axis[1] = axis2; + if (axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) { + win->event.whichAxis = 1; + e->type = RGFW_gpAxisMove; + e->axis[1] = axis2; + + return 1; + } } return 0; @@ -6501,19 +6559,19 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ CloseClipboard(); } - u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) { + u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) { assert(win != NULL); - RGFW_UNUSED(jsNumber) + RGFW_UNUSED(gpNumber) - return RGFW_registerJoystickF(win, (char*) ""); + return RGFW_registerGamepadF(win, (char*) ""); } - u16 RGFW_registerJoystickF(RGFW_window* win, char* file) { + u16 RGFW_registerGamepadF(RGFW_window* win, char* file) { assert(win != NULL); RGFW_UNUSED(file) - return RGFW_joystickCount - 1; + return RGFW_gamepadCount - 1; } void RGFW_window_moveMouse(RGFW_window* win, RGFW_point p) { @@ -8046,11 +8104,20 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ monitor.rect = RGFW_RECT((int) bounds.origin.x, (int) bounds.origin.y, (int) bounds.size.width, (int) bounds.size.height); CGSize screenSizeMM = CGDisplayScreenSize(display); - monitor.physW = screenSizeMM.width; - monitor.physH = screenSizeMM.height; + monitor.physW = (float)screenSizeMM.width / 25.4f; + monitor.physH = (float)screenSizeMM.height / 25.4f; - monitor.scaleX = ((monitor.rect.w / (screenSizeMM.width / 25.4)) / 96) + 0.25; - monitor.scaleY = ((monitor.rect.h / (screenSizeMM.height / 25.4)) / 96) + 0.25; + float dpi_width = round((double)monitor.rect.w/(double)monitor.physW); + float dpi_height = round((double)monitor.rect.h/(double)monitor.physH); + + monitor.scaleX = (float) (dpi_width) / (float) 96; + monitor.scaleY = (float) (dpi_height) / (float) 96; + + if (isinf(monitor.scaleX) || (monitor.scaleX > 1 && monitor.scaleX < 1.1)) + monitor.scaleX = 1; + + if (isinf(monitor.scaleY) || (monitor.scaleY > 1 && monitor.scaleY < 1.1)) + monitor.scaleY = 1; return monitor; } @@ -8111,20 +8178,20 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ NSPasteBoard_setString(NSPasteboard_generalPasteboard(), text, NSPasteboardTypeString); } - u16 RGFW_registerJoystick(RGFW_window* win, i32 jsNumber) { - RGFW_UNUSED(jsNumber); + u16 RGFW_registerGamepad(RGFW_window* win, i32 gpNumber) { + RGFW_UNUSED(gpNumber); assert(win != NULL); - return RGFW_registerJoystickF(win, (char*) ""); + return RGFW_registerGamepadF(win, (char*) ""); } - u16 RGFW_registerJoystickF(RGFW_window* win, char* file) { + u16 RGFW_registerGamepadF(RGFW_window* win, char* file) { RGFW_UNUSED(file); assert(win != NULL); - return RGFW_joystickCount - 1; + return RGFW_gamepadCount - 1; } #ifdef RGFW_OPENGL @@ -8311,16 +8378,47 @@ EM_BOOL Emscripten_on_resize(int eventType, const EmscriptenUiEvent* e, void* us } EM_BOOL Emscripten_on_fullscreenchange(int eventType, const EmscriptenFullscreenChangeEvent* e, void* userData) { - RGFW_UNUSED(eventType); RGFW_UNUSED(userData); + static u8 fullscreen = RGFW_FALSE; + static RGFW_rect ogRect; + + if (fullscreen == RGFW_FALSE) { + ogRect = RGFW_root->r; + } + fullscreen = !fullscreen; + + RGFW_UNUSED(eventType); RGFW_UNUSED(userData); + RGFW_events[RGFW_eventLen].type = RGFW_windowResized; RGFW_eventLen++; + + RGFW_root->r = RGFW_RECT(0, 0, e->screenWidth, e->screenHeight); + + EM_ASM("Module.canvas.focus();"); + + if (fullscreen == RGFW_FALSE) { + RGFW_root->r = RGFW_RECT(0, 0, ogRect.w, ogRect.h); + // emscripten_request_fullscreen("#canvas", 0); + } else { + #if __EMSCRIPTEN_major__ >= 1 && __EMSCRIPTEN_minor__ >= 29 && __EMSCRIPTEN_tiny__ >= 0 + EmscriptenFullscreenStrategy FSStrat = {0}; + FSStrat.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;//EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT;// : EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; + FSStrat.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_HIDEF; + FSStrat.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; + emscripten_request_fullscreen_strategy("#canvas", 1, &FSStrat); + #else + emscripten_request_fullscreen("#canvas", 1); + #endif + } + + emscripten_set_canvas_element_size("#canvas", RGFW_root->r.w, RGFW_root->r.h); - RGFW_root->r = RGFW_RECT(0, 0, e->elementWidth, e->elementHeight); RGFW_windowResizeCallback(RGFW_root, RGFW_root->r); - return EM_TRUE; + return EM_TRUE; } + + EM_BOOL Emscripten_on_focusin(int eventType, const EmscriptenFocusEvent* e, void* userData) { RGFW_UNUSED(eventType); RGFW_UNUSED(userData); RGFW_UNUSED(e); @@ -8399,7 +8497,7 @@ EM_BOOL Emscripten_on_wheel(int eventType, const EmscriptenWheelEvent* e, void* RGFW_events[RGFW_eventLen].type = RGFW_mouseButtonPressed; RGFW_events[RGFW_eventLen].point = RGFW_POINT(e->mouse.targetX, e->mouse.targetY); RGFW_events[RGFW_eventLen].button = RGFW_mouseScrollUp + (e->deltaY < 0); - RGFW_events[RGFW_eventLen].scroll = e->deltaY; + RGFW_events[RGFW_eventLen].scroll = e->deltaY < 0 ? 1 : -1; RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].prev = RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current; RGFW_mouseButtons[RGFW_events[RGFW_eventLen].button].current = 1; @@ -8472,8 +8570,8 @@ EM_BOOL Emscripten_on_gamepad(int eventType, const EmscriptenGamepadEvent *gamep if (gamepadEvent->index >= 4) return 0; - - RGFW_joysticks[gamepadEvent->index] = gamepadEvent->connected; + + RGFW_gamepads[gamepadEvent->index] = gamepadEvent->connected; return 1; // The event was consumed by the callback handler } @@ -8532,8 +8630,7 @@ void EMSCRIPTEN_KEEPALIVE RGFW_makeSetValue(size_t index, char* file) { */ RGFW_events[RGFW_eventLen].type = RGFW_dnd; - char** arr = (char**)&RGFW_events[RGFW_eventLen].droppedFiles[index]; - *arr = file; + strcpy((char*)RGFW_events[RGFW_eventLen].droppedFiles[index], file); } #include @@ -8687,49 +8784,58 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { static u8 index = 0; - if (index == 0) + if (index == 0) { RGFW_resetKey(); - + } + + emscripten_sample_gamepad_data(); /* check gamepads */ for (int i = 0; (i < emscripten_get_num_gamepads()) && (i < 4); i++) { - if (RGFW_joysticks[i] == 0) - continue;; - + if (RGFW_gamepads[i] == 0) + continue; EmscriptenGamepadEvent gamepadState; if (emscripten_get_gamepad_status(i, &gamepadState) != EMSCRIPTEN_RESULT_SUCCESS) break; - + // Register buttons data for every connected gamepad for (int j = 0; (j < gamepadState.numButtons) && (j < 16); j++) { u32 map[] = { - RGFW_JS_A, RGFW_JS_X, RGFW_JS_B, RGFW_JS_Y, - RGFW_JS_L1, RGFW_JS_R1, RGFW_JS_L2, RGFW_JS_R2, - RGFW_JS_SELECT, RGFW_JS_START, - 0, 0, - RGFW_JS_UP, RGFW_JS_DOWN, RGFW_JS_LEFT, RGFW_JS_RIGHT + RGFW_GP_A, RGFW_GP_B, RGFW_GP_X, RGFW_GP_Y, + RGFW_GP_L1, RGFW_GP_R1, RGFW_GP_L2, RGFW_GP_R2, + RGFW_GP_SELECT, RGFW_GP_START, + RGFW_GP_L3, RGFW_GP_R3, + RGFW_GP_UP, RGFW_GP_DOWN, RGFW_GP_LEFT, RGFW_GP_RIGHT }; + u32 button = map[j]; - if (RGFW_jsPressed[i][button] != gamepadState.digitalButton[j]) { - win->event.type = RGFW_jsButtonPressed; - win->event.joystick = i; + if (button == 404) + continue; + + if (RGFW_gpPressed[i][button] != gamepadState.digitalButton[j]) { + if (gamepadState.digitalButton[j]) + win->event.type = RGFW_gpButtonPressed; + else + win->event.type = RGFW_gpButtonReleased; + + win->event.gamepad = i; win->event.button = map[j]; + RGFW_gpPressed[i][button] = gamepadState.digitalButton[j]; return &win->event; } - - RGFW_jsPressed[i][button] = gamepadState.digitalButton[j]; } for (int j = 0; (j < gamepadState.numAxes) && (j < 4); j += 2) { - win->event.axisesCount = gamepadState.numAxes; - if (win->event.axis[j].x != gamepadState.axis[j] || - win->event.axis[j].y != gamepadState.axis[j + 1] + win->event.axisesCount = gamepadState.numAxes / 2; + if (win->event.axis[j / 2].x != (i8)(gamepadState.axis[j] * 100.0f) || + win->event.axis[j / 2].y != (i8)(gamepadState.axis[j + 1] * 100.0f) ) { - win->event.axis[j].x = gamepadState.axis[j]; - win->event.axis[j].y = gamepadState.axis[j + 1]; - win->event.type = RGFW_jsAxisMove; - win->event.joystick = i; + win->event.axis[j / 2].x = (i8)(gamepadState.axis[j] * 100.0f); + win->event.axis[j / 2].y = (i8)(gamepadState.axis[j + 1] * 100.0f); + win->event.type = RGFW_gpAxisMove; + win->event.gamepad = i; + win->event.whichAxis = j / 2; return &win->event; } } @@ -8738,7 +8844,7 @@ RGFW_Event* RGFW_window_checkEvent(RGFW_window* win) { /* check queued events */ if (RGFW_eventLen == 0) return NULL; - + RGFW_events[index].frameTime = win->event.frameTime; RGFW_events[index].frameTime2 = win->event.frameTime2; RGFW_events[index].inFocus = win->event.inFocus; diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 3cf005f25..d9ba8185c 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -6,6 +6,8 @@ * - Windows (Win32, Win64) * - Linux (X11/Wayland desktop mode) * - MacOS (Cocoa) +* - HTML5 (Emscripten) +* - Others (untested) * * LIMITATIONS: * - TODO @@ -46,7 +48,11 @@ * **********************************************************************************************/ -#if defined(GRAPHICS_API_OPENGL_ES2) +#if defined(PLATFORM_WEB_RGFW) +#define RGFW_NO_GL_HEADER +#endif + +#if defined(GRAPHICS_API_OPENGL_ES2) && !defined(PLATFORM_WEB_RGFW) #define RGFW_OPENGL_ES2 #endif @@ -80,6 +86,10 @@ void CloseWindow(void); #define Size NSSIZE #endif +#define RGFW_MALLOC RL_MALLOC +#define RGFW_FREE RL_FREE +#define RGFW_CALLOC RL_CALLOC + #include "../external/RGFW.h" #if defined(_WIN32) || defined(_WIN64) @@ -118,6 +128,7 @@ static bool RGFW_disableCursor = false; static const unsigned short keyMappingRGFW[] = { [RGFW_KEY_NULL] = KEY_NULL, + [RGFW_Return] = KEY_ENTER, [RGFW_Quote] = KEY_APOSTROPHE, [RGFW_Comma] = KEY_COMMA, [RGFW_Minus] = KEY_MINUS, @@ -246,7 +257,7 @@ bool WindowShouldClose(void) // Toggle fullscreen mode void ToggleFullscreen(void) -{ +{ RGFW_window_maximize(platform.window); ToggleBorderlessWindowed(); } @@ -611,7 +622,7 @@ int GetMonitorPhysicalWidth(int monitor) { RGFW_monitor *mons = RGFW_getMonitors(); - return (int)mons[monitor].physW; + return mons[monitor].physW; } // Get selected monitor physical height in millimetres @@ -664,39 +675,42 @@ const char *GetClipboardText(void) return RGFW_readClipboard(NULL); } + #if defined(SUPPORT_CLIPBOARD_IMAGE) -#if defined(_WIN32) - #define WIN32_CLIPBOARD_IMPLEMENTATION - #define WINUSER_ALREADY_INCLUDED - #define WINBASE_ALREADY_INCLUDED - #define WINGDI_ALREADY_INCLUDED - #include "../external/win32_clipboard.h" + +#ifdef _WIN32 +# define WIN32_CLIPBOARD_IMPLEMENTATION +# define WINUSER_ALREADY_INCLUDED +# define WINBASE_ALREADY_INCLUDED +# define WINGDI_ALREADY_INCLUDED +# include "../external/win32_clipboard.h" #endif -#endif // SUPPORT_CLIPBOARD_IMAGE // Get clipboard image Image GetClipboardImage(void) { - Image image = { 0 }; - -#if defined(SUPPORT_CLIPBOARD_IMAGE) -#if defined(_WIN32) + Image image = {0}; unsigned long long int dataSize = 0; - void *fileData = NULL; - int width = 0; - int height = 0; + void* fileData = NULL; +#ifdef _WIN32 + int width, height; fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize); - - if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); - else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize); #else - TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); + TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement `GetClipboardImage` for this OS"); #endif -#endif // SUPPORT_CLIPBOARD_IMAGE + if (fileData == NULL) + { + TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); + } + else + { + image = LoadImageFromMemory(".bmp", fileData, dataSize); + } return image; } +#endif // SUPPORT_CLIPBOARD_IMAGE // Show mouse cursor void ShowCursor(void) @@ -861,6 +875,28 @@ char RSGL_keystrToChar(const char *str) return '\0'; } +int RGFW_gpConvTable[18] = { + [RGFW_GP_Y] = GAMEPAD_BUTTON_RIGHT_FACE_UP, + [RGFW_GP_B] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, + [RGFW_GP_A] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN, + [RGFW_GP_X] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT, + [RGFW_GP_L1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1, + [RGFW_GP_R1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1, + [RGFW_GP_L2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2, + [RGFW_GP_R2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2, + [RGFW_GP_SELECT] = GAMEPAD_BUTTON_MIDDLE_LEFT, + [RGFW_GP_HOME] = GAMEPAD_BUTTON_MIDDLE, + [RGFW_GP_START] = GAMEPAD_BUTTON_MIDDLE_RIGHT, + [RGFW_GP_UP] = GAMEPAD_BUTTON_LEFT_FACE_UP, + [RGFW_GP_RIGHT] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT, + [RGFW_GP_DOWN] = GAMEPAD_BUTTON_LEFT_FACE_DOWN, + [RGFW_GP_LEFT] = GAMEPAD_BUTTON_LEFT_FACE_LEFT, + [RGFW_GP_L3] = GAMEPAD_BUTTON_LEFT_THUMB, + [RGFW_GP_R3] = GAMEPAD_BUTTON_RIGHT_THUMB, +}; + + + // Register all input events void PollInputEvents(void) { @@ -869,7 +905,7 @@ void PollInputEvents(void) // because ProcessGestureEvent() is just called on an event, not every frame UpdateGestures(); #endif - + // Reset keys/chars pressed registered CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0; @@ -933,27 +969,27 @@ void PollInputEvents(void) while (RGFW_window_checkEvent(platform.window)) { - if ((platform.window->event.type >= RGFW_jsButtonPressed) && (platform.window->event.type <= RGFW_jsAxisMove)) + if ((platform.window->event.type >= RGFW_gpButtonPressed) && (platform.window->event.type <= RGFW_gpAxisMove)) { - if (!CORE.Input.Gamepad.ready[platform.window->event.joystick]) + if (!CORE.Input.Gamepad.ready[platform.window->event.gamepad]) { - CORE.Input.Gamepad.ready[platform.window->event.joystick] = true; - CORE.Input.Gamepad.axisCount[platform.window->event.joystick] = platform.window->event.axisesCount; - CORE.Input.Gamepad.name[platform.window->event.joystick][0] = '\0'; - CORE.Input.Gamepad.axisState[platform.window->event.joystick][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f; - CORE.Input.Gamepad.axisState[platform.window->event.joystick][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f; + CORE.Input.Gamepad.ready[platform.window->event.gamepad] = true; + CORE.Input.Gamepad.axisCount[platform.window->event.gamepad] = platform.window->event.axisesCount; + CORE.Input.Gamepad.name[platform.window->event.gamepad][0] = '\0'; + CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f; + CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f; } } RGFW_Event *event = &platform.window->event; - // All input events can be processed after polling - switch (event->type) + + switch (event->type) { case RGFW_quit: CORE.Window.shouldClose = true; break; case RGFW_dnd: // Dropped file { - for (u32 i = 0; i < event->droppedFilesCount; i++) + for (int i = 0; i < event->droppedFilesCount; i++) { if (CORE.Window.dropFileCount == 0) { @@ -964,7 +1000,7 @@ void PollInputEvents(void) CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event->droppedFiles[i]); - + CORE.Window.dropFileCount++; } else if (CORE.Window.dropFileCount < 1024) @@ -998,7 +1034,6 @@ void PollInputEvents(void) case RGFW_keyPressed: { KeyboardKey key = ConvertScancodeToKey(event->keyCode); - if (key != KEY_NULL) { // If key was up, add it to the key pressed queue @@ -1037,7 +1072,7 @@ void PollInputEvents(void) { if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown)) { - CORE.Input.Mouse.currentWheelMove.y = (float)event->scroll; + CORE.Input.Mouse.currentWheelMove.y = event->scroll; break; } @@ -1053,10 +1088,9 @@ void PollInputEvents(void) } break; case RGFW_mouseButtonReleased: { - if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown)) { - CORE.Input.Mouse.currentWheelMove.y = (float)event->scroll; + CORE.Input.Mouse.currentWheelMove.y = event->scroll; break; } @@ -1087,124 +1121,53 @@ void PollInputEvents(void) CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; touchAction = 2; } break; - case RGFW_jsButtonPressed: + case RGFW_gpButtonPressed: { - int button = -1; - - switch (event->button) - { - case RGFW_JS_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break; - case RGFW_JS_B: button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break; - case RGFW_JS_A: button = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; break; - case RGFW_JS_X: button = GAMEPAD_BUTTON_RIGHT_FACE_LEFT; break; - - case RGFW_JS_L1: button = GAMEPAD_BUTTON_LEFT_TRIGGER_1; break; - case RGFW_JS_R1: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_1; break; - - case RGFW_JS_L2: button = GAMEPAD_BUTTON_LEFT_TRIGGER_2; break; - case RGFW_JS_R2: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_2; break; - - case RGFW_JS_SELECT: button = GAMEPAD_BUTTON_MIDDLE_LEFT; break; - case RGFW_JS_HOME: button = GAMEPAD_BUTTON_MIDDLE; break; - case RGFW_JS_START: button = GAMEPAD_BUTTON_MIDDLE_RIGHT; break; - - case RGFW_JS_UP: button = GAMEPAD_BUTTON_LEFT_FACE_UP; break; - case RGFW_JS_RIGHT: button = GAMEPAD_BUTTON_LEFT_FACE_RIGHT; break; - case RGFW_JS_DOWN: button = GAMEPAD_BUTTON_LEFT_FACE_DOWN; break; - case RGFW_JS_LEFT: button = GAMEPAD_BUTTON_LEFT_FACE_LEFT; break; - - default: break; - } + int button = RGFW_gpConvTable[event->button]; if (button >= 0) { - CORE.Input.Gamepad.currentButtonState[event->joystick][button] = 1; + CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 1; CORE.Input.Gamepad.lastButtonPressed = button; } } break; - case RGFW_jsButtonReleased: + case RGFW_gpButtonReleased: { - int button = -1; - switch (event->button) - { - case RGFW_JS_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break; - case RGFW_JS_B: button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break; - case RGFW_JS_A: button = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; break; - case RGFW_JS_X: button = GAMEPAD_BUTTON_RIGHT_FACE_LEFT; break; + int button = RGFW_gpConvTable[event->button]; - case RGFW_JS_L1: button = GAMEPAD_BUTTON_LEFT_TRIGGER_1; break; - case RGFW_JS_R1: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_1; break; - - case RGFW_JS_L2: button = GAMEPAD_BUTTON_LEFT_TRIGGER_2; break; - case RGFW_JS_R2: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_2; break; - - case RGFW_JS_SELECT: button = GAMEPAD_BUTTON_MIDDLE_LEFT; break; - case RGFW_JS_HOME: button = GAMEPAD_BUTTON_MIDDLE; break; - case RGFW_JS_START: button = GAMEPAD_BUTTON_MIDDLE_RIGHT; break; - - case RGFW_JS_UP: button = GAMEPAD_BUTTON_LEFT_FACE_UP; break; - case RGFW_JS_RIGHT: button = GAMEPAD_BUTTON_LEFT_FACE_RIGHT; break; - case RGFW_JS_DOWN: button = GAMEPAD_BUTTON_LEFT_FACE_DOWN; break; - case RGFW_JS_LEFT: button = GAMEPAD_BUTTON_LEFT_FACE_LEFT; break; - default: break; - } - - if (button >= 0) - { - CORE.Input.Gamepad.currentButtonState[event->joystick][button] = 0; - if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; - } + CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 0; + if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; } break; - case RGFW_jsAxisMove: + case RGFW_gpAxisMove: { int axis = -1; - for (int i = 0; i < event->axisesCount; i++) + + float value = 0; + switch(event->whichAxis) { - switch(i) - { - case 0: - { - if (abs(event->axis[i].x) > abs(event->axis[i].y)) - { - axis = GAMEPAD_AXIS_LEFT_X; - break; - } - - axis = GAMEPAD_AXIS_LEFT_Y; - } break; - case 1: - { - if (abs(event->axis[i].x) > abs(event->axis[i].y)) - { - axis = GAMEPAD_AXIS_RIGHT_X; - break; - } - - axis = GAMEPAD_AXIS_RIGHT_Y; - } break; - case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER; break; - case 3: axis = GAMEPAD_AXIS_RIGHT_TRIGGER; break; - default: break; - } - - #ifdef __linux__ - float value = (event->axis[i].x + event->axis[i].y)/(float)32767; - #else - float value = (event->axis[i].x + -event->axis[i].y)/(float)32767; - #endif - CORE.Input.Gamepad.axisState[event->joystick][axis] = value; - - // Register button state for triggers in addition to their axes - if ((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER)) - { - int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2; - int pressed = (value > 0.1f); - CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed; - - if (pressed) CORE.Input.Gamepad.lastButtonPressed = button; - else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; - } - } + case 0: + { + CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f; + CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f; + } break; + case 1: + { + CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f; + CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f; + } break; + case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER; + case 3: + { + if (axis == -1) axis = GAMEPAD_AXIS_RIGHT_TRIGGER; + int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2; + int pressed = (value > 0.1f); + CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = pressed; + + if (pressed) CORE.Input.Gamepad.lastButtonPressed = button; + else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; + } + default: break; + } } break; default: break; } @@ -1289,17 +1252,22 @@ int InitPlatform(void) platform.window = RGFW_createWindow(CORE.Window.title, RGFW_RECT(0, 0, CORE.Window.screen.width, CORE.Window.screen.height), flags); + +#ifndef PLATFORM_WEB_RGFW RGFW_area screenSize = RGFW_getScreenSize(); CORE.Window.display.width = screenSize.w; CORE.Window.display.height = screenSize.h; - /* - I think this is needed by Raylib now ? +#else + CORE.Window.display.width = CORE.Window.screen.width; + CORE.Window.display.height = CORE.Window.screen.height; +#endif + /* + I think this is needed by Raylib now ? If so, rcore_destkop_sdl should be updated too */ - SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height); - - if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1); - + //SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height); + + if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1); RGFW_window_makeCurrent(platform.window); // Check surface and context activation @@ -1311,12 +1279,6 @@ int InitPlatform(void) CORE.Window.render.height = CORE.Window.screen.height; CORE.Window.currentFbo.width = CORE.Window.render.width; CORE.Window.currentFbo.height = CORE.Window.render.height; - - TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully"); - TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); - TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); - TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); - TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); } else { @@ -1366,12 +1328,11 @@ int InitPlatform(void) #ifdef RGFW_X11 for (int i = 0; (i < 4) && (i < MAX_GAMEPADS); i++) { - RGFW_registerJoystick(platform.window, i); + RGFW_registergamepad(platform.window, i); } #endif TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully"); - return 0; } @@ -1385,6 +1346,6 @@ void ClosePlatform(void) static KeyboardKey ConvertScancodeToKey(u32 keycode) { if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return 0; - - return keyMappingRGFW[keycode]; + + return keyMappingRGFW[keycode]; } diff --git a/src/rcore.c b/src/rcore.c index 571abf97c..40167718c 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -12,6 +12,13 @@ * - Windows (Win32, Win64) * - Linux (X11/Wayland desktop mode) * - Others (not tested) +* > PLATFORM_DESKTOP_RGFW (RGFW backend): +* - Windows (Win32, Win64) +* - Linux (X11/Wayland desktop mode) +* - macOS/OSX (x64, arm64) +* - Others (not tested) +* > PLATFORM_WEB_RGFW: +* - HTML5 (WebAssembly) * > PLATFORM_WEB: * - HTML5 (WebAssembly) * > PLATFORM_DRM: @@ -85,12 +92,12 @@ //---------------------------------------------------------------------------------- // Feature Test Macros required for this module //---------------------------------------------------------------------------------- -#if (defined(__linux__) || defined(PLATFORM_WEB)) && (_XOPEN_SOURCE < 500) +#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_WEB_RGFW)) && (_XOPEN_SOURCE < 500) #undef _XOPEN_SOURCE #define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without gnu ext. #endif -#if (defined(__linux__) || defined(PLATFORM_WEB)) && (_POSIX_C_SOURCE < 199309L) +#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_WEB_RGFW)) && (_POSIX_C_SOURCE < 199309L) #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext. #endif @@ -540,7 +547,7 @@ const char *TextFormat(const char *text, ...); // Formatting of tex #include "platforms/rcore_desktop_glfw.c" #elif defined(PLATFORM_DESKTOP_SDL) #include "platforms/rcore_desktop_sdl.c" -#elif defined(PLATFORM_DESKTOP_RGFW) +#elif (defined(PLATFORM_DESKTOP_RGFW) || defined(PLATFORM_WEB_RGFW)) #include "platforms/rcore_desktop_rgfw.c" #elif defined(PLATFORM_WEB) #include "platforms/rcore_web.c" @@ -611,6 +618,8 @@ void InitWindow(int width, int height, const char *title) TRACELOG(LOG_INFO, "Platform backend: DESKTOP (SDL)"); #elif defined(PLATFORM_DESKTOP_RGFW) TRACELOG(LOG_INFO, "Platform backend: DESKTOP (RGFW)"); +#elif defined(PLATFORM_WEB_RGFW) + TRACELOG(LOG_INFO, "Platform backend: WEB (RGFW) (HTML5)"); #elif defined(PLATFORM_WEB) TRACELOG(LOG_INFO, "Platform backend: WEB (HTML5)"); #elif defined(PLATFORM_DRM) @@ -3573,7 +3582,7 @@ void SetupViewport(int width, int height) // NOTE: Global variables CORE.Window.render.width/CORE.Window.render.height and CORE.Window.renderOffset.x/CORE.Window.renderOffset.y can be modified void SetupFramebuffer(int width, int height) { - // Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var) + // Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var) if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height)) { TRACELOG(LOG_WARNING, "DISPLAY: Downscaling required: Screen size (%ix%i) is bigger than display size (%ix%i)", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height); From 783ca612ccfe6f291998bbbe50480c0531659b7f Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Dec 2024 12:51:00 +0100 Subject: [PATCH 024/793] Update Makefile --- src/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index 4797b587f..b5fa2ecff 100644 --- a/src/Makefile +++ b/src/Makefile @@ -61,11 +61,10 @@ #------------------------------------------------------------------------------------------------ # Define target platform PLATFORM ?= PLATFORM_DESKTOP - ifeq ($(PLATFORM), PLATFORM_DESKTOP) - TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW + TARGET_PLATFORM = PLATFORM_DESKTOP_GLFW else - TARGET_PLATFORM = $(PLATFORM) + TARGET_PLATFORM = $(PLATFORM) endif # Define required raylib variables @@ -122,7 +121,6 @@ SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib SDL_LIBRARIES ?= -lSDL2 -lSDL2main - # Determine if the file has root access (only required to install raylib) # "whoami" prints the name of the user that calls him (so, if it is the root user, "whoami" prints "root") ROOT = $(shell whoami) From 99cb4cbc360181131f632ec63854d8b411a297d8 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Wed, 18 Dec 2024 10:53:50 -0300 Subject: [PATCH 025/793] Fix SetGamepadVibration() TRACELOG message (#4615) --- src/platforms/rcore_android.c | 2 +- src/platforms/rcore_desktop_glfw.c | 2 +- src/platforms/rcore_desktop_rgfw.c | 2 +- src/platforms/rcore_drm.c | 2 +- src/platforms/rcore_template.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 4528c810d..faa00c98b 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -627,7 +627,7 @@ int SetGamepadMappings(const char *mappings) // Set gamepad vibration void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration) { - TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform"); + TRACELOG(LOG_WARNING, "SetGamepadVibration() not implemented on target platform"); } // Set mouse position XY diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 5caf17ead..0d95cdd75 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1088,7 +1088,7 @@ int SetGamepadMappings(const char *mappings) // Set gamepad vibration void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration) { - TRACELOG(LOG_WARNING, "GamepadSetVibration() not available on target platform"); + TRACELOG(LOG_WARNING, "SetGamepadVibration() not available on target platform"); } // Set mouse position XY diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index d9ba8185c..9aea44971 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -797,7 +797,7 @@ int SetGamepadMappings(const char *mappings) // Set gamepad vibration void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration) { - TRACELOG(LOG_WARNING, "GamepadSetVibration() not available on target platform"); + TRACELOG(LOG_WARNING, "SetGamepadVibration() not available on target platform"); } // Set mouse position XY diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index 425b1d4a6..09cb80556 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -622,7 +622,7 @@ int SetGamepadMappings(const char *mappings) // Set gamepad vibration void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration) { - TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform"); + TRACELOG(LOG_WARNING, "SetGamepadVibration() not implemented on target platform"); } // Set mouse position XY diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 9eca9726a..d7605950e 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -384,7 +384,7 @@ int SetGamepadMappings(const char *mappings) // Set gamepad vibration void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration) { - TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform"); + TRACELOG(LOG_WARNING, "SetGamepadVibration() not implemented on target platform"); } // Set mouse position XY From 6eb1206660730e3beb117b9336004356e59ed92f Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Wed, 18 Dec 2024 18:07:48 +0100 Subject: [PATCH 026/793] fix `shaders_deffered_render.c` for OpenGL ES 3 (#4617) This fixes an incomplete framebuffer issue due to the use of a texture format not supported in ES 3. This commit also adds more information on how to manage deferred rendering. --- examples/shaders/shaders_deferred_render.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/shaders/shaders_deferred_render.c b/examples/shaders/shaders_deferred_render.c index 4f652fe33..52c713aa7 100644 --- a/examples/shaders/shaders_deferred_render.c +++ b/examples/shaders/shaders_deferred_render.c @@ -95,11 +95,19 @@ int main(void) rlEnableFramebuffer(gBuffer.framebuffer); - // Since we are storing position and normal data in these textures, - // we need to use a floating point format. - gBuffer.positionTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32, 1); + // NOTE: Vertex positions are stored in a texture for simplicity. A better approach would use a depth texture + // (instead of a detph renderbuffer) to reconstruct world positions in the final render shader via clip-space position, + // depth, and the inverse view/projection matrices. + + // 16-bit precision ensures OpenGL ES 3 compatibility, though it may lack precision for real scenarios. + // But as mentioned above, the positions could be reconstructed instead of stored. If not targeting OpenGL ES + // and you wish to maintain this approach, consider using `RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32`. + gBuffer.positionTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, 1); + + // Similarly, 16-bit precision is used for normals ensures OpenGL ES 3 compatibility. + // This is generally sufficient, but a 16-bit fixed-point format offer a better uniform precision in all orientations. + gBuffer.normalTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R16G16B16, 1); - gBuffer.normalTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R32G32B32, 1); // Albedo (diffuse color) and specular strength can be combined into one texture. // The color in RGB, and the specular strength in the alpha channel. gBuffer.albedoSpecTexture = rlLoadTexture(NULL, screenWidth, screenHeight, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1); From 03ff864087a3ca46a60cd64ef709650cd8d824f5 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Dec 2024 18:44:23 +0100 Subject: [PATCH 027/793] Formating tweaks --- src/platforms/rcore_desktop_rgfw.c | 77 ++++++++++-------------------- 1 file changed, 26 insertions(+), 51 deletions(-) diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 9aea44971..a74af2074 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -168,7 +168,6 @@ static const unsigned short keyMappingRGFW[] = { [RGFW_SuperL] = KEY_LEFT_SUPER, #ifndef RGFW_MACOS [RGFW_ShiftR] = KEY_RIGHT_SHIFT, - [RGFW_AltR] = KEY_RIGHT_ALT, #endif [RGFW_Space] = KEY_SPACE, @@ -677,40 +676,37 @@ const char *GetClipboardText(void) #if defined(SUPPORT_CLIPBOARD_IMAGE) - -#ifdef _WIN32 -# define WIN32_CLIPBOARD_IMPLEMENTATION -# define WINUSER_ALREADY_INCLUDED -# define WINBASE_ALREADY_INCLUDED -# define WINGDI_ALREADY_INCLUDED -# include "../external/win32_clipboard.h" +#if defined(_WIN32) + #define WIN32_CLIPBOARD_IMPLEMENTATION + #define WINUSER_ALREADY_INCLUDED + #define WINBASE_ALREADY_INCLUDED + #define WINGDI_ALREADY_INCLUDED + #include "../external/win32_clipboard.h" +#endif #endif // Get clipboard image Image GetClipboardImage(void) { - Image image = {0}; + Image image = { 0 }; unsigned long long int dataSize = 0; - void* fileData = NULL; + void *fileData = NULL; -#ifdef _WIN32 - int width, height; - fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize); +#if defined(SUPPORT_CLIPBOARD_IMAGE) +#if defined(_WIN32) + int width = 0; + int height = 0; + fileData = (void *)Win32GetClipboardImageData(&width, &height, &dataSize); + + if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data"); + else image = LoadImageFromMemory(".bmp", fileData, dataSize); #else - TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement `GetClipboardImage` for this OS"); + TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement GetClipboardImage() for this OS"); #endif +#endif // SUPPORT_CLIPBOARD_IMAGE - if (fileData == NULL) - { - TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); - } - else - { - image = LoadImageFromMemory(".bmp", fileData, dataSize); - } return image; } -#endif // SUPPORT_CLIPBOARD_IMAGE // Show mouse cursor void ShowCursor(void) @@ -742,9 +738,7 @@ void EnableCursor(void) void DisableCursor(void) { RGFW_disableCursor = true; - RGFW_window_mouseHold(platform.window, RGFW_AREA(0, 0)); - HideCursor(); } @@ -875,6 +869,7 @@ char RSGL_keystrToChar(const char *str) return '\0'; } +// Gamepad buttons conversion table int RGFW_gpConvTable[18] = { [RGFW_GP_Y] = GAMEPAD_BUTTON_RIGHT_FACE_UP, [RGFW_GP_B] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, @@ -895,8 +890,6 @@ int RGFW_gpConvTable[18] = { [RGFW_GP_R3] = GAMEPAD_BUTTON_RIGHT_THUMB, }; - - // Register all input events void PollInputEvents(void) { @@ -917,7 +910,6 @@ void PollInputEvents(void) // Register previous mouse position // Reset last gamepad button/axis registered state - for (int i = 0; (i < 4) && (i < MAX_GAMEPADS); i++) { // Check if gamepad is available @@ -1224,35 +1216,20 @@ int InitPlatform(void) if ((CORE.Window.flags & FLAG_WINDOW_UNDECORATED) > 0) flags |= RGFW_NO_BORDER; if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) == 0) flags |= RGFW_NO_RESIZE; - if ((CORE.Window.flags & FLAG_WINDOW_TRANSPARENT) > 0) flags |= RGFW_TRANSPARENT_WINDOW; - if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) flags |= RGFW_FULLSCREEN; // NOTE: Some OpenGL context attributes must be set before window creation // Check selection OpenGL version - if (rlGetVersion() == RL_OPENGL_21) - { - RGFW_setGLVersion(RGFW_GL_CORE, 2, 1); - } - else if (rlGetVersion() == RL_OPENGL_33) - { - RGFW_setGLVersion(RGFW_GL_CORE, 3, 3); - } - else if (rlGetVersion() == RL_OPENGL_43) - { - RGFW_setGLVersion(RGFW_GL_CORE, 4, 1); - } + if (rlGetVersion() == RL_OPENGL_21) RGFW_setGLVersion(RGFW_GL_CORE, 2, 1); + else if (rlGetVersion() == RL_OPENGL_33) RGFW_setGLVersion(RGFW_GL_CORE, 3, 3); + else if (rlGetVersion() == RL_OPENGL_43) RGFW_setGLVersion(RGFW_GL_CORE, 4, 1); - if (CORE.Window.flags & FLAG_MSAA_4X_HINT) - { - RGFW_setGLSamples(4); - } + if (CORE.Window.flags & FLAG_MSAA_4X_HINT) RGFW_setGLSamples(4); platform.window = RGFW_createWindow(CORE.Window.title, RGFW_RECT(0, 0, CORE.Window.screen.width, CORE.Window.screen.height), flags); - #ifndef PLATFORM_WEB_RGFW RGFW_area screenSize = RGFW_getScreenSize(); CORE.Window.display.width = screenSize.w; @@ -1261,10 +1238,8 @@ int InitPlatform(void) CORE.Window.display.width = CORE.Window.screen.width; CORE.Window.display.height = CORE.Window.screen.height; #endif - /* - I think this is needed by Raylib now ? - If so, rcore_destkop_sdl should be updated too - */ + // TODO: Is this needed by raylib now? + // If so, rcore_desktop_sdl should be updated too //SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height); if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1); From ab83e6dd41f7d0cb85cd7dc37555bbd384650109 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 19 Dec 2024 13:24:30 +0100 Subject: [PATCH 028/793] Image manipulation functions depend on a flag --- src/rtextures.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rtextures.c b/src/rtextures.c index 06f81e577..e0ae5f4af 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -4204,8 +4204,10 @@ TextureCubemap LoadTextureCubemap(Image image, int layout) ImageFormat(&faces, image.format); Image mipmapped = ImageCopy(image); + #if defined(SUPPORT_IMAGE_MANIPULATION) ImageMipmaps(&mipmapped); ImageMipmaps(&faces); + #endif // NOTE: Image formatting does not work with compressed textures From 26e12d6b352406a3cda8839beaeb6b704847ee69 Mon Sep 17 00:00:00 2001 From: Fancy2209 <64917206+Fancy2209@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:53:51 -0100 Subject: [PATCH 029/793] Fix Typo in rcore_desktop_sdl.c (#4621) --- src/platforms/rcore_desktop_sdl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index b7f00bc76..3d1ac0bf3 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -23,7 +23,7 @@ * Custom flag for rcore on target platform -not used- * * DEPENDENCIES: -* - SDL 2 or SLD 3 (main library): Windowing and inputs management +* - SDL 2 or SDL 3 (main library): Windowing and inputs management * - gestures: Gestures system for touch-ready devices (or simulated from mouse inputs) * * From 0212ed0a4b8466477af479018f3d601f5cb9521d Mon Sep 17 00:00:00 2001 From: Jett <30197659+JettMonstersGoBoom@users.noreply.github.com> Date: Fri, 20 Dec 2024 08:14:13 -0500 Subject: [PATCH 030/793] setting MAX_LEVEL based on actual mipcount input (#4622) --- src/rlgl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rlgl.h b/src/rlgl.h index 857e97511..5fd523b3c 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -3301,6 +3301,7 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format, // Activate Trilinear filtering if mipmaps are available glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapCount); // user defined mip count would break without this. } #endif From 6f0d8611feb46f76b106a2e26c7a29844f2d85cd Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 23 Dec 2024 19:24:07 +0100 Subject: [PATCH 031/793] Formating tweaks --- src/rcore.c | 2 +- src/rmodels.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index 40167718c..5ba24a5b8 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -3582,7 +3582,7 @@ void SetupViewport(int width, int height) // NOTE: Global variables CORE.Window.render.width/CORE.Window.render.height and CORE.Window.renderOffset.x/CORE.Window.renderOffset.y can be modified void SetupFramebuffer(int width, int height) { - // Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var) + // Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var) if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height)) { TRACELOG(LOG_WARNING, "DISPLAY: Downscaling required: Screen size (%ix%i) is bigger than display size (%ix%i)", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height); diff --git a/src/rmodels.c b/src/rmodels.c index 43997c318..44988133f 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -2325,7 +2325,7 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) { memcpy(model.meshes[i].boneMatrices, model.meshes[firstMeshWithBones].boneMatrices, - model.meshes[i].boneCount * sizeof(model.meshes[i].boneMatrices[0])); + model.meshes[i].boneCount*sizeof(model.meshes[i].boneMatrices[0])); } } } @@ -2338,7 +2338,7 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) { UpdateModelAnimationBones(model,anim,frame); - + for (int m = 0; m < model.meshCount; m++) { Mesh mesh = model.meshes[m]; @@ -2349,7 +2349,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) float boneWeight = 0.0; bool updated = false; // Flag to check when anim vertex information is updated const int vValues = mesh.vertexCount*3; - + for (int vCounter = 0; vCounter < vValues; vCounter += 3) { mesh.animVertices[vCounter] = 0; From a3a25da59426ddcefc0c01675ba3c9bdaa0ccce8 Mon Sep 17 00:00:00 2001 From: JupiterRider <60042618+JupiterRider@users.noreply.github.com> Date: Mon, 23 Dec 2024 19:25:41 +0100 Subject: [PATCH 032/793] Update BINDINGS.md (#4628) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 56c7e79c1..1faf6ba3d 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -10,7 +10,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT | | [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT | | [raylib-c3](https://github.com/c3lang/vendor/tree/main/libraries/raylib55.c3l) | **5.5** | [C3](https://c3-lang.org) | MIT | -| [Raylib-cs](https://github.com/ChrisDill/Raylib-cs) | **5.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | +| [Raylib-cs](https://github.com/ChrisDill/Raylib-cs) | **5.5** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | Zlib | | [Raylib-CsLo](https://github.com/NotNotTech/Raylib-CsLo) | 4.2 | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | | [Raylib-CSharp-Vinculum](https://github.com/ZeroElectric/Raylib-CSharp-Vinculum) | **5.0** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MPL-2.0 | | [Raylib-CSharp](https://github.com/MrScautHD/Raylib-CSharp) | **5.1-dev** | [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)) | MIT | From e5d8de7c6396783cf28bef77e1d4920af57a133d Mon Sep 17 00:00:00 2001 From: veins1 <19636663+veins1@users.noreply.github.com> Date: Mon, 23 Dec 2024 23:26:50 +0500 Subject: [PATCH 033/793] Fix: Setting flags disables fullscreen #4618 (#4619) --- src/platforms/rcore_desktop_glfw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 0d95cdd75..cb61f7d81 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -322,7 +322,7 @@ void SetWindowState(unsigned int flags) } // State change: FLAG_FULLSCREEN_MODE - if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE)) + if ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) != (flags & FLAG_FULLSCREEN_MODE) && ((flags & FLAG_FULLSCREEN_MODE) > 0)) { ToggleFullscreen(); // NOTE: Window state flag updated inside function } From 4fc908b38f0379a7c2aad2797b7e5e67a127c6dc Mon Sep 17 00:00:00 2001 From: James Doyle Date: Mon, 23 Dec 2024 11:51:11 -0800 Subject: [PATCH 034/793] Update BINDINGS.md (#4633) Add some missing bindings for 5.5 --- BINDINGS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BINDINGS.md b/BINDINGS.md index 1faf6ba3d..5e93a076a 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -44,6 +44,9 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [raylib-lua](https://github.com/TSnake41/raylib-lua) | 5.0 | [Lua](http://www.lua.org) | ISC | | [raylib-lua-bindings (WIP)](https://github.com/legendaryredfox/raylib-lua-bindings) | 5.5 | [Lua](http://www.lua.org) | ISC | | [ReiLua](https://github.com/nullstare/ReiLua) | 5.5 | [Lua](http://www.lua.org) | MIT | +| [raylib-lua-sol](https://github.com/RobLoach/raylib-lua-sol) | 5.5 | [Lua](http://www.lua.org) | Zlib | +| [raylib-luajit](https://github.com/homma/raylib-luajit) | 5.5 | [Lua](http://www.lua.org) | MIT | +| [raylib-luajit-generated](https://github.com/james2doyle/raylib-luajit-generated) | 5.5 | [Lua](http://www.lua.org) | MIT | | [raylib-matte](https://github.com/jcorks/raylib-matte) | 4.6-dev | [Matte](https://github.com/jcorks/matte) | **???** | | [Raylib.nelua](https://github.com/AuzFox/Raylib.nelua) | **5.0** | [nelua](https://nelua.io) | Zlib | | [raylib-bindings](https://github.com/vaiorabbit/raylib-bindings) | 5.6-dev | [Ruby](https://www.ruby-lang.org/en) | Zlib | @@ -72,6 +75,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [raylib-scopes](https://github.com/salotz/raylib-scopes) | auto | [Scopes](http://scopes.rocks) | MIT | | [raylib-SmallBASIC](https://github.com/smallbasic/smallbasic.plugins/tree/master/raylib) | **5.5** | [SmallBASIC](https://github.com/smallbasic/SmallBASIC) | GPLv3 | | [raylib-umka](https://github.com/robloach/raylib-umka) | 4.5 | [Umka](https://github.com/vtereshkov/umka-lang) | Zlib | +| [raylib-for-v](https://github.com/EmmaTheMartian/raylib-for-v) | 5.5 | [V](https://vlang.io) | MIT/Unlicense | | [raylib.v](https://github.com/irishgreencitrus/raylib.v) | 4.2 | [V](https://vlang.io) | Zlib | | [raylib-vapi](https://github.com/lxmcf/raylib-vapi) | **5.0** | [Vala](https://vala.dev) | Zlib | | [raylib-wren](https://github.com/TSnake41/raylib-wren) | 4.5 | [Wren](http://wren.io) | ISC | From 7868d600f40b80177add61e9b865f66405fd77f3 Mon Sep 17 00:00:00 2001 From: Fancy2209 <64917206+Fancy2209@users.noreply.github.com> Date: Mon, 23 Dec 2024 20:25:22 -0100 Subject: [PATCH 035/793] [rtext] Fix default font alpha on Big Endian systems (#4624) * Fix rtext default font alpha on Big Endian * Endian Indepence --- src/rtext.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rtext.c b/src/rtext.c index 005568dbf..b60c8cb1d 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -247,7 +247,11 @@ extern void LoadFontDefault(void) // we must consider data as little-endian order (alpha + gray) ((unsigned short *)imFont.data)[i + j] = 0xffff; } - else ((unsigned short *)imFont.data)[i + j] = 0x00ff; + else + { + ((unsigned char *)imFont.data)[(i + j)*sizeof(short)] = 0xFF; + ((unsigned char *)imFont.data)[(i + j)*sizeof(short) + 1] = 0x00; + } } counter++; From a7686c47b35fb62e8c9041240060622e5b89b9f6 Mon Sep 17 00:00:00 2001 From: Jett <30197659+JettMonstersGoBoom@users.noreply.github.com> Date: Tue, 24 Dec 2024 14:11:17 -0500 Subject: [PATCH 036/793] resolved a few segfaults with animation system (#4635) * Update rmodels.c resolves segfault with missing bone weights or bone IDs * Update rmodels.c segfault with animation and missing normals/animnormals * correct place. --- src/rmodels.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rmodels.c b/src/rmodels.c index 44988133f..3fcd5cea7 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -2286,6 +2286,7 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) } } + // Update all bones and boneMatrices of first mesh with bones. for (int boneId = 0; boneId < anim.boneCount; boneId++) { @@ -2350,6 +2351,8 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) bool updated = false; // Flag to check when anim vertex information is updated const int vValues = mesh.vertexCount*3; + if ((mesh.boneWeights==NULL) || (mesh.boneIds==NULL)) continue; // skip if missing bone data, causes segfault without on some models + for (int vCounter = 0; vCounter < vValues; vCounter += 3) { mesh.animVertices[vCounter] = 0; @@ -2378,7 +2381,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) // Normals processing // NOTE: We use meshes.baseNormals (default normal) to calculate meshes.normals (animated normals) - if (mesh.normals != NULL) + if ((mesh.normals != NULL) && (mesh.animNormals != NULL )) { animNormal = (Vector3){ mesh.normals[vCounter], mesh.normals[vCounter + 1], mesh.normals[vCounter + 2] }; animNormal = Vector3Transform(animNormal,model.meshes[m].boneMatrices[boneId]); @@ -2392,7 +2395,8 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) if (updated) { rlUpdateVertexBuffer(mesh.vboId[0], mesh.animVertices, mesh.vertexCount*3*sizeof(float), 0); // Update vertex position - rlUpdateVertexBuffer(mesh.vboId[2], mesh.animNormals, mesh.vertexCount*3*sizeof(float), 0); // Update vertex normals + if (mesh.normals != NULL) + rlUpdateVertexBuffer(mesh.vboId[2], mesh.animNormals, mesh.vertexCount*3*sizeof(float), 0); // Update vertex normals } } } From ae3c0df2060ac0df13e4e95ece5b3fc9be464d6f Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 24 Dec 2024 20:14:54 +0100 Subject: [PATCH 037/793] Reviewed formating, removed assert() #4635 --- src/rmodels.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/rmodels.c b/src/rmodels.c index 3fcd5cea7..0455ced27 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -2277,7 +2277,6 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) { if (model.meshes[i].boneMatrices) { - assert(model.meshes[i].boneCount == anim.boneCount); if (firstMeshWithBones == -1) { firstMeshWithBones = i; @@ -2286,7 +2285,6 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) } } - // Update all bones and boneMatrices of first mesh with bones. for (int boneId = 0; boneId < anim.boneCount; boneId++) { @@ -2351,7 +2349,8 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) bool updated = false; // Flag to check when anim vertex information is updated const int vValues = mesh.vertexCount*3; - if ((mesh.boneWeights==NULL) || (mesh.boneIds==NULL)) continue; // skip if missing bone data, causes segfault without on some models + // Skip if missing bone data, causes segfault without on some models + if ((mesh.boneWeights == NULL) || (mesh.boneIds == NULL)) continue; for (int vCounter = 0; vCounter < vValues; vCounter += 3) { @@ -2364,7 +2363,8 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) mesh.animNormals[vCounter + 1] = 0; mesh.animNormals[vCounter + 2] = 0; } - // Iterates over 4 bones per vertex + + // Iterates over 4 bones per vertex for (int j = 0; j < 4; j++, boneCounter++) { boneWeight = mesh.boneWeights[boneCounter]; @@ -2395,8 +2395,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) if (updated) { rlUpdateVertexBuffer(mesh.vboId[0], mesh.animVertices, mesh.vertexCount*3*sizeof(float), 0); // Update vertex position - if (mesh.normals != NULL) - rlUpdateVertexBuffer(mesh.vboId[2], mesh.animNormals, mesh.vertexCount*3*sizeof(float), 0); // Update vertex normals + if (mesh.normals != NULL) rlUpdateVertexBuffer(mesh.vboId[2], mesh.animNormals, mesh.vertexCount*3*sizeof(float), 0); // Update vertex normals } } } From 873bf31be3145d5695f9f13b7cb3eb688b6256e4 Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Tue, 24 Dec 2024 20:17:37 +0100 Subject: [PATCH 038/793] [rmodels] Fix normal transform in `UpdateModelAnimationBones` (#4634) * remove duplicate calculation of `invRotation` in `UpdateModelAnimationBones` * fix normal transform in `UpdateModelAnimation` --- src/rmodels.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/rmodels.c b/src/rmodels.c index 0455ced27..c62267de4 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -2296,13 +2296,12 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame) Quaternion outRotation = anim.framePoses[frame][boneId].rotation; Vector3 outScale = anim.framePoses[frame][boneId].scale; - Vector3 invTranslation = Vector3RotateByQuaternion(Vector3Negate(inTranslation), QuaternionInvert(inRotation)); Quaternion invRotation = QuaternionInvert(inRotation); + Vector3 invTranslation = Vector3RotateByQuaternion(Vector3Negate(inTranslation), invRotation); Vector3 invScale = Vector3Divide((Vector3){ 1.0f, 1.0f, 1.0f }, inScale); - Vector3 boneTranslation = Vector3Add( - Vector3RotateByQuaternion(Vector3Multiply(outScale, invTranslation), - outRotation), outTranslation); + Vector3 boneTranslation = Vector3Add(Vector3RotateByQuaternion( + Vector3Multiply(outScale, invTranslation), outRotation), outTranslation); Quaternion boneRotation = QuaternionMultiply(outRotation, invRotation); Vector3 boneScale = Vector3Multiply(outScale, invScale); @@ -2384,7 +2383,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) if ((mesh.normals != NULL) && (mesh.animNormals != NULL )) { animNormal = (Vector3){ mesh.normals[vCounter], mesh.normals[vCounter + 1], mesh.normals[vCounter + 2] }; - animNormal = Vector3Transform(animNormal,model.meshes[m].boneMatrices[boneId]); + animNormal = Vector3Transform(animNormal, MatrixTranspose(MatrixInvert(model.meshes[m].boneMatrices[boneId]))); mesh.animNormals[vCounter] += animNormal.x*boneWeight; mesh.animNormals[vCounter + 1] += animNormal.y*boneWeight; mesh.animNormals[vCounter + 2] += animNormal.z*boneWeight; From c333e8049778de79c6f4e0c2698b49c16af19577 Mon Sep 17 00:00:00 2001 From: Colleague Riley Date: Wed, 25 Dec 2024 12:19:51 -0800 Subject: [PATCH 039/793] Update RGFW (#4637) * add PLATFORM_WEB_RGFW * fix some bugs * fix web_rgfw gamepad * send fake screensize * fix gamepad bugs (linux) | add L3 + R3 (gamepad) * fix? * update RGFW (again) * update raylib (merge) * fix xinput stuff * delete makefile added by mistake * update RGFW * update RGFW (rename joystick to gamepad to avoid misunderstandings * update RGFW (fix X11 bug) * update RGFW * use RL_MALLOC for RGFW * update RGFW (fixes xdnd bug) * fix some formating * Update RGFW * update RGFW * undo change * undo change * undo change * undo change * have .scroll be 0 by default --- src/external/RGFW.h | 922 ++++++++++++++++++----------- src/platforms/rcore_desktop_rgfw.c | 68 +-- 2 files changed, 585 insertions(+), 405 deletions(-) diff --git a/src/external/RGFW.h b/src/external/RGFW.h index 2a10eda2c..317d00c7a 100644 --- a/src/external/RGFW.h +++ b/src/external/RGFW.h @@ -30,6 +30,7 @@ /* #define RGFW_IMPLEMENTATION - (required) makes it so the source code is included #define RGFW_PRINT_ERRORS - (optional) makes it so RGFW prints errors when they're found + #define RGFW_DEBUG - (optional) makes it so RGFW prints debug messages #define RGFW_OSMESA - (optional) use OSmesa as backend (instead of system's opengl api + regular opengl) #define RGFW_BUFFER - (optional) just draw directly to (RGFW) window pixel buffer that is drawn to screen (the buffer is in the RGBA format) #define RGFW_EGL - (optional) use EGL for loading an OpenGL context (instead of the system's opengl api) @@ -65,7 +66,7 @@ /* Example to get you started : -linux : gcc main.c -lX11 -lXrandr -lGL +linux : gcc main.c -lX11 -lXrandr -lGL -lm windows : gcc main.c -lopengl32 -lwinmm -lshell32 -lgdi32 macos : gcc main.c -framework Foundation -framework AppKit -framework OpenGL -framework CoreVideo @@ -207,11 +208,7 @@ int main() { #endif #ifndef RGFWDEF - #ifdef __clang__ - #define RGFWDEF static inline - #else - #define RGFWDEF inline - #endif + #define RGFWDEF inline #endif #ifndef RGFW_ENUM @@ -391,7 +388,7 @@ typedef RGFW_ENUM(u8, RGFW_event_types) { RGFW_keyReleased, /*!< a key has been released*/ /*! key event note the code of the key pressed is stored in - RGFW_Event.keyCode + RGFW_Event.key !!Keycodes defined at the bottom of the RGFW_HEADER part of this file!! while a string version is stored in @@ -546,8 +543,9 @@ typedef struct RGFW_Event { u32 type; /*!< which event has been sent?*/ RGFW_point point; /*!< mouse x, y of event (or drop point) */ - u8 keyCode; /*!< keycode of event !!Keycodes defined at the bottom of the RGFW_HEADER part of this file!! */ - + u8 key; /*!< the physical key of the event, refers to where key is physically !!Keycodes defined at the bottom of the RGFW_HEADER part of this file!! */ + u8 keyChar; /*!< mapped key char of the event*/ + b8 repeat; /*!< key press event repeated (the key is being held) */ b8 inFocus; /*!< if the window is in focus or not (this is always true for MacOS windows due to the api being weird) */ @@ -871,14 +869,6 @@ RGFWDEF RGFW_monitor RGFW_window_getMonitor(RGFW_window* win); /*error handling*/ RGFWDEF b8 RGFW_Error(void); /*!< returns true if an error has occurred (doesn't print errors itself) */ -/*! returns true if the key should be shifted */ -RGFWDEF b8 RGFW_shouldShift(u32 keycode, u8 lockState); - -/*! get char from RGFW keycode (using a LUT), uses shift'd version if shift = true */ -RGFWDEF char RGFW_keyCodeToChar(u32 keycode, b8 shift); -/*! get char from RGFW keycode (using a LUT), uses lockState for shouldShift) */ -RGFWDEF char RGFW_keyCodeToCharAuto(u32 keycode, u8 lockState); - /*! if window == NULL, it checks if the key is pressed globally. Otherwise, it checks only if the key is pressed while the window in focus.*/ RGFWDEF b8 RGFW_isPressed(RGFW_window* win, u8 key); /*!< if key is pressed (key code)*/ @@ -935,8 +925,8 @@ typedef void (* RGFW_mouseposfunc)(RGFW_window* win, RGFW_point point); typedef void (* RGFW_dndInitfunc)(RGFW_window* win, RGFW_point point); /*! RGFW_windowRefresh, the window that needs to be refreshed */ typedef void (* RGFW_windowrefreshfunc)(RGFW_window* win); -/*! RGFW_keyPressed / RGFW_keyReleased, the window that got the event, the keycode, the string version, the state of mod keys, if it was a press (else it's a release) */ -typedef void (* RGFW_keyfunc)(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed); +/*! RGFW_keyPressed / RGFW_keyReleased, the window that got the event, the mapped key, the physical key, the string version, the state of mod keys, if it was a press (else it's a release) */ +typedef void (* RGFW_keyfunc)(RGFW_window* win, u32 key, u32 mappedKey, char keyName[16], u8 lockState, b8 pressed); /*! RGFW_mouseButtonPressed / RGFW_mouseButtonReleased, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */ typedef void (* RGFW_mousebuttonfunc)(RGFW_window* win, u8 button, double scroll, b8 pressed); /*!gp /gp, the window that got the event, the button that was pressed, the scroll value, if it was a press (else it's a release) */ @@ -1085,7 +1075,64 @@ RGFWDEF void RGFW_sleep(u64 milisecond); /*!< sleep for a set time */ typedef RGFW_ENUM(u8, RGFW_Key) { RGFW_KEY_NULL = 0, - RGFW_Escape, + RGFW_Escape = '\033', + RGFW_Backtick = '`', + RGFW_0 = '0', + RGFW_1 = '1', + RGFW_2 = '2', + RGFW_3 = '3', + RGFW_4 = '4', + RGFW_5 = '5', + RGFW_6 = '6', + RGFW_7 = '7', + RGFW_8 = '8', + RGFW_9 = '9', + + RGFW_Minus = '-', + RGFW_Equals = '=', + RGFW_BackSpace = '\b', + RGFW_Tab = '\t', + RGFW_Space = ' ', + + RGFW_a = 'a', + RGFW_b = 'b', + RGFW_c = 'c', + RGFW_d = 'd', + RGFW_e = 'e', + RGFW_f = 'f', + RGFW_g = 'g', + RGFW_h = 'h', + RGFW_i = 'i', + RGFW_j = 'j', + RGFW_k = 'k', + RGFW_l = 'l', + RGFW_m = 'm', + RGFW_n = 'n', + RGFW_o = 'o', + RGFW_p = 'p', + RGFW_q = 'q', + RGFW_r = 'r', + RGFW_s = 's', + RGFW_t = 't', + RGFW_u = 'u', + RGFW_v = 'v', + RGFW_w = 'w', + RGFW_x = 'x', + RGFW_y = 'y', + RGFW_z = 'z', + + RGFW_Period = '.', + RGFW_Comma = ',', + RGFW_Slash = '/', + RGFW_Bracket = '{', + RGFW_CloseBracket = '}', + RGFW_Semicolon = ';', + RGFW_Apostrophe = '\'', + RGFW_BackSlash = '\\', + RGFW_Return = '\n', + + RGFW_Delete = '\177', /* 127 */ + RGFW_F1, RGFW_F2, RGFW_F3, @@ -1099,23 +1146,6 @@ typedef RGFW_ENUM(u8, RGFW_Key) { RGFW_F11, RGFW_F12, - RGFW_Backtick, - - RGFW_0, - RGFW_1, - RGFW_2, - RGFW_3, - RGFW_4, - RGFW_5, - RGFW_6, - RGFW_7, - RGFW_8, - RGFW_9, - - RGFW_Minus, - RGFW_Equals, - RGFW_BackSpace, - RGFW_Tab, RGFW_CapsLock, RGFW_ShiftL, RGFW_ControlL, @@ -1125,51 +1155,11 @@ typedef RGFW_ENUM(u8, RGFW_Key) { RGFW_ControlR, RGFW_AltR, RGFW_SuperR, - RGFW_Space, - - RGFW_a, - RGFW_b, - RGFW_c, - RGFW_d, - RGFW_e, - RGFW_f, - RGFW_g, - RGFW_h, - RGFW_i, - RGFW_j, - RGFW_k, - RGFW_l, - RGFW_m, - RGFW_n, - RGFW_o, - RGFW_p, - RGFW_q, - RGFW_r, - RGFW_s, - RGFW_t, - RGFW_u, - RGFW_v, - RGFW_w, - RGFW_x, - RGFW_y, - RGFW_z, - - RGFW_Period, - RGFW_Comma, - RGFW_Slash, - RGFW_Bracket, - RGFW_CloseBracket, - RGFW_Semicolon, - RGFW_Return, - RGFW_Quote, - RGFW_BackSlash, - RGFW_Up, RGFW_Down, RGFW_Left, RGFW_Right, - RGFW_Delete, RGFW_Insert, RGFW_End, RGFW_Home, @@ -1180,10 +1170,10 @@ typedef RGFW_ENUM(u8, RGFW_Key) { RGFW_KP_Slash, RGFW_Multiply, RGFW_KP_Minus, - RGFW_KP_1, - RGFW_KP_2, - RGFW_KP_3, - RGFW_KP_4, + RGFW_KP_1, + RGFW_KP_2, + RGFW_KP_3, + RGFW_KP_4, RGFW_KP_5, RGFW_KP_6, RGFW_KP_7, @@ -1193,7 +1183,7 @@ typedef RGFW_ENUM(u8, RGFW_Key) { RGFW_KP_Period, RGFW_KP_Return, - final_key, + final_key }; @@ -1263,121 +1253,121 @@ This is the start of keycode data #include #endif -u8 RGFW_keycodes [RGFW_OS_BASED_VALUE(136, 337, 128, DOM_VK_WIN_OEM_CLEAR + 1, 130)] = { +u8 RGFW_keycodes [RGFW_OS_BASED_VALUE(136, 0x15C + 1, 128, DOM_VK_WIN_OEM_CLEAR + 1, 130)] = { #ifdef __cplusplus 0 }; void RGFW_init_keys(void) { #endif - RGFW_MAP [RGFW_OS_BASED_VALUE(49, 192, 50, DOM_VK_BACK_QUOTE, KEY_GRAVE)] = RGFW_Backtick RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(49, 0x029, 50, DOM_VK_BACK_QUOTE, KEY_GRAVE)] = RGFW_Backtick RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(19, 0x30, 29, DOM_VK_0, KEY_0)] = RGFW_0 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(10, 0x31, 18, DOM_VK_1, KEY_1)] = RGFW_1 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(11, 0x32, 19, DOM_VK_2, KEY_2)] = RGFW_2 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(12, 0x33, 20, DOM_VK_3, KEY_3)] = RGFW_3 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(13, 0x34, 21, DOM_VK_4, KEY_4)] = RGFW_4 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(14, 0x35, 23, DOM_VK_5, KEY_5)] = RGFW_5 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(15, 0x36, 22, DOM_VK_6, KEY_6)] = RGFW_6 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(16, 0x37, 26, DOM_VK_7, KEY_7)] = RGFW_7 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(17, 0x38, 28, DOM_VK_8, KEY_8)] = RGFW_8 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(18, 0x39, 25, DOM_VK_9, KEY_9)] = RGFW_9, + RGFW_MAP [RGFW_OS_BASED_VALUE(19, 0x00B, 29, DOM_VK_0, KEY_0)] = RGFW_0 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(10, 0x002, 18, DOM_VK_1, KEY_1)] = RGFW_1 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(11, 0x003, 19, DOM_VK_2, KEY_2)] = RGFW_2 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(12, 0x004, 20, DOM_VK_3, KEY_3)] = RGFW_3 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(13, 0x005, 21, DOM_VK_4, KEY_4)] = RGFW_4 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(14, 0x006, 23, DOM_VK_5, KEY_5)] = RGFW_5 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(15, 0x007, 22, DOM_VK_6, KEY_6)] = RGFW_6 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(16, 0x008, 26, DOM_VK_7, KEY_7)] = RGFW_7 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(17, 0x009, 28, DOM_VK_8, KEY_8)] = RGFW_8 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(18, 0x00A, 25, DOM_VK_9, KEY_9)] = RGFW_9, - RGFW_MAP [RGFW_OS_BASED_VALUE(65, 0x20, 49, DOM_VK_SPACE, KEY_SPACE)] = RGFW_Space, + RGFW_MAP [RGFW_OS_BASED_VALUE(65, 0x039, 49, DOM_VK_SPACE, KEY_SPACE)] = RGFW_Space, - RGFW_MAP [RGFW_OS_BASED_VALUE(38, 0x41, 0, DOM_VK_A, KEY_A)] = RGFW_a RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(56, 0x42, 11, DOM_VK_B, KEY_B)] = RGFW_b RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(54, 0x43, 8, DOM_VK_C, KEY_C)] = RGFW_c RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(40, 0x44, 2, DOM_VK_D, KEY_D)] = RGFW_d RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(26, 0x45, 14, DOM_VK_E, KEY_E)] = RGFW_e RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(41, 0x46, 3, DOM_VK_F, KEY_F)] = RGFW_f RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(42, 0x47, 5, DOM_VK_G, KEY_G)] = RGFW_g RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(43, 0x48, 4, DOM_VK_H, KEY_H)] = RGFW_h RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(31, 0x49, 34, DOM_VK_I, KEY_I)] = RGFW_i RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(44, 0x4A, 38, DOM_VK_J, KEY_J)] = RGFW_j RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(45, 0x4B, 40, DOM_VK_K, KEY_K)] = RGFW_k RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(46, 0x4C, 37, DOM_VK_L, KEY_L)] = RGFW_l RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(58, 0x4D, 46, DOM_VK_M, KEY_M)] = RGFW_m RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(57, 0x4E, 45, DOM_VK_N, KEY_N)] = RGFW_n RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(32, 0x4F, 31, DOM_VK_O, KEY_O)] = RGFW_o RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(33, 0x50, 35, DOM_VK_P, KEY_P)] = RGFW_p RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(24, 0x51, 12, DOM_VK_Q, KEY_Q)] = RGFW_q RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(27, 0x52, 15, DOM_VK_R, KEY_R)] = RGFW_r RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(39, 0x53, 1, DOM_VK_S, KEY_S)] = RGFW_s RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(28, 0x54, 17, DOM_VK_T, KEY_T)] = RGFW_t RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(30, 0x55, 32, DOM_VK_U, KEY_U)] = RGFW_u RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(55, 0x56, 9, DOM_VK_V, KEY_V)] = RGFW_v RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(25, 0x57, 13, DOM_VK_W, KEY_W)] = RGFW_w RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(53, 0x58, 7, DOM_VK_X, KEY_X)] = RGFW_x RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(29, 0x59, 16, DOM_VK_Y, KEY_Y)] = RGFW_y RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(52, 0x5A, 6, DOM_VK_Z, KEY_Z)] = RGFW_z, + RGFW_MAP [RGFW_OS_BASED_VALUE(38, 0x01E, 0, DOM_VK_A, KEY_A)] = RGFW_a RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(56, 0x030, 11, DOM_VK_B, KEY_B)] = RGFW_b RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(54, 0x02E, 8, DOM_VK_C, KEY_C)] = RGFW_c RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(40, 0x020, 2, DOM_VK_D, KEY_D)] = RGFW_d RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(26, 0x012, 14, DOM_VK_E, KEY_E)] = RGFW_e RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(41, 0x021, 3, DOM_VK_F, KEY_F)] = RGFW_f RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(42, 0x022, 5, DOM_VK_G, KEY_G)] = RGFW_g RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(43, 0x023, 4, DOM_VK_H, KEY_H)] = RGFW_h RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(31, 0x017, 34, DOM_VK_I, KEY_I)] = RGFW_i RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(44, 0x024, 38, DOM_VK_J, KEY_J)] = RGFW_j RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(45, 0x025, 40, DOM_VK_K, KEY_K)] = RGFW_k RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(46, 0x026, 37, DOM_VK_L, KEY_L)] = RGFW_l RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(58, 0x032, 46, DOM_VK_M, KEY_M)] = RGFW_m RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(57, 0x031, 45, DOM_VK_N, KEY_N)] = RGFW_n RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(32, 0x018, 31, DOM_VK_O, KEY_O)] = RGFW_o RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(33, 0x019, 35, DOM_VK_P, KEY_P)] = RGFW_p RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(24, 0x010, 12, DOM_VK_Q, KEY_Q)] = RGFW_q RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(27, 0x013, 15, DOM_VK_R, KEY_R)] = RGFW_r RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(39, 0x01F, 1, DOM_VK_S, KEY_S)] = RGFW_s RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(28, 0x014, 17, DOM_VK_T, KEY_T)] = RGFW_t RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(30, 0x016, 32, DOM_VK_U, KEY_U)] = RGFW_u RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(55, 0x02F, 9, DOM_VK_V, KEY_V)] = RGFW_v RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(25, 0x011, 13, DOM_VK_W, KEY_W)] = RGFW_w RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(53, 0x02D, 7, DOM_VK_X, KEY_X)] = RGFW_x RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(29, 0x015, 16, DOM_VK_Y, KEY_Y)] = RGFW_y RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(52, 0x02C, 6, DOM_VK_Z, KEY_Z)] = RGFW_z, - RGFW_MAP [RGFW_OS_BASED_VALUE(60, 190, 47, DOM_VK_PERIOD, KEY_DOT)] = RGFW_Period RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(59, 188, 43, DOM_VK_COMMA, KEY_COMMA)] = RGFW_Comma RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(61, 191, 44, DOM_VK_SLASH, KEY_SLASH)] = RGFW_Slash RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(34, 219, 33, DOM_VK_OPEN_BRACKET, KEY_LEFTBRACE)] = RGFW_Bracket RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(35, 221, 30, DOM_VK_CLOSE_BRACKET, KEY_RIGHTBRACE)] = RGFW_CloseBracket RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(47, 186, 41, DOM_VK_SEMICOLON, KEY_SEMICOLON)] = RGFW_Semicolon RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(48, 222, 39, DOM_VK_QUOTE, KEY_APOSTROPHE)] = RGFW_Quote RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(51, 322, 42, DOM_VK_BACK_SLASH, KEY_BACKSLASH)] = RGFW_BackSlash, + RGFW_MAP [RGFW_OS_BASED_VALUE(60, 0x034, 47, DOM_VK_PERIOD, KEY_DOT)] = RGFW_Period RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(59, 0x033, 43, DOM_VK_COMMA, KEY_COMMA)] = RGFW_Comma RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(61, 0x035, 44, DOM_VK_SLASH, KEY_SLASH)] = RGFW_Slash RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(34, 0x01A, 33, DOM_VK_OPEN_BRACKET, KEY_LEFTBRACE)] = RGFW_Bracket RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(35, 0x01B, 30, DOM_VK_CLOSE_BRACKET, KEY_RIGHTBRACE)] = RGFW_CloseBracket RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(47, 0x027, 41, DOM_VK_SEMICOLON, KEY_SEMICOLON)] = RGFW_Semicolon RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(48, 0x028, 39, DOM_VK_QUOTE, KEY_APOSTROPHE)] = RGFW_Apostrophe RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(51, 0x02B, 42, DOM_VK_BACK_SLASH, KEY_BACKSLASH)] = RGFW_BackSlash, - RGFW_MAP [RGFW_OS_BASED_VALUE(36, 0x0D, 36, DOM_VK_RETURN, KEY_ENTER)] = RGFW_Return RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(119, 0x2E, 118, DOM_VK_DELETE, KEY_DELETE)] = RGFW_Delete RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(77, 0x90, 72, DOM_VK_NUM_LOCK, KEY_NUMLOCK)] = RGFW_Numlock RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(106, 0x6F, 82, DOM_VK_DIVIDE, KEY_KPSLASH)] = RGFW_KP_Slash RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(63, 0x6A, 76, DOM_VK_MULTIPLY, KEY_KPASTERISK)] = RGFW_Multiply RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(82, 0x6D, 67, DOM_VK_SUBTRACT, KEY_KPMINUS)] = RGFW_KP_Minus RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(87, 0x61, 84, DOM_VK_NUMPAD1, KEY_KP1)] = RGFW_KP_1 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(88, 0x62, 85, DOM_VK_NUMPAD2, KEY_KP2)] = RGFW_KP_2 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(89, 0x63, 86, DOM_VK_NUMPAD3, KEY_KP3)] = RGFW_KP_3 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(83, 0x64, 87, DOM_VK_NUMPAD4, KEY_KP4)] = RGFW_KP_4 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(84, 0x65, 88, DOM_VK_NUMPAD5, KEY_KP5)] = RGFW_KP_5 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(85, 0x66, 89, DOM_VK_NUMPAD6, KEY_KP6)] = RGFW_KP_6 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(79, 0x67, 90, DOM_VK_NUMPAD7, KEY_KP7)] = RGFW_KP_7 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(80, 0x68, 92, DOM_VK_NUMPAD8, KEY_KP8)] = RGFW_KP_8 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(81, 0x69, 93, DOM_VK_NUMPAD9, KEY_KP9)] = RGFW_KP_9 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(90, 0x60, 83, DOM_VK_NUMPAD0, KEY_KP0)] = RGFW_KP_0 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(91, 0x6E, 65, DOM_VK_DECIMAL, KEY_KPDOT)] = RGFW_KP_Period RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(104, 0x92, 77, 0, KEY_KPENTER)] = RGFW_KP_Return, + RGFW_MAP [RGFW_OS_BASED_VALUE(36, 0x01C, 36, DOM_VK_RETURN, KEY_ENTER)] = RGFW_Return RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(119, 0x153, 118, DOM_VK_DELETE, KEY_DELETE)] = RGFW_Delete RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(77, 0x145, 72, DOM_VK_NUM_LOCK, KEY_NUMLOCK)] = RGFW_Numlock RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(106, 0x135, 82, DOM_VK_DIVIDE, KEY_KPSLASH)] = RGFW_KP_Slash RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(63, 0x037, 76, DOM_VK_MULTIPLY, KEY_KPASTERISK)] = RGFW_Multiply RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(82, 0x04A, 67, DOM_VK_SUBTRACT, KEY_KPMINUS)] = RGFW_KP_Minus RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(87, 0x04F, 84, DOM_VK_NUMPAD1, KEY_KP1)] = RGFW_KP_1 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(88, 0x050, 85, DOM_VK_NUMPAD2, KEY_KP2)] = RGFW_KP_2 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(89, 0x051, 86, DOM_VK_NUMPAD3, KEY_KP3)] = RGFW_KP_3 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(83, 0x04B, 87, DOM_VK_NUMPAD4, KEY_KP4)] = RGFW_KP_4 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(84, 0x04C, 88, DOM_VK_NUMPAD5, KEY_KP5)] = RGFW_KP_5 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(85, 0x04D, 89, DOM_VK_NUMPAD6, KEY_KP6)] = RGFW_KP_6 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(79, 0x047, 90, DOM_VK_NUMPAD7, KEY_KP7)] = RGFW_KP_7 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(80, 0x048, 92, DOM_VK_NUMPAD8, KEY_KP8)] = RGFW_KP_8 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(81, 0x049, 93, DOM_VK_NUMPAD9, KEY_KP9)] = RGFW_KP_9 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(90, 0x052, 83, DOM_VK_NUMPAD0, KEY_KP0)] = RGFW_KP_0 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(91, 0x053, 65, DOM_VK_DECIMAL, KEY_KPDOT)] = RGFW_KP_Period RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(104, 0x11C, 77, 0, KEY_KPENTER)] = RGFW_KP_Return, - RGFW_MAP [RGFW_OS_BASED_VALUE(20, 189, 27, DOM_VK_HYPHEN_MINUS, KEY_MINUS)] = RGFW_Minus RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(21, 187, 24, DOM_VK_EQUALS, KEY_EQUAL)] = RGFW_Equals RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(22, 8, 51, DOM_VK_BACK_SPACE, KEY_BACKSPACE)] = RGFW_BackSpace RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(23, 0x09, 48, DOM_VK_TAB, KEY_TAB)] = RGFW_Tab RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(66, 20, 57, DOM_VK_CAPS_LOCK, KEY_CAPSLOCK)] = RGFW_CapsLock RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(50, 0x10, 56, DOM_VK_SHIFT, KEY_LEFTSHIFT)] = RGFW_ShiftL RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(37, 0x11, 59, DOM_VK_CONTROL, KEY_LEFTCTRL)] = RGFW_ControlL RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(64,0x12, 58, DOM_VK_ALT, KEY_LEFTALT)] = RGFW_AltL RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(133, 0x5B, 55, DOM_VK_WIN, KEY_LEFTMETA)] = RGFW_SuperL, + RGFW_MAP [RGFW_OS_BASED_VALUE(20, 0x00C, 27, DOM_VK_HYPHEN_MINUS, KEY_MINUS)] = RGFW_Minus RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(21, 0x00D, 24, DOM_VK_EQUALS, KEY_EQUAL)] = RGFW_Equals RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(22, 0x00E, 51, DOM_VK_BACK_SPACE, KEY_BACKSPACE)] = RGFW_BackSpace RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(23, 0x00F, 48, DOM_VK_TAB, KEY_TAB)] = RGFW_Tab RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(66, 0x03A, 57, DOM_VK_CAPS_LOCK, KEY_CAPSLOCK)] = RGFW_CapsLock RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(50, 0x02A, 56, DOM_VK_SHIFT, KEY_LEFTSHIFT)] = RGFW_ShiftL RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(37, 0x01D, 59, DOM_VK_CONTROL, KEY_LEFTCTRL)] = RGFW_ControlL RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(64, 0x038, 58, DOM_VK_ALT, KEY_LEFTALT)] = RGFW_AltL RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(133, 0x15B, 55, DOM_VK_WIN, KEY_LEFTMETA)] = RGFW_SuperL, - #if !defined(RGFW_WINDOWS) && !defined(RGFW_MACOS) && !defined(RGFW_WEBASM) - RGFW_MAP [RGFW_OS_BASED_VALUE(105, 0x11, 59, 0, KEY_RIGHTCTRL)] = RGFW_ControlR RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(135, 0xA4, 55, 0, KEY_RIGHTMETA)] = RGFW_SuperR, - RGFW_MAP [RGFW_OS_BASED_VALUE(62, 0x5C, 56, 0, KEY_RIGHTSHIFT)] = RGFW_ShiftR RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(108, 165, 58, 0, KEY_RIGHTALT)] = RGFW_AltR, + #if !defined(RGFW_MACOS) && !defined(RGFW_WEBASM) + RGFW_MAP [RGFW_OS_BASED_VALUE(105, 0x11D, 59, 0, KEY_RIGHTCTRL)] = RGFW_ControlR RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(135, 0x15C, 55, 0, KEY_RIGHTMETA)] = RGFW_SuperR, + RGFW_MAP [RGFW_OS_BASED_VALUE(62, 0x036, 56, 0, KEY_RIGHTSHIFT)] = RGFW_ShiftR RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(108, 0x138, 58, 0, KEY_RIGHTALT)] = RGFW_AltR, #endif - RGFW_MAP [RGFW_OS_BASED_VALUE(67, 0x70, 127, DOM_VK_F1, KEY_F1)] = RGFW_F1 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(68, 0x71, 121, DOM_VK_F2, KEY_F2)] = RGFW_F2 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(69, 0x72, 100, DOM_VK_F3, KEY_F3)] = RGFW_F3 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(70, 0x73, 119, DOM_VK_F4, KEY_F4)] = RGFW_F4 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(71, 0x74, 97, DOM_VK_F5, KEY_F5)] = RGFW_F5 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(72, 0x75, 98, DOM_VK_F6, KEY_F6)] = RGFW_F6 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(73, 0x76, 99, DOM_VK_F7, KEY_F7)] = RGFW_F7 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(74, 0x77, 101, DOM_VK_F8, KEY_F8)] = RGFW_F8 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(75, 0x78, 102, DOM_VK_F9, KEY_F9)] = RGFW_F9 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(76, 0x79, 110, DOM_VK_F10, KEY_F10)] = RGFW_F10 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(95, 0x7A, 104, DOM_VK_F11, KEY_F11)] = RGFW_F11 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(96, 0x7B, 112, DOM_VK_F12, KEY_F12)] = RGFW_F12 RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(111, 0x26, 126, DOM_VK_UP, KEY_UP)] = RGFW_Up RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(116, 0x28, 125, DOM_VK_DOWN, KEY_DOWN)] = RGFW_Down RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(113, 0x25, 123, DOM_VK_LEFT, KEY_LEFT)] = RGFW_Left RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(114, 0x27, 124, DOM_VK_RIGHT, KEY_RIGHT)] = RGFW_Right RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(118, 0x2D, 115, DOM_VK_INSERT, KEY_INSERT)] = RGFW_Insert RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(115, 0x23, 120, DOM_VK_END, KEY_END)] = RGFW_End RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(112, 336, 117, DOM_VK_PAGE_UP, KEY_PAGEUP)] = RGFW_PageUp RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(117, 325, 122, DOM_VK_PAGE_DOWN, KEY_PAGEDOWN)] = RGFW_PageDown RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(9, 0x1B, 53, DOM_VK_ESCAPE, KEY_ESC)] = RGFW_Escape RGFW_NEXT - RGFW_MAP [RGFW_OS_BASED_VALUE(110, 0x24, 116, DOM_VK_HOME, KEY_HOME)] = RGFW_Home RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(67, 0x03B, 127, DOM_VK_F1, KEY_F1)] = RGFW_F1 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(68, 0x03C, 121, DOM_VK_F2, KEY_F2)] = RGFW_F2 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(69, 0x03D, 100, DOM_VK_F3, KEY_F3)] = RGFW_F3 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(70, 0x03E, 119, DOM_VK_F4, KEY_F4)] = RGFW_F4 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(71, 0x03F, 97, DOM_VK_F5, KEY_F5)] = RGFW_F5 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(72, 0x040, 98, DOM_VK_F6, KEY_F6)] = RGFW_F6 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(73, 0x041, 99, DOM_VK_F7, KEY_F7)] = RGFW_F7 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(74, 0x042, 101, DOM_VK_F8, KEY_F8)] = RGFW_F8 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(75, 0x043, 102, DOM_VK_F9, KEY_F9)] = RGFW_F9 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(76, 0x044, 110, DOM_VK_F10, KEY_F10)] = RGFW_F10 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(95, 0x057, 104, DOM_VK_F11, KEY_F11)] = RGFW_F11 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(96, 0x058, 112, DOM_VK_F12, KEY_F12)] = RGFW_F12 RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(111, 0x148, 126, DOM_VK_UP, KEY_UP)] = RGFW_Up RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(116, 0x150, 125, DOM_VK_DOWN, KEY_DOWN)] = RGFW_Down RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(113, 0x14B, 123, DOM_VK_LEFT, KEY_LEFT)] = RGFW_Left RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(114, 0x14D, 124, DOM_VK_RIGHT, KEY_RIGHT)] = RGFW_Right RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(118, 0x152, 115, DOM_VK_INSERT, KEY_INSERT)] = RGFW_Insert RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(115, 0x14F, 120, DOM_VK_END, KEY_END)] = RGFW_End RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(112, 0x149, 117, DOM_VK_PAGE_UP, KEY_PAGEUP)] = RGFW_PageUp RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(117, 0x151, 122, DOM_VK_PAGE_DOWN, KEY_PAGEDOWN)] = RGFW_PageDown RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(9, 0x001, 53, DOM_VK_ESCAPE, KEY_ESC)] = RGFW_Escape RGFW_NEXT + RGFW_MAP [RGFW_OS_BASED_VALUE(110, 0x147, 116, DOM_VK_HOME, KEY_HOME)] = RGFW_Home RGFW_NEXT #ifndef __cplusplus }; #else @@ -1394,9 +1384,9 @@ typedef struct { RGFW_keyState RGFW_keyboard[final_key] = { {0, 0} }; -RGFWDEF u32 RGFW_apiKeyCodeToRGFW(u32 keycode); +RGFWDEF u32 RGFW_apiKeyToRGFW(u32 keycode); -u32 RGFW_apiKeyCodeToRGFW(u32 keycode) { +u32 RGFW_apiKeyToRGFW(u32 keycode) { #ifdef __cplusplus if (RGFW_OS_BASED_VALUE(49, 192, 50, DOM_VK_BACK_QUOTE, KEY_GRAVE) != RGFW_Backtick) { RGFW_init_keys(); @@ -1419,38 +1409,6 @@ void RGFW_resetKey(void) { RGFW_keyboard[i].prev = 0; } -b8 RGFW_shouldShift(u32 keycode, u8 lockState) { - #define RGFW_xor(x, y) (( (x) && (!(y)) ) || ((y) && (!(x)) )) - b8 caps4caps = (lockState & RGFW_CAPSLOCK) && ((keycode >= RGFW_a) && (keycode <= RGFW_z)); - b8 shouldShift = RGFW_xor((RGFW_isPressed(NULL, RGFW_ShiftL) || RGFW_isPressed(NULL, RGFW_ShiftR)), caps4caps); - #undef RGFW_xor - - return shouldShift; -} - -char RGFW_keyCodeToChar(u32 keycode, b8 shift) { - static const char map[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '`', '0', '1', '2', '3', '4', '5', '6', '7', '8', - '9', '-', '=', 0, '\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', ',', '/', '[', ']', ';', '\n', '\'', '\\', - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', '*', '-', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\n' - }; - - static const char mapCaps[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '~', ')', '!', '@', '#', '$', '%', '^', '&', '*', - '(', '_', '+', 0, '0', 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', '>', '<', '?', '{', '}', ':', '\n', '"', '|', - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '?', '*', '-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - if (shift == RGFW_FALSE) - return map[keycode]; - return mapCaps[keycode]; -} - -char RGFW_keyCodeToCharAuto(u32 keycode, u8 lockState) { return RGFW_keyCodeToChar(keycode, RGFW_shouldShift(keycode, lockState)); } - /* this is the end of keycode data */ @@ -1479,7 +1437,7 @@ void RGFW_mouseNotifyfuncEMPTY(RGFW_window* win, RGFW_point point, b8 status) {R void RGFW_mouseposfuncEMPTY(RGFW_window* win, RGFW_point point) {RGFW_UNUSED(win); RGFW_UNUSED(point);} void RGFW_dndInitfuncEMPTY(RGFW_window* win, RGFW_point point) {RGFW_UNUSED(win); RGFW_UNUSED(point);} void RGFW_windowrefreshfuncEMPTY(RGFW_window* win) {RGFW_UNUSED(win); } -void RGFW_keyfuncEMPTY(RGFW_window* win, u32 keycode, char keyName[16], u8 lockState, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(keycode); RGFW_UNUSED(keyName); RGFW_UNUSED(lockState); RGFW_UNUSED(pressed);} +void RGFW_keyfuncEMPTY(RGFW_window* win, u32 key, u32 mappedKey, char keyName[16], u8 lockState, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(key); RGFW_UNUSED(mappedKey); RGFW_UNUSED(keyName); RGFW_UNUSED(lockState); RGFW_UNUSED(pressed);} void RGFW_mousebuttonfuncEMPTY(RGFW_window* win, u8 button, double scroll, b8 pressed) {RGFW_UNUSED(win); RGFW_UNUSED(button); RGFW_UNUSED(scroll); RGFW_UNUSED(pressed);} void RGFW_gpButtonfuncEMPTY(RGFW_window* win, u16 gamepad, u8 button, b8 pressed){RGFW_UNUSED(win); RGFW_UNUSED(gamepad); RGFW_UNUSED(button); RGFW_UNUSED(pressed); } void RGFW_gpAxisfuncEMPTY(RGFW_window* win, u16 gamepad, RGFW_point axis[2], u8 axisesCount){RGFW_UNUSED(win); RGFW_UNUSED(gamepad); RGFW_UNUSED(axis); RGFW_UNUSED(axisesCount); } @@ -1959,7 +1917,7 @@ void RGFW_updateLockState(RGFW_window* win, b8 capital, b8 numlock) { MacOS and Windows do this using a structure called a "pixel format" X11 calls it a "Visual" This function returns the attributes for the format we want */ - static u32* RGFW_initFormatAttribs(u32 useSoftware) { + u32* RGFW_initFormatAttribs(u32 useSoftware) { RGFW_UNUSED(useSoftware); static u32 attribs[] = { #if defined(RGFW_X11) || defined(RGFW_WINDOWS) @@ -2422,6 +2380,10 @@ Start of Linux / Unix defines win->buffer = (u8*)RGFW_MALLOC(RGFW_bufferSize.w * RGFW_bufferSize.h * 4); + #ifdef RGFW_DEBUG + printf("RGFW INFO: createing a 4 channel %i by %i buffer\n", RGFW_bufferSize.w, RGFW_bufferSize.h); + #endif + #ifdef RGFW_OSMESA win->src.ctx = OSMesaCreateContext(OSMESA_RGBA, NULL); OSMesaMakeCurrent(win->src.ctx, win->buffer, GL_UNSIGNED_BYTE, win->r.w, win->r.h); @@ -2489,7 +2451,6 @@ Start of Linux / Unix defines XISelectEvents(win->src.display, XDefaultRootWindow(win->src.display), &em, 1); XGrabPointer(win->src.display, win->src.window, True, PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); - RGFW_window_moveMouse(win, RGFW_POINT(win->r.x + (i32)(r.w / 2), win->r.y + (i32)(r.h / 2))); } @@ -2739,6 +2700,10 @@ Start of Linux / Unix defines RGFW_windowsOpen++; + #ifdef RGFW_DEBUG + printf("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n", win->r.x, win->r.y, win->r.w, win->r.h); + #endif + return win; /*return newly created window*/ } @@ -2831,8 +2796,10 @@ Start of Linux / Unix defines } /* set event key data */ + win->event.key = RGFW_apiKeyToRGFW(E.xkey.keycode); + KeySym sym = (KeySym)XkbKeycodeToKeysym((Display*) win->src.display, E.xkey.keycode, 0, E.xkey.state & ShiftMask ? 1 : 0); - win->event.keyCode = RGFW_apiKeyCodeToRGFW(E.xkey.keycode); + win->event.keyChar = (u8)sym; char* str = (char*)XKeysymToString(sym); if (str != NULL) @@ -2840,7 +2807,7 @@ Start of Linux / Unix defines win->event.keyName[15] = '\0'; - RGFW_keyboard[win->event.keyCode].prev = RGFW_isPressed(win, win->event.keyCode); + RGFW_keyboard[win->event.key].prev = RGFW_isPressed(win, win->event.key); /* get keystate data */ win->event.type = (E.type == KeyPress) ? RGFW_keyPressed : RGFW_keyReleased; @@ -2849,14 +2816,15 @@ Start of Linux / Unix defines XGetKeyboardControl((Display*) win->src.display, &keystate); RGFW_updateLockState(win, (keystate.led_mask & 1), (keystate.led_mask & 2)); - RGFW_keyboard[win->event.keyCode].current = (E.type == KeyPress); - RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, (E.type == KeyPress)); + RGFW_keyboard[win->event.key].current = (E.type == KeyPress); + RGFW_keyCallback(win, win->event.key, win->event.keyChar, win->event.keyName, win->event.lockState, (E.type == KeyPress)); break; } case ButtonPress: case ButtonRelease: win->event.type = RGFW_mouseButtonPressed + (E.type == ButtonRelease); // the events match + win->event.button = E.xbutton.button; switch(win->event.button) { case RGFW_mouseScrollUp: win->event.scroll = 1; @@ -2866,12 +2834,11 @@ Start of Linux / Unix defines break; default: break; } - - win->event.button = E.xbutton.button; + RGFW_mouseButtons[win->event.button].prev = RGFW_mouseButtons[win->event.button].current; if (win->event.repeat == RGFW_FALSE) - win->event.repeat = RGFW_isPressed(win, win->event.keyCode); + win->event.repeat = RGFW_isPressed(win, win->event.key); RGFW_mouseButtons[win->event.button].current = (E.type == ButtonPress); RGFW_mouseButtonCallback(win, win->event.button, win->event.scroll, (E.type == ButtonPress)); @@ -2884,8 +2851,8 @@ Start of Linux / Unix defines if ((win->_winArgs & RGFW_HOLD_MOUSE)) { win->event.point.y = E.xmotion.y; - win->event.point.x = win->_lastMousePoint.x - abs(win->event.point.x); - win->event.point.y = win->_lastMousePoint.y - abs(win->event.point.y); + win->event.point.x = win->event.point.x - win->_lastMousePoint.x; + win->event.point.y = win->event.point.y - win->_lastMousePoint.y; } win->_lastMousePoint = RGFW_POINT(E.xmotion.x, E.xmotion.y); @@ -3217,9 +3184,9 @@ Start of Linux / Unix defines break; } - default: { - break; - } + default: + XFlush((Display*) win->src.display); + return RGFW_window_checkEvent(win); } XFlush((Display*) win->src.display); @@ -3432,7 +3399,7 @@ Start of Linux / Unix defines #endif } - void RGFW_window_moveMouse(RGFW_window* win, RGFW_point v) { + void RGFW_window_moveMouse(RGFW_window* win, RGFW_point p) { assert(win != NULL); XEvent event; @@ -3442,10 +3409,11 @@ Start of Linux / Unix defines &event.xbutton.x, &event.xbutton.y, &event.xbutton.state); - if (event.xbutton.x == v.x && event.xbutton.y == v.y) + win->_lastMousePoint = RGFW_POINT(p.x - win->r.x, p.y - win->r.y); + if (event.xbutton.x == p.x && event.xbutton.y == p.y) return; - XWarpPointer(win->src.display, None, win->src.window, 0, 0, 0, 0, (int) v.x - win->r.x, (int) v.y - win->r.y); + XWarpPointer(win->src.display, None, win->src.window, 0, 0, 0, 0, (int) p.x - win->r.x, (int) p.y - win->r.y); } RGFWDEF void RGFW_window_disableMouse(RGFW_window* win) { @@ -3783,6 +3751,10 @@ Start of Linux / Unix defines monitor.scaleY = (float) (dpi_height) / (float) 96; XRRFreeScreenResources(sr); XCloseDisplay(display); + + #ifdef RGFW_DEBUG + printf("RGFW INFO: monitor found: scale (%s):\n rect: {%i, %i, %i, %i}\n physical size:%f %f\n scale: %f %f\n", monitor.name, monitor.rect.x, monitor.rect.y, monitor.rect.w, monitor.rect.h, monitor.physW, monitor.physH, monitor.scaleX, monitor.scaleY); + #endif return monitor; } @@ -3812,6 +3784,10 @@ Start of Linux / Unix defines XCloseDisplay(display); + #ifdef RGFW_DEBUG + printf("RGFW INFO: monitor found: scale (%s):\n rect: {%i, %i, %i, %i}\n physical size:%f %f\n scale: %f %f\n", monitor.name, monitor.rect.x, monitor.rect.y, monitor.rect.w, monitor.rect.h, monitor.physW, monitor.physH, monitor.scaleX, monitor.scaleY); + #endif + return monitor; } @@ -4421,19 +4397,20 @@ static void keyboard_key (void *data, struct wl_keyboard *keyboard, uint32_t ser char name[16]; xkb_keysym_get_name(keysym, name, 16); - u32 RGFW_key = RGFW_apiKeyCodeToRGFW(key); + u32 RGFW_key = RGFW_apiKeyToRGFW(key); RGFW_keyboard[RGFW_key].prev = RGFW_keyboard[RGFW_key].current; RGFW_keyboard[RGFW_key].current = state; RGFW_Event ev; ev.type = RGFW_keyPressed + state; - ev.keyCode = RGFW_key; + ev.key = RGFW_key; + ev.keyChar = (u8)keysym; strcpy(ev.keyName, name); ev.repeat = RGFW_isHeld(RGFW_key_win, RGFW_key); RGFW_eventPipe_push(RGFW_key_win, ev); RGFW_updateLockState(RGFW_key_win, xkb_keymap_mod_get_index(keymap, "Lock"), xkb_keymap_mod_get_index(keymap, "Mod2")); - RGFW_keyCallback(RGFW_key_win, RGFW_key, name, RGFW_key_win->event.lockState, state); + RGFW_keyCallback(RGFW_key_win, RGFW_key, (u8)keysym, name, RGFW_key_win->event.lockState, state); } static void keyboard_modifiers (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { RGFW_UNUSED(data); RGFW_UNUSED(keyboard); RGFW_UNUSED(serial); RGFW_UNUSED(time); @@ -4563,6 +4540,8 @@ int create_shm_file(off_t size) { } static void wl_surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) { + RGFW_UNUSED(data); RGFW_UNUSED(cb); RGFW_UNUSED(time); + #ifdef RGFW_BUFFER RGFW_window* win = (RGFW_window*)data; if ((win->_winArgs & RGFW_NO_CPU_RENDER)) @@ -4608,11 +4587,13 @@ static const struct wl_callback_listener wl_surface_frame_listener = { void RGFW_releaseCursor(RGFW_window* win) { RGFW_UNUSED(win); + + /* TODO wayland */ } void RGFW_captureCursor(RGFW_window* win, RGFW_rect r) { RGFW_UNUSED(win); RGFW_UNUSED(r); - + /* TODO wayland */ } @@ -4764,6 +4745,10 @@ static const struct wl_callback_listener wl_surface_frame_listener = { win->src.eventIndex = 0; win->src.eventLen = 0; + + #ifdef RGFW_DEBUG + printf("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n", win->r.x, win->r.y, win->r.w, win->r.h); + #endif return win; } @@ -4812,8 +4797,20 @@ static const struct wl_callback_listener wl_surface_frame_listener = { void RGFW_window_move(RGFW_window* win, RGFW_point v) { RGFW_UNUSED(win); RGFW_UNUSED(v); - + /* TODO wayland */ + assert(win != NULL); + struct wl_pointer *pointer = wl_seat_get_pointer(win->seat); + if (!pointer) { + return; + } + + // Initiate the move operation + wl_shell_surface_move(win->shell_surface, pointer, win->serial); + win->r.x = v.x; + win->r.y = v.y; + + wl_display_flush(win->display); } void RGFW_window_setIcon(RGFW_window* win, u8* src, RGFW_area a, i32 channels) { @@ -4821,9 +4818,11 @@ static const struct wl_callback_listener wl_surface_frame_listener = { /* TODO wayland */ } - void RGFW_window_moveMouse(RGFW_window* win, RGFW_point v) { - RGFW_UNUSED(win); RGFW_UNUSED(v); - + void RGFW_window_moveMouse(RGFW_window* win, RGFW_point p) { + win->_lastMousePoint = RGFW_POINT(p.x - win->r.x, p.y - win->r.y); + #ifdef RGFW_DEBUG + printf("Wayland: The platform does not support moving the mouse\n"); + #endif /* TODO wayland */ } @@ -5206,7 +5205,7 @@ static HMODULE wglinstance = NULL; return DefWindowProcA(hWnd, message, wParam, lParam); } } - + #ifndef RGFW_NO_DPI static HMODULE RGFW_Shcore_dll = NULL; typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*); @@ -5363,9 +5362,9 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ Class.hCursor = LoadCursor(NULL, IDC_ARROW); Class.lpfnWndProc = WndProc; - Class.hIcon = LoadImageA(GetModuleHandleW(NULL), "RGFW_ICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + Class.hIcon = (HICON)LoadImageA(GetModuleHandleW(NULL), "RGFW_ICON", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); if (Class.hIcon == NULL) { - Class.hIcon = LoadImageA(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + Class.hIcon = (HICON)LoadImageA(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); } RegisterClassA(&Class); @@ -5606,6 +5605,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ wglShareLists(RGFW_root->src.ctx, win->src.ctx); #endif + #ifdef RGFW_DEBUG + printf("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n", win->r.x, win->r.y, win->r.w, win->r.h); + #endif + return win; } @@ -5848,9 +5851,19 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ return &win->event; static BYTE keyboardState[256]; + GetKeyboardState(keyboardState); - if (PeekMessageA(&msg, win->src.window, 0u, 0u, PM_REMOVE)) { - switch (msg.message) { + + if (!IsWindow(win->src.window)) { + win->event.type = RGFW_quit; + RGFW_windowQuitCallback(win); + return &win->event; + } + + if (PeekMessageA(&msg, win->src.window, 0u, 0u, PM_REMOVE) == 0) + return NULL; + + switch (msg.message) { case WM_CLOSE: case WM_QUIT: RGFW_windowQuitCallback(win); @@ -5883,15 +5896,36 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ break; case WM_KEYUP: { - win->event.keyCode = RGFW_apiKeyCodeToRGFW((u32) msg.wParam); - - RGFW_keyboard[win->event.keyCode].prev = RGFW_isPressed(win, win->event.keyCode); + i32 scancode = (HIWORD(msg.lParam) & (KF_EXTENDED | 0xff)); + if (scancode == 0) + scancode = MapVirtualKeyW((u32)msg.wParam, MAPVK_VK_TO_VSC); + + switch (scancode) { + case 0x54: scancode = 0x137; break; /* Alt+PrtS */ + case 0x146: scancode = 0x45; break; /* Ctrl+Pause */ + case 0x136: scancode = 0x36; break; /* CJK IME sets the extended bit for right Shift */ + default: break; + } + + win->event.key = RGFW_apiKeyToRGFW((u32) scancode); + + if (msg.wParam == VK_CONTROL) { + if (HIWORD(msg.lParam) & KF_EXTENDED) + win->event.key = RGFW_ControlR; + else win->event.key = RGFW_ControlL; + } + + wchar_t charBuffer; + ToUnicodeEx(msg.wParam, scancode, keyboardState, (wchar_t*)&charBuffer, 1, 0, NULL); + + win->event.keyChar = (u8)charBuffer; + + RGFW_keyboard[win->event.key].prev = RGFW_isPressed(win, win->event.key); static char keyName[16]; { GetKeyNameTextA((LONG) msg.lParam, keyName, 16); - if ((!(GetKeyState(VK_CAPITAL) & 0x0001) && !(GetKeyState(VK_SHIFT) & 0x8000)) || ((GetKeyState(VK_CAPITAL) & 0x0001) && (GetKeyState(VK_SHIFT) & 0x8000))) { CharLowerBuffA(keyName, 16); @@ -5908,14 +5942,35 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ } win->event.type = RGFW_keyReleased; - RGFW_keyboard[win->event.keyCode].current = 0; - RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, 0); + RGFW_keyboard[win->event.key].current = 0; + RGFW_keyCallback(win, win->event.key, win->event.keyChar, win->event.keyName, win->event.lockState, 0); break; } case WM_KEYDOWN: { - win->event.keyCode = RGFW_apiKeyCodeToRGFW((u32) msg.wParam); + i32 scancode = (HIWORD(msg.lParam) & (KF_EXTENDED | 0xff)); + if (scancode == 0) + scancode = MapVirtualKeyW((u32)msg.wParam, MAPVK_VK_TO_VSC); - RGFW_keyboard[win->event.keyCode].prev = RGFW_isPressed(win, win->event.keyCode); + switch (scancode) { + case 0x54: scancode = 0x137; break; /* Alt+PrtS */ + case 0x146: scancode = 0x45; break; /* Ctrl+Pause */ + case 0x136: scancode = 0x36; break; /* CJK IME sets the extended bit for right Shift */ + default: break; + } + + win->event.key = RGFW_apiKeyToRGFW((u32) scancode); + + if (msg.wParam == VK_CONTROL) { + if (HIWORD(msg.lParam) & KF_EXTENDED) + win->event.key = RGFW_ControlR; + else win->event.key = RGFW_ControlL; + } + + wchar_t charBuffer; + ToUnicodeEx(msg.wParam, scancode, keyboardState, &charBuffer, 1, 0, NULL); + win->event.keyChar = (u8)charBuffer; + + RGFW_keyboard[win->event.key].prev = RGFW_isPressed(win, win->event.key); static char keyName[16]; @@ -5938,20 +5993,20 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ } win->event.type = RGFW_keyPressed; - win->event.repeat = RGFW_isPressed(win, win->event.keyCode); - RGFW_keyboard[win->event.keyCode].current = 1; - RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, 1); + win->event.repeat = RGFW_isPressed(win, win->event.key); + RGFW_keyboard[win->event.key].current = 1; + RGFW_keyCallback(win, win->event.key, win->event.keyChar, win->event.keyName, win->event.lockState, 1); break; } - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: { if ((win->_winArgs & RGFW_HOLD_MOUSE)) break; win->event.type = RGFW_mousePosChanged; - win->event.point.x = GET_X_LPARAM(msg.lParam); - win->event.point.y = GET_Y_LPARAM(msg.lParam); + i32 x = GET_X_LPARAM(msg.lParam); + i32 y = GET_Y_LPARAM(msg.lParam); RGFW_mousePosCallback(win, win->event.point); @@ -5961,22 +6016,64 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ RGFW_mouseNotifyCallBack(win, win->event.point, 1); } - break; + /*if ((win->_winArgs & RGFW_HOLD_MOUSE)) { + RGFW_point p = RGFW_getGlobalMousePoint(); + //p = RGFW_POINT(p.x + win->r.x, p.y + win->r.y); + win->event.point.x = x - win->_lastMousePoint.x; + win->event.point.y = y - win->_lastMousePoint.y; + + win->_lastMousePoint = RGFW_POINT(x, y); + break; + }*/ + + win->event.point.x = x; + win->event.point.y = y; + win->_lastMousePoint = RGFW_POINT(x, y); + + break; + } case WM_INPUT: { if (!(win->_winArgs & RGFW_HOLD_MOUSE)) break; unsigned size = sizeof(RAWINPUT); - static RAWINPUT raw[sizeof(RAWINPUT)]; - GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, raw, &size, sizeof(RAWINPUTHEADER)); + static RAWINPUT raw = {}; - if (raw->header.dwType != RIM_TYPEMOUSE || (raw->data.mouse.lLastX == 0 && raw->data.mouse.lLastY == 0) ) + GetRawInputData((HRAWINPUT)msg.lParam, RID_INPUT, &raw, &size, sizeof(RAWINPUTHEADER)); + + if (raw.header.dwType != RIM_TYPEMOUSE || (raw.data.mouse.lLastX == 0 && raw.data.mouse.lLastY == 0) ) break; - + + if (raw.data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE) { + POINT pos = {0}; + int width, height; + + if (raw.data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) { + pos.x += GetSystemMetrics(SM_XVIRTUALSCREEN); + pos.y += GetSystemMetrics(SM_YVIRTUALSCREEN); + width = GetSystemMetrics(SM_CXVIRTUALSCREEN); + height = GetSystemMetrics(SM_CYVIRTUALSCREEN); + } + else { + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + } + + pos.x += (int) ((raw.data.mouse.lLastX / 65535.f) * width); + pos.y += (int) ((raw.data.mouse.lLastY / 65535.f) * height); + ScreenToClient(win->src.window, &pos); + + win->event.point.x = pos.x - win->_lastMousePoint.x; + win->event.point.y = pos.y - win->_lastMousePoint.y; + } else { + win->event.point.x = raw.data.mouse.lLastX; + win->event.point.y = raw.data.mouse.lLastY; + } + win->event.type = RGFW_mousePosChanged; - win->event.point.x = raw->data.mouse.lLastX; - win->event.point.y = raw->data.mouse.lLastY; + win->_lastMousePoint.x += win->event.point.x; + win->_lastMousePoint.y += win->event.point.y; break; } @@ -6074,26 +6171,18 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ return 0; } default: - win->event.type = 0; + TranslateMessage(&msg); + DispatchMessageA(&msg); + + return RGFW_window_checkEvent(win); break; } TranslateMessage(&msg); DispatchMessageA(&msg); - } - else - win->event.type = 0; - if (!IsWindow(win->src.window)) { - win->event.type = RGFW_quit; - RGFW_windowQuitCallback(win); - } - - if (win->event.type) - return &win->event; - else - return NULL; + return &win->event; } u8 RGFW_window_isFullscreen(RGFW_window* win) { @@ -6208,6 +6297,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ monitor.physW = GetSystemMetrics(SM_CYSCREEN) / (float) ppiX; monitor.physH = GetSystemMetrics(SM_CXSCREEN) / (float) ppiY; + #ifdef RGFW_DEBUG + printf("RGFW INFO: monitor found: scale (%s):\n rect: {%i, %i, %i, %i}\n physical size:%f %f\n scale: %f %f\n", monitor.name, monitor.rect.x, monitor.rect.y, monitor.rect.w, monitor.rect.h, monitor.physW, monitor.physH, monitor.scaleX, monitor.scaleY); + #endif + return monitor; } #endif /* RGFW_NO_MONITOR */ @@ -6576,7 +6669,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ void RGFW_window_moveMouse(RGFW_window* win, RGFW_point p) { assert(win != NULL); - + win->_lastMousePoint = RGFW_POINT(p.x - win->r.x, p.y - win->r.y); SetCursorPos(p.x, p.y); } @@ -6738,7 +6831,6 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ typedef void NSDraggingInfo; typedef void NSWindow; typedef void NSApplication; - typedef void NSScreen; typedef void NSEvent; typedef void NSString; typedef void NSOpenGLContext; @@ -7210,7 +7302,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ return false; } - static void NSMoveToResourceDir(void) { + void NSMoveToResourceDir(void) { /* sourced from glfw */ char resourcesPath[255]; @@ -7497,6 +7589,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ NSRetain(win->src.window); NSRetain(NSApp); + #ifdef RGFW_DEBUG + printf("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n", win->r.x, win->r.y, win->r.w, win->r.h); + #endif + return win; } @@ -7663,7 +7759,8 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (e) { - objc_msgSend_void_id(NSApp, sel_registerName("sendEvent:"), e); + ((void (*)(id, SEL, id, bool))objc_msgSend) + (NSApp, sel_registerName("postEvent:atStart:"), e, 1); } objc_msgSend_bool_void(eventPool, sel_registerName("drain")); @@ -7687,8 +7784,8 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (eventFunc == NULL) eventFunc = sel_registerName("nextEventMatchingMask:untilDate:inMode:dequeue:"); - if ((win->event.type == RGFW_windowMoved || win->event.type == RGFW_windowResized || win->event.type == RGFW_windowRefresh) && win->event.keyCode != 120) { - win->event.keyCode = 120; + if ((win->event.type == RGFW_windowMoved || win->event.type == RGFW_windowResized || win->event.type == RGFW_windowRefresh) && win->event.key != 120) { + win->event.key = 120; objc_msgSend_bool_void(eventPool, sel_registerName("drain")); return &win->event; } @@ -7723,7 +7820,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ switch (objc_msgSend_uint(e, sel_registerName("type"))) { case NSEventTypeMouseEntered: { win->event.type = RGFW_mouseEnter; - NSPoint p = ((NSPoint(*)(id, SEL)) objc_msgSend)(e, sel_registerName("locationInWindow")); + NSPoint p = ((NSPoint(*)(id, SEL)) objc_msgSend)(e, sel_registerName("locationInWindow")); win->event.point = RGFW_POINT((i32) p.x, (i32) (win->r.h - p.y)); RGFW_mouseNotifyCallBack(win, win->event.point, 1); @@ -7737,31 +7834,40 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ case NSEventTypeKeyDown: { u32 key = (u16) objc_msgSend_uint(e, sel_registerName("keyCode")); - win->event.keyCode = RGFW_apiKeyCodeToRGFW(key); - RGFW_keyboard[win->event.keyCode].prev = RGFW_keyboard[win->event.keyCode].current; + + u32 mappedKey = *((u32*)((char*)(const char*) NSString_to_char(objc_msgSend_id(e, sel_registerName("charactersIgnoringModifiers"))))); + + win->event.keyChar = (u8)mappedKey; + + win->event.key = RGFW_apiKeyToRGFW(key); + RGFW_keyboard[win->event.key].prev = RGFW_keyboard[win->event.key].current; win->event.type = RGFW_keyPressed; char* str = (char*)(const char*) NSString_to_char(objc_msgSend_id(e, sel_registerName("characters"))); strncpy(win->event.keyName, str, 16); - win->event.repeat = RGFW_isPressed(win, win->event.keyCode); - RGFW_keyboard[win->event.keyCode].current = 1; + win->event.repeat = RGFW_isPressed(win, win->event.key); + RGFW_keyboard[win->event.key].current = 1; - RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, 1); + RGFW_keyCallback(win, win->event.key, win->event.keyChar, win->event.keyName, win->event.lockState, 1); break; } case NSEventTypeKeyUp: { - u32 key = (u16) objc_msgSend_uint(e, sel_registerName("keyCode")); - win->event.keyCode = RGFW_apiKeyCodeToRGFW(key);; - - RGFW_keyboard[win->event.keyCode].prev = RGFW_keyboard[win->event.keyCode].current; + u32 key = (u16) objc_msgSend_uint(e, sel_registerName("keyCode")); + + u32 mappedKey = *((u32*)((char*)(const char*) NSString_to_char(objc_msgSend_id(e, sel_registerName("charactersIgnoringModifiers"))))); + win->event.keyChar = (u8)mappedKey; + + win->event.key = RGFW_apiKeyToRGFW(key); + + RGFW_keyboard[win->event.key].prev = RGFW_keyboard[win->event.key].current; win->event.type = RGFW_keyReleased; char* str = (char*)(const char*) NSString_to_char(objc_msgSend_id(e, sel_registerName("characters"))); strncpy(win->event.keyName, str, 16); - RGFW_keyboard[win->event.keyCode].current = 0; - RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, 0); + RGFW_keyboard[win->event.key].current = 0; + RGFW_keyCallback(win, win->event.key, win->event.keyChar, win->event.keyName, win->event.lockState, 0); break; } @@ -7784,7 +7890,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ RGFW_keyboard[key+ 4].current = 1; win->event.type = RGFW_keyPressed; - win->event.keyCode = key; + win->event.key = key; break; } @@ -7795,12 +7901,12 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ RGFW_keyboard[key + 4].current = 0; win->event.type = RGFW_keyReleased; - win->event.keyCode = key; + win->event.key = key; break; } } - RGFW_keyCallback(win, win->event.keyCode, win->event.keyName, win->event.lockState, win->event.type == RGFW_keyPressed); + RGFW_keyCallback(win, win->event.key, win->event.keyChar, win->event.keyName, win->event.lockState, win->event.type == RGFW_keyPressed); break; } @@ -7890,8 +7996,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ break; } - default: - break; + default: return RGFW_window_checkEvent(win); } objc_msgSend_void_id(NSApp, sel_registerName("sendEvent:"), e); @@ -8057,7 +8162,8 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ void RGFW_window_moveMouse(RGFW_window* win, RGFW_point v) { RGFW_UNUSED(win); - + + win->_lastMousePoint = RGFW_POINT(v.x - win->r.x, v.y - win->r.y); CGWarpMouseCursorPosition(CGPointMake(v.x, v.y)); } @@ -8097,7 +8203,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ return objc_msgSend_bool(win->src.window, sel_registerName("isZoomed")); } - static RGFW_monitor RGFW_NSCreateMonitor(CGDirectDisplayID display) { + RGFW_monitor RGFW_NSCreateMonitor(CGDirectDisplayID display) { RGFW_monitor monitor; CGRect bounds = CGDisplayBounds(display); @@ -8111,7 +8217,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ float dpi_height = round((double)monitor.rect.h/(double)monitor.physH); monitor.scaleX = (float) (dpi_width) / (float) 96; - monitor.scaleY = (float) (dpi_height) / (float) 96; + monitor.scaleY = (float) (dpi_height) / (float) 96; if (isinf(monitor.scaleX) || (monitor.scaleX > 1 && monitor.scaleX < 1.1)) monitor.scaleX = 1; @@ -8119,11 +8225,15 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ if (isinf(monitor.scaleY) || (monitor.scaleY > 1 && monitor.scaleY < 1.1)) monitor.scaleY = 1; + #ifdef RGFW_DEBUG + printf("RGFW INFO: monitor found: scale (%s):\n rect: {%i, %i, %i, %i}\n physical size:%f %f\n scale: %f %f\n", monitor.name, monitor.rect.x, monitor.rect.y, monitor.rect.w, monitor.rect.h, monitor.physW, monitor.physH, monitor.scaleX, monitor.scaleY); + #endif + return monitor; } - static RGFW_monitor RGFW_monitors[7]; + RGFW_monitor RGFW_monitors[7]; RGFW_monitor* RGFW_getMonitors(void) { static CGDirectDisplayID displays[7]; @@ -8334,39 +8444,6 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */ RGFW_Event RGFW_events[20]; size_t RGFW_eventLen = 0; -EM_BOOL Emscripten_on_keydown(int eventType, const EmscriptenKeyboardEvent* e, void* userData) { - RGFW_UNUSED(eventType); RGFW_UNUSED(userData); - - RGFW_events[RGFW_eventLen].type = RGFW_keyPressed; - memcpy(RGFW_events[RGFW_eventLen].keyName, e->key, 16); - RGFW_events[RGFW_eventLen].keyCode = RGFW_apiKeyCodeToRGFW(e->keyCode); - RGFW_events[RGFW_eventLen].lockState = 0; - RGFW_eventLen++; - - RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].prev = RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].current; - RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].current = 1; - RGFW_keyCallback(RGFW_root, RGFW_apiKeyCodeToRGFW(e->keyCode), RGFW_events[RGFW_eventLen].keyName, 0, 1); - - return EM_TRUE; -} - -EM_BOOL Emscripten_on_keyup(int eventType, const EmscriptenKeyboardEvent* e, void* userData) { - RGFW_UNUSED(eventType); RGFW_UNUSED(userData); - - RGFW_events[RGFW_eventLen].type = RGFW_keyReleased; - memcpy(RGFW_events[RGFW_eventLen].keyName, e->key, 16); - RGFW_events[RGFW_eventLen].keyCode = RGFW_apiKeyCodeToRGFW(e->keyCode); - RGFW_events[RGFW_eventLen].lockState = 0; - RGFW_eventLen++; - - RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].prev = RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].current; - RGFW_keyboard[RGFW_apiKeyCodeToRGFW(e->keyCode)].current = 0; - - RGFW_keyCallback(RGFW_root, RGFW_apiKeyCodeToRGFW(e->keyCode), RGFW_events[RGFW_eventLen].keyName, 0, 0); - - return EM_TRUE; -} - EM_BOOL Emscripten_on_resize(int eventType, const EmscriptenUiEvent* e, void* userData) { RGFW_UNUSED(eventType); RGFW_UNUSED(userData); @@ -8395,7 +8472,7 @@ EM_BOOL Emscripten_on_fullscreenchange(int eventType, const EmscriptenFullscreen RGFW_root->r = RGFW_RECT(0, 0, e->screenWidth, e->screenHeight); EM_ASM("Module.canvas.focus();"); - + if (fullscreen == RGFW_FALSE) { RGFW_root->r = RGFW_RECT(0, 0, ogRect.w, ogRect.h); // emscripten_request_fullscreen("#canvas", 0); @@ -8576,6 +8653,141 @@ EM_BOOL Emscripten_on_gamepad(int eventType, const EmscriptenGamepadEvent *gamep return 1; // The event was consumed by the callback handler } + +u32 RGFW_webasmPhysicalToRGFW(u32 hash) { + switch(hash) { /* 0x0000 */ + case 0x67243A2DU /* Escape */: return RGFW_Escape; /* 0x0001 */ + case 0x67251058U /* Digit0 */: return RGFW_0; /* 0x0002 */ + case 0x67251059U /* Digit1 */: return RGFW_1; /* 0x0003 */ + case 0x6725105AU /* Digit2 */: return RGFW_2; /* 0x0004 */ + case 0x6725105BU /* Digit3 */: return RGFW_3; /* 0x0005 */ + case 0x6725105CU /* Digit4 */: return RGFW_4; /* 0x0006 */ + case 0x6725105DU /* Digit5 */: return RGFW_5; /* 0x0007 */ + case 0x6725105EU /* Digit6 */: return RGFW_6; /* 0x0008 */ + case 0x6725105FU /* Digit7 */: return RGFW_7; /* 0x0009 */ + case 0x67251050U /* Digit8 */: return RGFW_8; /* 0x000A */ + case 0x67251051U /* Digit9 */: return RGFW_9; /* 0x000B */ + case 0x92E14DD3U /* Minus */: return RGFW_Minus; /* 0x000C */ + case 0x92E1FBACU /* Equal */: return RGFW_Equals; /* 0x000D */ + case 0x36BF1CB5U /* Backspace */: return RGFW_BackSpace; /* 0x000E */ + case 0x7B8E51E2U /* Tab */: return RGFW_Tab; /* 0x000F */ + case 0x2C595B51U /* KeyQ */: return RGFW_q; /* 0x0010 */ + case 0x2C595B57U /* KeyW */: return RGFW_w; /* 0x0011 */ + case 0x2C595B45U /* KeyE */: return RGFW_e; /* 0x0012 */ + case 0x2C595B52U /* KeyR */: return RGFW_r; /* 0x0013 */ + case 0x2C595B54U /* KeyT */: return RGFW_t; /* 0x0014 */ + case 0x2C595B59U /* KeyY */: return RGFW_y; /* 0x0015 */ + case 0x2C595B55U /* KeyU */: return RGFW_u; /* 0x0016 */ + case 0x2C595B4FU /* KeyO */: return RGFW_o; /* 0x0018 */ + case 0x2C595B50U /* KeyP */: return RGFW_p; /* 0x0019 */ + case 0x45D8158CU /* BracketLeft */: return RGFW_CloseBracket; /* 0x001A */ + case 0xDEEABF7CU /* BracketRight */: return RGFW_Bracket; /* 0x001B */ + case 0x92E1C5D2U /* Enter */: return RGFW_Return; /* 0x001C */ + case 0xE058958CU /* ControlLeft */: return RGFW_ControlL; /* 0x001D */ + case 0x2C595B41U /* KeyA */: return RGFW_a; /* 0x001E */ + case 0x2C595B53U /* KeyS */: return RGFW_s; /* 0x001F */ + case 0x2C595B44U /* KeyD */: return RGFW_d; /* 0x0020 */ + case 0x2C595B46U /* KeyF */: return RGFW_f; /* 0x0021 */ + case 0x2C595B47U /* KeyG */: return RGFW_g; /* 0x0022 */ + case 0x2C595B48U /* KeyH */: return RGFW_h; /* 0x0023 */ + case 0x2C595B4AU /* KeyJ */: return RGFW_j; /* 0x0024 */ + case 0x2C595B4BU /* KeyK */: return RGFW_k; /* 0x0025 */ + case 0x2C595B4CU /* KeyL */: return RGFW_l; /* 0x0026 */ + case 0x2707219EU /* Semicolon */: return RGFW_Semicolon; /* 0x0027 */ + case 0x92E0B58DU /* Quote */: return RGFW_Apostrophe; /* 0x0028 */ + case 0x36BF358DU /* Backquote */: return RGFW_Backtick; /* 0x0029 */ + case 0x26B1958CU /* ShiftLeft */: return RGFW_ShiftL; /* 0x002A */ + case 0x36BF2438U /* Backslash */: return RGFW_BackSlash; /* 0x002B */ + case 0x2C595B5AU /* KeyZ */: return RGFW_z; /* 0x002C */ + case 0x2C595B58U /* KeyX */: return RGFW_x; /* 0x002D */ + case 0x2C595B43U /* KeyC */: return RGFW_c; /* 0x002E */ + case 0x2C595B56U /* KeyV */: return RGFW_v; /* 0x002F */ + case 0x2C595B42U /* KeyB */: return RGFW_b; /* 0x0030 */ + case 0x2C595B4EU /* KeyN */: return RGFW_n; /* 0x0031 */ + case 0x2C595B4DU /* KeyM */: return RGFW_m; /* 0x0032 */ + case 0x92E1A1C1U /* Comma */: return RGFW_Comma; /* 0x0033 */ + case 0x672FFAD4U /* Period */: return RGFW_Period; /* 0x0034 */ + case 0x92E0A438U /* Slash */: return RGFW_Slash; /* 0x0035 */ + case 0xC5A6BF7CU /* ShiftRight */: return RGFW_ShiftR; + case 0x5D64DA91U /* NumpadMultiply */: return RGFW_Multiply; + case 0xC914958CU /* AltLeft */: return RGFW_AltL; /* 0x0038 */ + case 0x92E09CB5U /* Space */: return RGFW_Space; /* 0x0039 */ + case 0xB8FAE73BU /* CapsLock */: return RGFW_CapsLock; /* 0x003A */ + case 0x7174B789U /* F1 */: return RGFW_F1; /* 0x003B */ + case 0x7174B78AU /* F2 */: return RGFW_F2; /* 0x003C */ + case 0x7174B78BU /* F3 */: return RGFW_F3; /* 0x003D */ + case 0x7174B78CU /* F4 */: return RGFW_F4; /* 0x003E */ + case 0x7174B78DU /* F5 */: return RGFW_F5; /* 0x003F */ + case 0x7174B78EU /* F6 */: return RGFW_F6; /* 0x0040 */ + case 0x7174B78FU /* F7 */: return RGFW_F7; /* 0x0041 */ + case 0x7174B780U /* F8 */: return RGFW_F8; /* 0x0042 */ + case 0x7174B781U /* F9 */: return RGFW_F9; /* 0x0043 */ + case 0x7B8E57B0U /* F10 */: return RGFW_F10; /* 0x0044 */ + case 0xC925FCDFU /* Numpad7 */: return RGFW_Multiply; /* 0x0047 */ + case 0xC925FCD0U /* Numpad8 */: return RGFW_KP_8; /* 0x0048 */ + case 0xC925FCD1U /* Numpad9 */: return RGFW_KP_9; /* 0x0049 */ + case 0x5EA3E8A4U /* NumpadSubtract */: return RGFW_Minus; /* 0x004A */ + case 0xC925FCDCU /* Numpad4 */: return RGFW_KP_4; /* 0x004B */ + case 0xC925FCDDU /* Numpad5 */: return RGFW_KP_5; /* 0x004C */ + case 0xC925FCDEU /* Numpad6 */: return RGFW_KP_6; /* 0x004D */ + case 0xC925FCD9U /* Numpad1 */: return RGFW_KP_1; /* 0x004F */ + case 0xC925FCDAU /* Numpad2 */: return RGFW_KP_2; /* 0x0050 */ + case 0xC925FCDBU /* Numpad3 */: return RGFW_KP_3; /* 0x0051 */ + case 0xC925FCD8U /* Numpad0 */: return RGFW_KP_0; /* 0x0052 */ + case 0x95852DACU /* NumpadDecimal */: return RGFW_KP_Period; /* 0x0053 */ + case 0x7B8E57B1U /* F11 */: return RGFW_F11; /* 0x0057 */ + case 0x7B8E57B2U /* F12 */: return RGFW_F12; /* 0x0058 */ + case 0x7393FBACU /* NumpadEqual */: return RGFW_KP_Return; + case 0xB88EBF7CU /* AltRight */: return RGFW_AltR; /* 0xE038 */ + case 0xC925873BU /* NumLock */: return RGFW_Numlock; /* 0xE045 */ + case 0x2C595F45U /* Home */: return RGFW_Home; /* 0xE047 */ + case 0xC91BB690U /* ArrowUp */: return RGFW_Up; /* 0xE048 */ + case 0x672F9210U /* PageUp */: return RGFW_PageUp; /* 0xE049 */ + case 0x3799258CU /* ArrowLeft */: return RGFW_Left; /* 0xE04B */ + case 0x4CE33F7CU /* ArrowRight */: return RGFW_Right; /* 0xE04D */ + case 0x7B8E55DCU /* End */: return RGFW_End; /* 0xE04F */ + case 0x3799379EU /* ArrowDown */: return RGFW_Down; /* 0xE050 */ + case 0xBA90179EU /* PageDown */: return RGFW_PageDown; /* 0xE051 */ + case 0x6723CB2CU /* Insert */: return RGFW_Insert; /* 0xE052 */ + case 0x6725C50DU /* Delete */: return RGFW_Delete; /* 0xE053 */ + case 0x6723658CU /* OSLeft */: return RGFW_SuperL; /* 0xE05B */ + case 0x39643F7CU /* MetaRight */: return RGFW_SuperR; /* 0xE05C */ + } + + return 0; +} + +void EMSCRIPTEN_KEEPALIVE RGFW_handleKeyEvent(char* key, char* code, b8 press) { + const char* iCode = code; + + u32 hash = 0; + while(*iCode) hash = ((hash ^ 0x7E057D79U) << 3) ^ (unsigned int)*iCode++; + + u32 physicalKey = RGFW_webasmPhysicalToRGFW(hash); + + u8 mappedKey = (u8)(*((u32*)key)); + + if (*((u16*)key) != mappedKey) { + mappedKey = 0; + if (*((u32*)key) == *((u32*)"Tab")) mappedKey = RGFW_Tab; + } + + RGFW_events[RGFW_eventLen].type = press ? RGFW_keyPressed : RGFW_keyReleased; + memcpy(RGFW_events[RGFW_eventLen].keyName, key, 16); + RGFW_events[RGFW_eventLen].key = physicalKey; + RGFW_events[RGFW_eventLen].keyChar = mappedKey; + RGFW_events[RGFW_eventLen].lockState = 0; + RGFW_eventLen++; + + RGFW_keyboard[physicalKey].prev = RGFW_keyboard[physicalKey].current; + RGFW_keyboard[physicalKey].current = 0; + + RGFW_keyCallback(RGFW_root, physicalKey, mappedKey, RGFW_events[RGFW_eventLen].keyName, 0, press); + + free(key); + free(code); +} + void EMSCRIPTEN_KEEPALIVE Emscripten_onDrop(size_t count) { if (!(RGFW_root->_winArgs & RGFW_ALLOW_DND)) return; @@ -8694,8 +8906,6 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { emscripten_set_window_title(name); /* load callbacks */ - emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EM_FALSE, Emscripten_on_keydown); - emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EM_FALSE, Emscripten_on_keyup); emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, EM_FALSE, Emscripten_on_resize); emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, EM_FALSE, Emscripten_on_fullscreenchange); emscripten_set_mousemove_callback("#canvas", NULL, EM_FALSE, Emscripten_on_mousemove); @@ -8715,6 +8925,22 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { win->_winArgs |= RGFW_ALLOW_DND; } + EM_ASM({ + window.addEventListener("keydown", + (event) => { + Module._RGFW_handleKeyEvent(stringToNewUTF8(event.key), stringToNewUTF8(event.code), 1); + }, true, + ); + }); + + EM_ASM({ + window.addEventListener("keyup", + (event) => { + Module._RGFW_handleKeyEvent(stringToNewUTF8(event.key), stringToNewUTF8(event.code), 0); + }, true, + ); + }); + EM_ASM({ var canvas = document.getElementById('canvas'); canvas.addEventListener('drop', function(e) { @@ -8778,6 +9004,10 @@ RGFW_window* RGFW_createWindow(const char* name, RGFW_rect rect, u16 args) { RGFW_window_resize(win, RGFW_getScreenSize()); } + #ifdef RGFW_DEBUG + printf("RGFW INFO: a window with a rect of {%i, %i, %i, %i} \n", win->r.x, win->r.y, win->r.w, win->r.h); + #endif + return win; } @@ -9099,6 +9329,8 @@ RGFW_monitor RGFW_window_getMonitor(RGFW_window* win) { RGFW_UNUSED(win) return void RGFW_joinThread(RGFW_thread thread) { pthread_join((pthread_t) thread, NULL); } #ifdef __linux__ void RGFW_setThreadPriority(RGFW_thread thread, u8 priority) { pthread_setschedprio((pthread_t)thread, priority); } +#else + void RGFW_setThreadPriority(RGFW_thread thread, u8 priority) { RGFW_UNUSED(thread); RGFW_UNUSED(priority); } #endif #endif diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index a74af2074..ca756361a 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -129,7 +129,8 @@ static bool RGFW_disableCursor = false; static const unsigned short keyMappingRGFW[] = { [RGFW_KEY_NULL] = KEY_NULL, [RGFW_Return] = KEY_ENTER, - [RGFW_Quote] = KEY_APOSTROPHE, + [RGFW_Return] = KEY_ENTER, + [RGFW_Apostrophe] = KEY_APOSTROPHE, [RGFW_Comma] = KEY_COMMA, [RGFW_Minus] = KEY_MINUS, [RGFW_Period] = KEY_PERIOD, @@ -817,59 +818,6 @@ const char *GetKeyName(int key) static KeyboardKey ConvertScancodeToKey(u32 keycode); -// TODO: Review function to avoid duplicate with RSGL -char RSGL_keystrToChar(const char *str) -{ - if (str[1] == 0) return str[0]; - - static const char *map[] = { - "asciitilde", "`", - "grave", "~", - "exclam", "!", - "at", "@", - "numbersign", "#", - "dollar", "$", - "percent", "%%", - "asciicircum", "^", - "ampersand", "&", - "asterisk", "*", - "parenleft", "(", - "parenright", ")", - "underscore", "_", - "minus", "-", - "plus", "+", - "equal", "=", - "braceleft", "{", - "bracketleft", "[", - "bracketright", "]", - "braceright", "}", - "colon", ":", - "semicolon", ";", - "quotedbl", "\"", - "apostrophe", "'", - "bar", "|", - "backslash", "\'", - "less", "<", - "comma", ",", - "greater", ">", - "period", ".", - "question", "?", - "slash", "/", - "space", " ", - "Return", "\n", - "Enter", "\n", - "enter", "\n", - }; - - for (unsigned char i = 0; i < (sizeof(map)/sizeof(char *)); i += 2) - { - if (strcmp(map[i], str) == 0) return *map[i + 1]; - } - - return '\0'; -} - -// Gamepad buttons conversion table int RGFW_gpConvTable[18] = { [RGFW_GP_Y] = GAMEPAD_BUTTON_RIGHT_FACE_UP, [RGFW_GP_B] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, @@ -1025,7 +973,7 @@ void PollInputEvents(void) // Keyboard events case RGFW_keyPressed: { - KeyboardKey key = ConvertScancodeToKey(event->keyCode); + KeyboardKey key = ConvertScancodeToKey(event->key); if (key != KEY_NULL) { // If key was up, add it to the key pressed queue @@ -1049,13 +997,13 @@ void PollInputEvents(void) if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE) { // Add character (codepoint) to the queue - CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = RSGL_keystrToChar(event->keyName); + CORE.Input.Keyboard.charPressedQueue[CORE.Input.Keyboard.charPressedQueueCount] = event->keyChar; CORE.Input.Keyboard.charPressedQueueCount++; } } break; case RGFW_keyReleased: { - KeyboardKey key = ConvertScancodeToKey(event->keyCode); + KeyboardKey key = ConvertScancodeToKey(event->key); if (key != KEY_NULL) CORE.Input.Keyboard.currentKeyState[key] = 0; } break; @@ -1066,7 +1014,7 @@ void PollInputEvents(void) { CORE.Input.Mouse.currentWheelMove.y = event->scroll; break; - } + } else CORE.Input.Mouse.currentWheelMove.y = 0; int btn = event->button; if (btn == RGFW_mouseLeft) btn = 1; @@ -1084,7 +1032,7 @@ void PollInputEvents(void) { CORE.Input.Mouse.currentWheelMove.y = event->scroll; break; - } + } else CORE.Input.Mouse.currentWheelMove.y = 0; int btn = event->button; if (btn == RGFW_mouseLeft) btn = 1; @@ -1303,7 +1251,7 @@ int InitPlatform(void) #ifdef RGFW_X11 for (int i = 0; (i < 4) && (i < MAX_GAMEPADS); i++) { - RGFW_registergamepad(platform.window, i); + RGFW_registerGamepad(platform.window, i); } #endif From b07967993f6b13d5edb02c596cde652a3db139a1 Mon Sep 17 00:00:00 2001 From: Antonis Geralis <43617260+planetis-m@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:08:42 +0200 Subject: [PATCH 040/793] Update version number for the nim wrapper (#4638) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 5e93a076a..8f5c86f96 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -50,7 +50,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [raylib-matte](https://github.com/jcorks/raylib-matte) | 4.6-dev | [Matte](https://github.com/jcorks/matte) | **???** | | [Raylib.nelua](https://github.com/AuzFox/Raylib.nelua) | **5.0** | [nelua](https://nelua.io) | Zlib | | [raylib-bindings](https://github.com/vaiorabbit/raylib-bindings) | 5.6-dev | [Ruby](https://www.ruby-lang.org/en) | Zlib | -| [naylib](https://github.com/planetis-m/naylib) | **5.1-dev** | [Nim](https://nim-lang.org) | MIT | +| [naylib](https://github.com/planetis-m/naylib) | **5.6-dev** | [Nim](https://nim-lang.org) | MIT | | [node-raylib](https://github.com/RobLoach/node-raylib) | 4.5 | [Node.js](https://nodejs.org/en) | Zlib | | [raylib-odin](https://github.com/odin-lang/Odin/tree/master/vendor/raylib) | **5.5** | [Odin](https://odin-lang.org) | BSD-3Clause | | [raylib_odin_bindings](https://github.com/Deathbat2190/raylib_odin_bindings) | 4.0-dev | [Odin](https://odin-lang.org) | MIT | From 51b9a0acfc8fe16f7487ee058f1fa9ee4b99bd26 Mon Sep 17 00:00:00 2001 From: Bot Randomness <114881271+BotRandomness@users.noreply.github.com> Date: Thu, 26 Dec 2024 12:55:38 -0500 Subject: [PATCH 041/793] Updated BINDINGS.md for Ruby (#4639) Added a Ruby binding known as raylib-ruby on 4.5. (https://github.com/wilsonsilva/raylib-ruby) --- BINDINGS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BINDINGS.md b/BINDINGS.md index 8f5c86f96..3bc235b76 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -69,6 +69,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [raylibr](https://github.com/jeroenjanssens/raylibr) | 4.0 | [R](https://www.r-project.org) | MIT | | [raylib-ffi](https://github.com/ewpratten/raylib-ffi) | 5.5 | [Rust](https://www.rust-lang.org) | GPLv3 | | [raylib-rs](https://github.com/raylib-rs/raylib-rs) | **5.5** | [Rust](https://www.rust-lang.org) | Zlib | +| [raylib-ruby](https://github.com/wilsonsilva/raylib-ruby) | 4.5 | [Ruby](https://www.ruby-lang.org) | Zlib | | [Relib](https://github.com/RedCubeDev-ByteSpace/Relib) | 3.5 | [ReCT](https://github.com/RedCubeDev-ByteSpace/ReCT) | **???** | | [racket-raylib](https://github.com/eutro/racket-raylib) | 4.0 | [Racket](https://racket-lang.org) | MIT/Apache-2.0 | | [raylib-swift](https://github.com/STREGAsGate/Raylib) | 4.0 | [Swift](https://swift.org) | MIT | From 47588678156e6533eed5f1ca1d2d7779666819f0 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Thu, 26 Dec 2024 15:02:57 -0300 Subject: [PATCH 042/793] [rcore] [SDL2] Add implementation for `FLAG_WINDOW_ALWAYS_RUN` (#4598) * Enable FLAG_WINDOW_ALWAYS_RUN by default on PLATFORM_DESKTOP_GLFW * Revert enabling FLAG_WINDOW_ALWAYS_RUN by default on PLATFORM_DESKTOP_GLFW * Add implementation for FLAG_WINDOW_ALWAYS_RUN on PLATFORM_DESKTOP_SDL * Add reset for GetFrameTime() --- src/platforms/rcore_desktop_glfw.c | 7 ++++++- src/platforms/rcore_desktop_sdl.c | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index cb61f7d81..ac419ea7b 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1739,7 +1739,12 @@ static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float s static void WindowIconifyCallback(GLFWwindow *window, int iconified) { if (iconified) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; // The window was iconified - else CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // The window was restored + else + { + CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // The window was restored + + if ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0) CORE.Time.previous = GetTime(); + } } // GLFW3 WindowMaximize Callback, runs when window is maximized/restored diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 3d1ac0bf3..5d316df50 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -571,7 +571,7 @@ void SetWindowState(unsigned int flags) } if (flags & FLAG_WINDOW_ALWAYS_RUN) { - TRACELOG(LOG_WARNING, "SetWindowState() - FLAG_WINDOW_ALWAYS_RUN is not supported on PLATFORM_DESKTOP_SDL"); + CORE.Window.flags |= FLAG_WINDOW_ALWAYS_RUN; } if (flags & FLAG_WINDOW_TRANSPARENT) { @@ -658,7 +658,7 @@ void ClearWindowState(unsigned int flags) } if (flags & FLAG_WINDOW_ALWAYS_RUN) { - TRACELOG(LOG_WARNING, "ClearWindowState() - FLAG_WINDOW_ALWAYS_RUN is not supported on PLATFORM_DESKTOP_SDL"); + CORE.Window.flags &= ~FLAG_WINDOW_ALWAYS_RUN; } if (flags & FLAG_WINDOW_TRANSPARENT) { @@ -1378,6 +1378,8 @@ void PollInputEvents(void) CORE.Window.resizedLastFrame = false; + if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) && ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0)) SDL_WaitEvent(NULL); + SDL_Event event = { 0 }; while (SDL_PollEvent(&event) != 0) { @@ -1497,6 +1499,8 @@ void PollInputEvents(void) if ((CORE.Window.flags & SDL_WINDOW_MAXIMIZED) > 0) CORE.Window.flags &= ~SDL_WINDOW_MAXIMIZED; } #endif + + if ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0) CORE.Time.previous = GetTime(); } break; case SDL_WINDOWEVENT_HIDDEN: From 7ecc47d12e5f4c322af3d16615a08ba9bc47c4c2 Mon Sep 17 00:00:00 2001 From: Mario Nachbaur Date: Thu, 26 Dec 2024 20:12:53 +0100 Subject: [PATCH 043/793] Fix `IsWindowFocused()` on web. (#4640) --- src/platforms/rcore_web.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index d28ed55c2..996e7daf5 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -133,6 +133,7 @@ static void CursorEnterCallback(GLFWwindow *window, int enter); static EM_BOOL EmscriptenFullscreenChangeCallback(int eventType, const EmscriptenFullscreenChangeEvent *event, void *userData); // static EM_BOOL EmscriptenWindowResizedCallback(int eventType, const EmscriptenUiEvent *event, void *userData); static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *event, void *userData); +static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData); // Emscripten input callback events static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); @@ -1369,6 +1370,10 @@ int InitPlatform(void) // Support gamepad events (not provided by GLFW3 on emscripten) emscripten_set_gamepadconnected_callback(NULL, 1, EmscriptenGamepadCallback); emscripten_set_gamepaddisconnected_callback(NULL, 1, EmscriptenGamepadCallback); + + // Support focus events + emscripten_set_blur_callback("#canvas", platform.handle, 1, EmscriptenFocusCallback); + emscripten_set_focus_callback("#canvas", platform.handle, 1, EmscriptenFocusCallback); //---------------------------------------------------------------------------- // Initialize timing system @@ -1732,6 +1737,18 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE return 1; // The event was consumed by the callback handler } +static EM_BOOL EmscriptenFocusCallback(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData) +{ + EM_BOOL consumed = 1; + switch (eventType) + { + case EMSCRIPTEN_EVENT_BLUR: WindowFocusCallback(userData, 0); break; + case EMSCRIPTEN_EVENT_FOCUS: WindowFocusCallback(userData, 1); break; + default: consumed = 0; break; + } + return consumed; +} + // Register touch input events static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) { From e062dc085c164c3e89eb928ec91278f08c2f4ccf Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Sat, 28 Dec 2024 06:56:04 -0800 Subject: [PATCH 044/793] Add filters and platform files so they show up in MSVC for ease of editing (#4644) --- projects/VS2022/raylib/raylib.vcxproj | 70 ++++++++++ projects/VS2022/raylib/raylib.vcxproj.filters | 120 ++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 projects/VS2022/raylib/raylib.vcxproj.filters diff --git a/projects/VS2022/raylib/raylib.vcxproj b/projects/VS2022/raylib/raylib.vcxproj index 0c03027a4..347ff5d11 100644 --- a/projects/VS2022/raylib/raylib.vcxproj +++ b/projects/VS2022/raylib/raylib.vcxproj @@ -302,6 +302,76 @@ + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + diff --git a/projects/VS2022/raylib/raylib.vcxproj.filters b/projects/VS2022/raylib/raylib.vcxproj.filters new file mode 100644 index 000000000..182358229 --- /dev/null +++ b/projects/VS2022/raylib/raylib.vcxproj.filters @@ -0,0 +1,120 @@ + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Platform Files + + + Source Files\Platform Files + + + Source Files\Platform Files + + + Source Files\Platform Files + + + Source Files\Platform Files + + + Source Files\Platform Files + + + Source Files\Platform Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + + + {88e8d1f8-5c93-4f9e-a856-819a1f82a387} + + + {cba93591-3674-4384-9325-bc0ae2d72b9b} + + + {d18433d7-0e5c-40d7-a39d-e0f11f80d183} + + + \ No newline at end of file From 75b6b825dfc93488bc411c00845164b5c0f8fae6 Mon Sep 17 00:00:00 2001 From: Johannes <59510166+Joonsey@users.noreply.github.com> Date: Sat, 28 Dec 2024 15:57:10 +0100 Subject: [PATCH 045/793] using addCMacro instead of defineCMacro (#4620) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Johannes Rønning --- build.zig | 24 ++++++++++++------------ examples/build.zig | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build.zig b/build.zig index 66e8fab4f..0f6f29755 100644 --- a/build.zig +++ b/build.zig @@ -13,9 +13,9 @@ comptime { fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void { switch (platform) { - .glfw => raylib.defineCMacro("PLATFORM_DESKTOP_GLFW", null), - .rgfw => raylib.defineCMacro("PLATFORM_DESKTOP_RGFW", null), - .sdl => raylib.defineCMacro("PLATFORM_DESKTOP_SDL", null), + .glfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_GLFW", ""), + .rgfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_RGFW", ""), + .sdl => raylib.root_module.addCMacro("PLATFORM_DESKTOP_SDL", ""), else => {}, } } @@ -173,7 +173,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. } if (options.opengl_version != .auto) { - raylib.defineCMacro(options.opengl_version.toCMacroStr(), null); + raylib.root_module.addCMacro(options.opengl_version.toCMacroStr(), ""); } raylib.addIncludePath(b.path("src/platforms")); @@ -191,7 +191,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. try c_source_files.append("src/rglfw.c"); if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) { - raylib.defineCMacro("_GLFW_X11", null); + raylib.root_module.addCMacro("_GLFW_X11", ""); raylib.linkSystemLibrary("GLX"); raylib.linkSystemLibrary("X11"); raylib.linkSystemLibrary("Xcursor"); @@ -211,7 +211,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. , .{}); @panic("`wayland-scanner` not found"); }; - raylib.defineCMacro("_GLFW_WAYLAND", null); + raylib.root_module.addCMacro("_GLFW_WAYLAND", ""); raylib.linkSystemLibrary("EGL"); raylib.linkSystemLibrary("wayland-client"); raylib.linkSystemLibrary("xkbcommon"); @@ -230,16 +230,16 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. } else { if (options.opengl_version == .auto) { raylib.linkSystemLibrary("GLESv2"); - raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null); + raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", ""); } raylib.linkSystemLibrary("EGL"); raylib.linkSystemLibrary("gbm"); raylib.linkSystemLibrary2("libdrm", .{ .use_pkg_config = .force }); - raylib.defineCMacro("PLATFORM_DRM", null); - raylib.defineCMacro("EGL_NO_X11", null); - raylib.defineCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "2048"); + raylib.root_module.addCMacro("PLATFORM_DRM", ""); + raylib.root_module.addCMacro("EGL_NO_X11", ""); + raylib.root_module.addCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", ""); } }, .freebsd, .openbsd, .netbsd, .dragonfly => { @@ -290,9 +290,9 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. raylib.addIncludePath(dep.path("upstream/emscripten/cache/sysroot/include")); } - raylib.defineCMacro("PLATFORM_WEB", null); + raylib.root_module.addCMacro("PLATFORM_WEB", ""); if (options.opengl_version == .auto) { - raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null); + raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", ""); } }, else => { diff --git a/examples/build.zig b/examples/build.zig index df0cdf8c1..301381df3 100644 --- a/examples/build.zig +++ b/examples/build.zig @@ -46,7 +46,7 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.Build.Reso exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("opengl32"); - exe.defineCMacro("PLATFORM_DESKTOP", null); + exe.root_module.addCMacro("PLATFORM_DESKTOP", ""); }, .linux => { exe.linkSystemLibrary("GL"); @@ -55,7 +55,7 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.Build.Reso exe.linkSystemLibrary("m"); exe.linkSystemLibrary("X11"); - exe.defineCMacro("PLATFORM_DESKTOP", null); + exe.root_module.addCMacro("PLATFORM_DESKTOP", ""); }, .macos => { exe.linkFramework("Foundation"); @@ -65,7 +65,7 @@ fn add_module(comptime module: []const u8, b: *std.Build, target: std.Build.Reso exe.linkFramework("CoreVideo"); exe.linkFramework("IOKit"); - exe.defineCMacro("PLATFORM_DESKTOP", null); + exe.root_module.addCMacro("PLATFORM_DESKTOP", ""); }, else => { @panic("Unsupported OS"); From 5b822585e5aa31baf1d11e572f9fe7ef1fafc2ba Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Sat, 28 Dec 2024 11:59:05 -0300 Subject: [PATCH 046/793] [rcore] [GLFW] [SDL2] Updates `CORE.Window.eventWaiting` and `FLAG_WINDOW_ALWAYS_RUN` handling (#4642) * Add implementation for CORE.Window.eventWaiting on PLATFORM_DESKTOP_SDL * Optimize GetFrameTime() reset * Optimize FLAG_WINDOW_ALWAYS_RUN and GetFrameTime() reset for PLATFORM_DESKTOP_GLFW --- src/platforms/rcore_desktop_glfw.c | 16 ++++++---------- src/platforms/rcore_desktop_sdl.c | 8 +++++--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index ac419ea7b..c2a43be11 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1248,12 +1248,13 @@ void PollInputEvents(void) CORE.Window.resizedLastFrame = false; - if (CORE.Window.eventWaiting) glfwWaitEvents(); // Wait for in input events before continue (drawing is paused) + if ((CORE.Window.eventWaiting) || (IsWindowState(FLAG_WINDOW_MINIMIZED) && !IsWindowState(FLAG_WINDOW_ALWAYS_RUN))) + { + glfwWaitEvents(); // Wait for in input events before continue (drawing is paused) + CORE.Time.previous = GetTime(); + } else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks) -> Update keys state - // While window minimized, stop loop execution - while (IsWindowState(FLAG_WINDOW_MINIMIZED) && !IsWindowState(FLAG_WINDOW_ALWAYS_RUN)) glfwWaitEvents(); - CORE.Window.shouldClose = glfwWindowShouldClose(platform.handle); // Reset close status for next frame @@ -1739,12 +1740,7 @@ static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float s static void WindowIconifyCallback(GLFWwindow *window, int iconified) { if (iconified) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; // The window was iconified - else - { - CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // The window was restored - - if ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0) CORE.Time.previous = GetTime(); - } + else CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; // The window was restored } // GLFW3 WindowMaximize Callback, runs when window is maximized/restored diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 5d316df50..c5ff97cf0 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -1378,7 +1378,11 @@ void PollInputEvents(void) CORE.Window.resizedLastFrame = false; - if (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) && ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0)) SDL_WaitEvent(NULL); + if ((CORE.Window.eventWaiting) || (((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) && ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0))) + { + SDL_WaitEvent(NULL); + CORE.Time.previous = GetTime(); + } SDL_Event event = { 0 }; while (SDL_PollEvent(&event) != 0) @@ -1499,8 +1503,6 @@ void PollInputEvents(void) if ((CORE.Window.flags & SDL_WINDOW_MAXIMIZED) > 0) CORE.Window.flags &= ~SDL_WINDOW_MAXIMIZED; } #endif - - if ((CORE.Window.flags & FLAG_WINDOW_ALWAYS_RUN) == 0) CORE.Time.previous = GetTime(); } break; case SDL_WINDOWEVENT_HIDDEN: From c0f2067dbadecbc0130acb08f931361ebaed4d54 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 28 Dec 2024 16:35:42 +0100 Subject: [PATCH 047/793] REVIEWED: `LoadShaderFromMemory()`, use default locations for default shader #4641 --- src/rcore.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rcore.c b/src/rcore.c index 5ba24a5b8..17634a52c 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1326,9 +1326,10 @@ Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode) shader.id = rlLoadShaderCode(vsCode, fsCode); - // After shader loading, we TRY to set default location names - if (shader.id > 0) + if (shader.id == rlGetShaderIdDefault()) shader.locs = rlGetShaderLocsDefault(); + else if (shader.id > 0) { + // After custom shader loading, we TRY to set default location names // Default shader attribute locations have been binded before linking: // vertex position location = 0 // vertex texcoord location = 1 From f355d6f1db7d39b983d3a3fa06f9d29447dcc382 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Sat, 28 Dec 2024 16:07:52 -0800 Subject: [PATCH 048/793] Transform the vertex normals by the animated matrix (#4646) --- .../models/resources/shaders/glsl330/skinning.vs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/models/resources/shaders/glsl330/skinning.vs b/examples/models/resources/shaders/glsl330/skinning.vs index 73ecca51e..43bbca76c 100644 --- a/examples/models/resources/shaders/glsl330/skinning.vs +++ b/examples/models/resources/shaders/glsl330/skinning.vs @@ -6,16 +6,19 @@ in vec3 vertexPosition; in vec2 vertexTexCoord; in vec4 vertexColor; +in vec3 vertexNormal; in vec4 vertexBoneIds; in vec4 vertexBoneWeights; // Input uniform values uniform mat4 mvp; +uniform mat4 matNormal; uniform mat4 boneMatrices[MAX_BONE_NUM]; // Output vertex attributes (to fragment shader) out vec2 fragTexCoord; out vec4 fragColor; +out vec3 fragNormal; void main() { @@ -29,9 +32,18 @@ void main() vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexPosition, 1.0)) + vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexPosition, 1.0)) + vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexPosition, 1.0)); - + + vec4 skinnedNormal = + vertexBoneWeights.x*(boneMatrices[boneIndex0]*vec4(vertexNormal, 0.0)) + + vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexNormal, 0.0)) + + vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexNormal, 0.0)) + + vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexNormal, 0.0)); + skinnedNormal.w = 0.0; + fragTexCoord = vertexTexCoord; fragColor = vertexColor; + fragNormal = normalize(vec3(matNormal*skinnedNormal)); + gl_Position = mvp*skinnedPosition; } \ No newline at end of file From d1315e8a0429e9b43b80b705199d5fec4ee5a83b Mon Sep 17 00:00:00 2001 From: Peter Zmanovsky <48548636+peter15914@users.noreply.github.com> Date: Mon, 30 Dec 2024 01:06:40 +0500 Subject: [PATCH 049/793] [rmodels] Fix leaks in LoadIQM() and LoadModelAnimationsIQM() (#4649) Add calls to UnloadFileData() before return in cases of invalid IQM file. --- src/rmodels.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rmodels.c b/src/rmodels.c index c62267de4..70e461ea5 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -4570,12 +4570,14 @@ static Model LoadIQM(const char *fileName) if (memcmp(iqmHeader->magic, IQM_MAGIC, sizeof(IQM_MAGIC)) != 0) { TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file is not a valid model", fileName); + UnloadFileData(fileData); return model; } if (iqmHeader->version != IQM_VERSION) { TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file version not supported (%i)", fileName, iqmHeader->version); + UnloadFileData(fileData); return model; } @@ -4891,12 +4893,14 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCou if (memcmp(iqmHeader->magic, IQM_MAGIC, sizeof(IQM_MAGIC)) != 0) { TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file is not a valid model", fileName); + UnloadFileData(fileData); return NULL; } if (iqmHeader->version != IQM_VERSION) { TRACELOG(LOG_WARNING, "MODEL: [%s] IQM file version not supported (%i)", fileName, iqmHeader->version); + UnloadFileData(fileData); return NULL; } From fa0eada61a1131a7413df9139ead6d018b169f22 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 1 Jan 2025 00:02:52 +0100 Subject: [PATCH 050/793] Update year to 2025 --- LICENSE | 2 +- examples/Makefile | 2 +- examples/Makefile.Android | 2 +- examples/Makefile.Web | 2 +- examples/examples.rc | 2 +- parser/LICENSE | 2 +- parser/README.md | 2 +- parser/raylib_parser.c | 4 ++-- projects/VSCode/main.c | 2 +- src/Makefile | 2 +- src/config.h | 2 +- src/platforms/rcore_android.c | 2 +- src/platforms/rcore_desktop_glfw.c | 2 +- src/platforms/rcore_desktop_rgfw.c | 2 +- src/platforms/rcore_desktop_sdl.c | 2 +- src/platforms/rcore_drm.c | 2 +- src/platforms/rcore_template.c | 2 +- src/platforms/rcore_web.c | 2 +- src/raudio.c | 4 ++-- src/raylib.dll.rc | 2 +- src/raylib.dll.rc.data | Bin 11318 -> 7742 bytes src/raylib.h | 2 +- src/raylib.rc | 2 +- src/raylib.rc.data | Bin 11302 -> 7726 bytes src/raymath.h | 2 +- src/rcamera.h | 2 +- src/rcore.c | 4 ++-- src/rgestures.h | 2 +- src/rglfw.c | 2 +- src/rlgl.h | 2 +- src/rmodels.c | 4 ++-- src/rshapes.c | 2 +- src/rtext.c | 4 ++-- src/rtextures.c | 4 ++-- src/utils.c | 4 ++-- src/utils.h | 2 +- 36 files changed, 41 insertions(+), 41 deletions(-) diff --git a/LICENSE b/LICENSE index d1bfe3b1a..e96f876a2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +Copyright (c) 2013-2025 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. diff --git a/examples/Makefile b/examples/Makefile index c02cad434..12d798b50 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -30,7 +30,7 @@ # > PLATFORM_ANDROID: # - Android (ARM, ARM64) # -# Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2025 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. diff --git a/examples/Makefile.Android b/examples/Makefile.Android index 01d88fa49..c00da171e 100644 --- a/examples/Makefile.Android +++ b/examples/Makefile.Android @@ -2,7 +2,7 @@ # # raylib makefile for Android project (APK building) # -# Copyright (c) 2017-2024 Ramon Santamaria (@raysan5) +# Copyright (c) 2017-2025 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. diff --git a/examples/Makefile.Web b/examples/Makefile.Web index a4470e09f..90345f97d 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -2,7 +2,7 @@ # # raylib makefile for Web platform # -# Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2025 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. diff --git a/examples/examples.rc b/examples/examples.rc index 4767ad480..e5024b731 100644 --- a/examples/examples.rc +++ b/examples/examples.rc @@ -13,7 +13,7 @@ BEGIN VALUE "FileDescription", "raylib example" VALUE "FileVersion", "1.0" VALUE "InternalName", "raylib-example" - VALUE "LegalCopyright", "(c) 2024 raylib technologies (@raylibtech)" + VALUE "LegalCopyright", "(c) 2025 raylib technologies (@raylibtech)" //VALUE "OriginalFilename", "raylib_app.exe" VALUE "ProductName", "raylib-example" VALUE "ProductVersion", "1.0" diff --git a/parser/LICENSE b/parser/LICENSE index 7fc2d13b0..7ed4b8722 100644 --- a/parser/LICENSE +++ b/parser/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021-2024 Ramon Santamaria (@raysan5) +Copyright (c) 2021-2025 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. diff --git a/parser/README.md b/parser/README.md index 6616cdc51..86cdfdd5b 100644 --- a/parser/README.md +++ b/parser/README.md @@ -19,7 +19,7 @@ Check `raylib_parser.c` for details about those structs. // // // more info and bugs-report: github.com/raysan5/raylib/parser // // // -// Copyright (c) 2021-2024 Ramon Santamaria (@raysan5) // +// Copyright (c) 2021-2025 Ramon Santamaria (@raysan5) // // // ////////////////////////////////////////////////////////////////////////////////// diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c index 94a715562..82e22f195 100644 --- a/parser/raylib_parser.c +++ b/parser/raylib_parser.c @@ -54,7 +54,7 @@ raylib-parser is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software: - Copyright (c) 2021-2024 Ramon Santamaria (@raysan5) + Copyright (c) 2021-2025 Ramon Santamaria (@raysan5) **********************************************************************************************/ @@ -1084,7 +1084,7 @@ static void ShowCommandLineInfo(void) printf("// //\n"); printf("// more info and bugs-report: github.com/raysan5/raylib/parser //\n"); printf("// //\n"); - printf("// Copyright (c) 2021-2024 Ramon Santamaria (@raysan5) //\n"); + printf("// Copyright (c) 2021-2025 Ramon Santamaria (@raysan5) //\n"); printf("// //\n"); printf("//////////////////////////////////////////////////////////////////////////////////\n\n"); diff --git a/projects/VSCode/main.c b/projects/VSCode/main.c index 5a2e342bd..cad32c2ef 100644 --- a/projects/VSCode/main.c +++ b/projects/VSCode/main.c @@ -15,7 +15,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/src/Makefile b/src/Makefile index b5fa2ecff..37554b2a0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -33,7 +33,7 @@ # Many thanks to Milan Nikolic (@gen2brain) for implementing Android platform pipeline. # Many thanks to Emanuele Petriglia for his contribution on GNU/Linux pipeline. # -# Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2025 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. diff --git a/src/config.h b/src/config.h index 74e0a1353..f7b015305 100644 --- a/src/config.h +++ b/src/config.h @@ -6,7 +6,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2018-2024 Ahmad Fatoum & Ramon Santamaria (@raysan5) +* Copyright (c) 2018-2025 Ahmad Fatoum & 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. diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index faa00c98b..96ea367dc 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -27,7 +27,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) and contributors +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) and contributors * * 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. diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index c2a43be11..bd2600c87 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -30,7 +30,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) and contributors +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) and contributors * * 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. diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index ca756361a..800f54658 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -29,7 +29,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5), Colleague Riley and contributors +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5), Colleague Riley and contributors * * 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. diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index c5ff97cf0..4b3327ee1 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -29,7 +29,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) and contributors +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) and contributors * * 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. diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index 09cb80556..36d255bc0 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -29,7 +29,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) and contributors +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) and contributors * * 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. diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index d7605950e..c532bf24f 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -27,7 +27,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) and contributors +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) and contributors * * 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. diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 996e7daf5..9fd2afb5a 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -26,7 +26,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) and contributors +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) and contributors * * 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. diff --git a/src/raudio.c b/src/raudio.c index cc596ec11..a143c5ff5 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -50,7 +50,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2025 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. @@ -1125,7 +1125,7 @@ bool ExportWaveAsCode(Wave wave, const char *fileName) byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); - byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2024 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2025 Ramon Santamaria (@raysan5) //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); byteCount += sprintf(txtData + byteCount, "//////////////////////////////////////////////////////////////////////////////////\n\n"); diff --git a/src/raylib.dll.rc b/src/raylib.dll.rc index 2f02b495c..7ad39c76f 100644 --- a/src/raylib.dll.rc +++ b/src/raylib.dll.rc @@ -13,7 +13,7 @@ BEGIN VALUE "FileDescription", "raylib dynamic library (www.raylib.com)" VALUE "FileVersion", "5.5.0" VALUE "InternalName", "raylib.dll" - VALUE "LegalCopyright", "(c) 2024 Ramon Santamaria (@raysan5)" + VALUE "LegalCopyright", "(c) 2025 Ramon Santamaria (@raysan5)" VALUE "OriginalFilename", "raylib.dll" VALUE "ProductName", "raylib" VALUE "ProductVersion", "5.5.0" diff --git a/src/raylib.dll.rc.data b/src/raylib.dll.rc.data index 64d2a1cd5708166afa50efa2611b82ee528088e0..db6b924a70a57a674f6ece692b44bac7e11eac6d 100644 GIT binary patch delta 6124 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 literal 11318 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 diff --git a/src/raylib.h b/src/raylib.h index 7e1a1f838..451091269 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -63,7 +63,7 @@ * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software: * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2025 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. diff --git a/src/raylib.rc b/src/raylib.rc index 327b2c4de..7de8382bd 100644 --- a/src/raylib.rc +++ b/src/raylib.rc @@ -13,7 +13,7 @@ BEGIN VALUE "FileDescription", "raylib application (www.raylib.com)" VALUE "FileVersion", "5.5.0" VALUE "InternalName", "raylib" - VALUE "LegalCopyright", "(c) 2024 Ramon Santamaria (@raysan5)" + VALUE "LegalCopyright", "(c) 2025 Ramon Santamaria (@raysan5)" VALUE "OriginalFilename", "raylib" VALUE "ProductName", "raylib app" VALUE "ProductVersion", "5.5.0" diff --git a/src/raylib.rc.data b/src/raylib.rc.data index ceeafa6822baa8ea52830c5c46ba6883212cc2f6..8727d21308057ce88f30f52cc39578fe8f733620 100644 GIT binary patch delta 6138 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 literal 11302 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 diff --git a/src/raymath.h b/src/raymath.h index 9d712027c..bee21b4f6 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -32,7 +32,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2015-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2015-2025 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. diff --git a/src/rcamera.h b/src/rcamera.h index ab998ae03..a598e1107 100644 --- a/src/rcamera.h +++ b/src/rcamera.h @@ -20,7 +20,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2022-2024 Christoph Wagner (@Crydsch) & Ramon Santamaria (@raysan5) +* Copyright (c) 2022-2025 Christoph Wagner (@Crydsch) & 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. diff --git a/src/rcore.c b/src/rcore.c index 17634a52c..2806235cc 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -70,7 +70,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) and contributors +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) and contributors * * 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. @@ -3000,7 +3000,7 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName) byteCount += sprintf(txtData + byteCount, "# more info and bugs-report: github.com/raysan5/raylib\n"); byteCount += sprintf(txtData + byteCount, "# feedback and support: ray[at]raylib.com\n"); byteCount += sprintf(txtData + byteCount, "#\n"); - byteCount += sprintf(txtData + byteCount, "# Copyright (c) 2023-2024 Ramon Santamaria (@raysan5)\n"); + byteCount += sprintf(txtData + byteCount, "# Copyright (c) 2023-2025 Ramon Santamaria (@raysan5)\n"); byteCount += sprintf(txtData + byteCount, "#\n\n"); // Add events data diff --git a/src/rgestures.h b/src/rgestures.h index b5624be56..1bf4e0555 100644 --- a/src/rgestures.h +++ b/src/rgestures.h @@ -21,7 +21,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2025 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. diff --git a/src/rglfw.c b/src/rglfw.c index 2282955a1..b167955bc 100644 --- a/src/rglfw.c +++ b/src/rglfw.c @@ -7,7 +7,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2017-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2017-2025 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. diff --git a/src/rlgl.h b/src/rlgl.h index 5fd523b3c..0f3a203e7 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -88,7 +88,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2025 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. diff --git a/src/rmodels.c b/src/rmodels.c index 70e461ea5..ed0ce9136 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -21,7 +21,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2025 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. @@ -1960,7 +1960,7 @@ bool ExportMesh(Mesh mesh, const char *fileName) byteCount += sprintf(txtData + byteCount, "# // more info and bugs-report: github.com/raysan5/raylib //\n"); byteCount += sprintf(txtData + byteCount, "# // feedback and support: ray[at]raylib.com //\n"); byteCount += sprintf(txtData + byteCount, "# // //\n"); - byteCount += sprintf(txtData + byteCount, "# // Copyright (c) 2018-2024 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "# // Copyright (c) 2018-2025 Ramon Santamaria (@raysan5) //\n"); byteCount += sprintf(txtData + byteCount, "# // //\n"); byteCount += sprintf(txtData + byteCount, "# //////////////////////////////////////////////////////////////////////////////////\n\n"); byteCount += sprintf(txtData + byteCount, "# Vertex Count: %i\n", mesh.vertexCount); diff --git a/src/rshapes.c b/src/rshapes.c index ece5513b3..f0da73575 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -25,7 +25,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2025 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. diff --git a/src/rtext.c b/src/rtext.c index b60c8cb1d..12c25e4e6 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -34,7 +34,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2025 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. @@ -989,7 +989,7 @@ bool ExportFontAsCode(Font font, const char *fileName) byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); - byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2024 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2025 Ramon Santamaria (@raysan5) //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); byteCount += sprintf(txtData + byteCount, "// ---------------------------------------------------------------------------------- //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); diff --git a/src/rtextures.c b/src/rtextures.c index e0ae5f4af..5248f1f4c 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -42,7 +42,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2013-2025 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. @@ -761,7 +761,7 @@ bool ExportImageAsCode(Image image, const char *fileName) byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); - byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2024 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2018-2025 Ramon Santamaria (@raysan5) //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n"); diff --git a/src/utils.c b/src/utils.c index c5d9748d4..5c189845b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -10,7 +10,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2025 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. @@ -308,7 +308,7 @@ bool ExportDataAsCode(const unsigned char *data, int dataSize, const char *fileN byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); - byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2022-2024 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2022-2025 Ramon Santamaria (@raysan5) //\n"); byteCount += sprintf(txtData + byteCount, "// //\n"); byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n"); diff --git a/src/utils.h b/src/utils.h index 23eca8ee9..271d0d2c7 100644 --- a/src/utils.h +++ b/src/utils.h @@ -5,7 +5,7 @@ * * LICENSE: zlib/libpng * -* Copyright (c) 2014-2024 Ramon Santamaria (@raysan5) +* Copyright (c) 2014-2025 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. From 0f6e85a975f637e14b1fed3ff6022a0e0008e620 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Wed, 1 Jan 2025 11:18:11 +0000 Subject: [PATCH 051/793] [build] CMake: Don't build examples using audio if audio is disabled (#4652) --- examples/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 64b6d7604..f77ece4c0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -124,7 +124,21 @@ endif () # The rlgl_standalone example only targets desktop, without shared libraries. if (BUILD_SHARED_LIBS OR NOT ${PLATFORM} MATCHES "Desktop") list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) +endif() +# The audio examples fail to link if raylib is built without raudio +if (NOT SUPPORT_MODULE_RAUDIO) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_mixed_processor.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_module_playing.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_music_stream.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_raw_stream.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_sound_loading.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_sound_multi.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio/audio_stream_effects.c) + + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/embedded_files_loading.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/textures/textures_sprite_button.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/textures/textures_sprite_explosion.c) endif() include_directories(BEFORE SYSTEM others/external/include) From 97fa3a73e82416fa7542dd50e8e96dd20a71d980 Mon Sep 17 00:00:00 2001 From: veins1 <19636663+veins1@users.noreply.github.com> Date: Fri, 3 Jan 2025 21:36:48 +0500 Subject: [PATCH 052/793] Fix: Alt-Tab not working in borderless fullscreen (#3865) (#4655) --- src/platforms/rcore_desktop_glfw.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index bd2600c87..0076ccb0d 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -223,11 +223,9 @@ void ToggleBorderlessWindowed(void) if (!wasOnFullscreen) CORE.Window.previousPosition = CORE.Window.position; CORE.Window.previousScreen = CORE.Window.screen; - // Set undecorated and topmost modes and flags + // Set undecorated flag glfwSetWindowAttrib(platform.handle, GLFW_DECORATED, GLFW_FALSE); CORE.Window.flags |= FLAG_WINDOW_UNDECORATED; - glfwSetWindowAttrib(platform.handle, GLFW_FLOATING, GLFW_TRUE); - CORE.Window.flags |= FLAG_WINDOW_TOPMOST; // Get monitor position and size int monitorPosX = 0; @@ -247,9 +245,7 @@ void ToggleBorderlessWindowed(void) } else { - // Remove topmost and undecorated modes and flags - glfwSetWindowAttrib(platform.handle, GLFW_FLOATING, GLFW_FALSE); - CORE.Window.flags &= ~FLAG_WINDOW_TOPMOST; + // Remove undecorated flag glfwSetWindowAttrib(platform.handle, GLFW_DECORATED, GLFW_TRUE); CORE.Window.flags &= ~FLAG_WINDOW_UNDECORATED; From 05c4d8a652e8b56932ffb87dbf8914bd82c19d22 Mon Sep 17 00:00:00 2001 From: Brian E <72316548+Brian-ED@users.noreply.github.com> Date: Sun, 5 Jan 2025 12:29:31 +0100 Subject: [PATCH 053/793] [rlgl.h] Fixed typo in top comment (#4658) "renderer" to "rendered" --- src/rlgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rlgl.h b/src/rlgl.h index 0f3a203e7..cb10fd7ab 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -10,7 +10,7 @@ * When choosing an OpenGL backend different than OpenGL 1.1, some internal buffer are * initialized on rlglInit() to accumulate vertex data * -* When an internal state change is required all the stored vertex data is renderer in batch, +* When an internal state change is required all the stored vertex data is rendered in batch, * additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch * * Some resources are also loaded for convenience, here the complete list: From 2f95e8382b7b5e93fa2c018510b917c166cb5db2 Mon Sep 17 00:00:00 2001 From: rexept <103546774+rexept@users.noreply.github.com> Date: Sun, 5 Jan 2025 04:30:06 -0700 Subject: [PATCH 054/793] typo fix (#4656) --- examples/core/core_3d_camera_split_screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/core/core_3d_camera_split_screen.c b/examples/core/core_3d_camera_split_screen.c index 5294e8949..313b64f65 100644 --- a/examples/core/core_3d_camera_split_screen.c +++ b/examples/core/core_3d_camera_split_screen.c @@ -63,7 +63,7 @@ int main(void) // Update //---------------------------------------------------------------------------------- // If anyone moves this frame, how far will they move based on the time since the last frame - // this moves thigns at 10 world units per second, regardless of the actual FPS + // this moves things at 10 world units per second, regardless of the actual FPS float offsetThisFrame = 10.0f*GetFrameTime(); // Move Player1 forward and backwards (no turning) @@ -171,4 +171,4 @@ int main(void) //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} From ad035edfacf18214b46a4739244e21b63db41ed1 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Sun, 5 Jan 2025 08:30:43 -0300 Subject: [PATCH 055/793] Fix camera initial position (#4657) --- src/platforms/rcore_desktop_glfw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 0076ccb0d..dba821ddd 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1017,6 +1017,9 @@ void EnableCursor(void) // Disables cursor (lock cursor) void DisableCursor(void) { + // Reset mouse position within the window area before disabling cursor + SetMousePosition(CORE.Window.screen.width, CORE.Window.screen.height); + glfwSetInputMode(platform.handle, GLFW_CURSOR, GLFW_CURSOR_DISABLED); // Set cursor position in the middle From fc29bc27fd1c6904143fc24fbcf5ca629ec491c6 Mon Sep 17 00:00:00 2001 From: Maicon Santana Date: Mon, 6 Jan 2025 10:29:24 +0000 Subject: [PATCH 056/793] Fix Touch pointCount reduction (#4661) --- src/platforms/rcore_web.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 9fd2afb5a..78fd46f50 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -1812,7 +1812,23 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) { - CORE.Input.Touch.pointCount--; + // Identify the EMSCRIPTEN_EVENT_TOUCHEND and remove it from the list + for (int i = 0; i < CORE.Input.Touch.pointCount; i++) + { + if (touchEvent->touches[i].isChanged) + { + // Move all touch points one position up + for (int j = i; j < CORE.Input.Touch.pointCount - 1; j++) + { + CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[j + 1]; + CORE.Input.Touch.position[j] = CORE.Input.Touch.position[j + 1]; + } + // Decrease touch points count to remove the last one + CORE.Input.Touch.pointCount--; + break; + } + } + // Clamp pointCount to avoid negative values if (CORE.Input.Touch.pointCount < 0) CORE.Input.Touch.pointCount = 0; } From 5d9aed5d4063158bbc3634e6889ba2dd979412b0 Mon Sep 17 00:00:00 2001 From: "K. Adam Christensen" Date: Wed, 8 Jan 2025 09:53:27 -0800 Subject: [PATCH 057/793] [rlgl] Optimize rlReadScreenPixels (#4667) This optimization works in the following ways: 1. Reduces calls to malloc to 1. Instead of needing an extra array, we can just swap the top half with the bottom half of the one array. 2. Unroll the inner for loop and remove a condition. Unrolling loops buys some performance wins, but the real goal was to remove the if check and just set the alpha channel to 255. On my hidpi arm64 laptop, I saw ~60% improvement in performance in my debug build (29 FPS vs 47 FPS). When optimized, the gains were roughly 10% (75 FPS vs 83%). Signed-off-by: K. Adam Christensen --- src/rlgl.h | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/rlgl.h b/src/rlgl.h index cb10fd7ab..574b860b0 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -3666,29 +3666,37 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format) // Read screen pixel data (color buffer) unsigned char *rlReadScreenPixels(int width, int height) { - unsigned char *screenData = (unsigned char *)RL_CALLOC(width*height*4, sizeof(unsigned char)); + unsigned char *imgData = (unsigned char *)RL_CALLOC(width*height*4, sizeof(unsigned char)); // NOTE 1: glReadPixels returns image flipped vertically -> (0,0) is the bottom left corner of the framebuffer // NOTE 2: We are getting alpha channel! Be careful, it can be transparent if not cleared properly! - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, screenData); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, imgData); // Flip image vertically! - unsigned char *imgData = (unsigned char *)RL_MALLOC(width*height*4*sizeof(unsigned char)); - - for (int y = height - 1; y >= 0; y--) + // NOTE: Alpha value has already been applied to RGB in framebuffer, we don't need it! + for (int y = height - 1; y >= height / 2; y--) { - for (int x = 0; x < (width*4); x++) + for (int x = 0; x < (width*4); x += 4) { - imgData[((height - 1) - y)*width*4 + x] = screenData[(y*width*4) + x]; // Flip line + size_t s = ((height - 1) - y)*width*4 + x; + size_t e = y*width*4 + x; - // Set alpha component value to 255 (no trasparent image retrieval) - // NOTE: Alpha value has already been applied to RGB in framebuffer, we don't need it! - if (((x + 1)%4) == 0) imgData[((height - 1) - y)*width*4 + x] = 255; + unsigned char r = imgData[s]; + unsigned char g = imgData[s+1]; + unsigned char b = imgData[s+2]; + + imgData[s] = imgData[e]; + imgData[s+1] = imgData[e+1]; + imgData[s+2] = imgData[e+2]; + imgData[s+3] = 255; // Set alpha component value to 255 (no trasparent image retrieval) + + imgData[e] = r; + imgData[e+1] = g; + imgData[e+2] = b; + imgData[e+3] = 255; // Ditto } } - RL_FREE(screenData); - return imgData; // NOTE: image data should be freed } From ddd86a33874b407f9f0cbb7a095c9e72c9ed3b47 Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Thu, 9 Jan 2025 00:07:59 +0100 Subject: [PATCH 058/793] [rshapes] Fix pixel offset issue with line drawing (#4666) * fix pixel offset issue with `DrawRectangleRoundedLinesEx` * improve fix - (pixel offset issue with `DrawRectangleRoundedLinesEx`) * revert radius tweak (`DrawRectangleRoundedLines`) --- src/rshapes.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/rshapes.c b/src/rshapes.c index f0da73575..07c685b6e 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1160,18 +1160,29 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f P5 ================== P4 */ const Vector2 point[16] = { - {(float)rec.x + innerRadius, rec.y - lineThick}, {(float)(rec.x + rec.width) - innerRadius, rec.y - lineThick}, { rec.x + rec.width + lineThick, (float)rec.y + innerRadius }, // PO, P1, P2 - {rec.x + rec.width + lineThick, (float)(rec.y + rec.height) - innerRadius}, {(float)(rec.x + rec.width) - innerRadius, rec.y + rec.height + lineThick}, // P3, P4 - {(float)rec.x + innerRadius, rec.y + rec.height + lineThick}, { rec.x - lineThick, (float)(rec.y + rec.height) - innerRadius}, {rec.x - lineThick, (float)rec.y + innerRadius}, // P5, P6, P7 - {(float)rec.x + innerRadius, rec.y}, {(float)(rec.x + rec.width) - innerRadius, rec.y}, // P8, P9 - { rec.x + rec.width, (float)rec.y + innerRadius }, {rec.x + rec.width, (float)(rec.y + rec.height) - innerRadius}, // P10, P11 - {(float)(rec.x + rec.width) - innerRadius, rec.y + rec.height}, {(float)rec.x + innerRadius, rec.y + rec.height}, // P12, P13 - { rec.x, (float)(rec.y + rec.height) - innerRadius}, {rec.x, (float)rec.y + innerRadius} // P14, P15 + {(float)rec.x + innerRadius + 0.5f, rec.y - lineThick + 0.5f}, + {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y - lineThick + 0.5f}, + {rec.x + rec.width + lineThick - 0.5f, (float)rec.y + innerRadius + 0.5f}, // PO, P1, P2 + {rec.x + rec.width + lineThick - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height + lineThick - 0.5f}, // P3, P4 + {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height + lineThick - 0.5f}, + {rec.x - lineThick + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {rec.x - lineThick + 0.5f, (float)rec.y + innerRadius + 0.5f}, // P5, P6, P7 + {(float)rec.x + innerRadius + 0.5f, rec.y + 0.5f}, + {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + 0.5f}, // P8, P9 + {rec.x + rec.width - 0.5f, (float)rec.y + innerRadius + 0.5f}, + {rec.x + rec.width - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, // P10, P11 + {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height - 0.5f}, + {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height - 0.5f}, // P12, P13 + {rec.x + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {rec.x + 0.5f, (float)rec.y + innerRadius + 0.5f} // P14, P15 }; const Vector2 centers[4] = { - {(float)rec.x + innerRadius, (float)rec.y + innerRadius}, {(float)(rec.x + rec.width) - innerRadius, (float)rec.y + innerRadius}, // P16, P17 - {(float)(rec.x + rec.width) - innerRadius, (float)(rec.y + rec.height) - innerRadius}, {(float)rec.x + innerRadius, (float)(rec.y + rec.height) - innerRadius} // P18, P19 + {(float)rec.x + innerRadius + 0.5f, (float)rec.y + innerRadius + 0.5f}, + {(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)rec.y + innerRadius + 0.5f}, // P16, P17 + {(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {(float)rec.x + innerRadius + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f} // P18, P19 }; const float angles[4] = { 180.0f, 270.0f, 0.0f, 90.0f }; From bf8962dbc7233d9814b45d83d7a7b91b8335fb52 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 10 Jan 2025 13:06:28 +0100 Subject: [PATCH 059/793] REVIEWED: Remove some `const` from text buffer return values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lately got some compilation `errors` related, it seems GCC 14 interprets some `const`-missmatch as errors instead of warnings (as previous versions). But in any case, I don't see why an user won't be able to operate directly over of those returned buffers; `const` adds a restriction (for security reasons?) that in my opinion is useless. From an expert on compilers (w64devkit creator), here there are some notes I agree with: ``` No const. It serves no practical role in optimization, and I cannot recall an instance where it caught, or would have caught, a mistake. I held out for awhile as prototype documentation, but on reflection I found that good parameter names were sufficient. Dropping const has made me noticeably more productive by reducing cognitive load and eliminating visual clutter. I now believe its inclusion in C was a costly mistake. (One small exception: I still like it as a hint to place static tables in read-only memory closer to the code. I’ll cast away the const if needed. This is only of minor importance.) ``` Ref: https://nullprogram.com/blog/2023/10/08/ --- src/raylib.h | 14 +++++++------- src/rtext.c | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index 451091269..f59e1c041 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1510,15 +1510,15 @@ RLAPI const char *TextFormat(const char *text, ...); RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string RLAPI char *TextReplace(const char *text, const char *replace, const char *by); // Replace text string (WARNING: memory must be freed!) RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (WARNING: memory must be freed!) -RLAPI const char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter -RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings +RLAPI char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter +RLAPI char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor! RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string -RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string -RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string -RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string -RLAPI const char *TextToSnake(const char *text); // Get Snake case notation version of provided string -RLAPI const char *TextToCamel(const char *text); // Get Camel case notation version of provided string +RLAPI char *TextToUpper(const char *text); // Get upper case version of provided string +RLAPI char *TextToLower(const char *text); // Get lower case version of provided string +RLAPI char *TextToPascal(const char *text); // Get Pascal case notation version of provided string +RLAPI char *TextToSnake(const char *text); // Get Snake case notation version of provided string +RLAPI char *TextToCamel(const char *text); // Get Camel case notation version of provided string RLAPI int TextToInteger(const char *text); // Get integer value from text RLAPI float TextToFloat(const char *text); // Get float value from text diff --git a/src/rtext.c b/src/rtext.c index 12c25e4e6..e22e14778 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1629,7 +1629,7 @@ char *TextInsert(const char *text, const char *insert, int position) // Join text strings with delimiter // REQUIRES: memset(), memcpy() -const char *TextJoin(const char **textList, int count, const char *delimiter) +char *TextJoin(const char **textList, int count, const char *delimiter) { static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); @@ -1663,7 +1663,7 @@ const char *TextJoin(const char **textList, int count, const char *delimiter) // Split string into multiple strings // REQUIRES: memset() -const char **TextSplit(const char *text, char delimiter, int *count) +char **TextSplit(const char *text, char delimiter, int *count) { // NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter) // inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated, @@ -1671,7 +1671,7 @@ const char **TextSplit(const char *text, char delimiter, int *count) // 1. Maximum number of possible split strings is set by MAX_TEXTSPLIT_COUNT // 2. Maximum size of text to split is MAX_TEXT_BUFFER_LENGTH - static const char *result[MAX_TEXTSPLIT_COUNT] = { NULL }; + static char *result[MAX_TEXTSPLIT_COUNT] = { NULL }; static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); @@ -1727,7 +1727,7 @@ int TextFindIndex(const char *text, const char *find) // Get upper case version of provided string // WARNING: Limited functionality, only basic characters set // TODO: Support UTF-8 diacritics to upper-case, check codepoints -const char *TextToUpper(const char *text) +char *TextToUpper(const char *text) { static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); @@ -1746,7 +1746,7 @@ const char *TextToUpper(const char *text) // Get lower case version of provided string // WARNING: Limited functionality, only basic characters set -const char *TextToLower(const char *text) +char *TextToLower(const char *text) { static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); @@ -1765,7 +1765,7 @@ const char *TextToLower(const char *text) // Get Pascal case notation version of provided string // WARNING: Limited functionality, only basic characters set -const char *TextToPascal(const char *text) +char *TextToPascal(const char *text) { static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); @@ -1793,7 +1793,7 @@ const char *TextToPascal(const char *text) // Get snake case notation version of provided string // WARNING: Limited functionality, only basic characters set -const char *TextToSnake(const char *text) +char *TextToSnake(const char *text) { static char buffer[MAX_TEXT_BUFFER_LENGTH] = {0}; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); @@ -1821,7 +1821,7 @@ const char *TextToSnake(const char *text) // Get Camel case notation version of provided string // WARNING: Limited functionality, only basic characters set -const char *TextToCamel(const char *text) +char *TextToCamel(const char *text) { static char buffer[MAX_TEXT_BUFFER_LENGTH] = {0}; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); From 433cc23ea4511fbeddc0fccc597cde91f5756d59 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 10 Jan 2025 12:06:46 +0000 Subject: [PATCH 060/793] Update raylib_api.* by CI --- parser/output/raylib_api.json | 14 +++++++------- parser/output/raylib_api.lua | 14 +++++++------- parser/output/raylib_api.txt | 14 +++++++------- parser/output/raylib_api.xml | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index 853f591d4..c7ebeaf38 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -9675,7 +9675,7 @@ { "name": "TextJoin", "description": "Join text strings with delimiter", - "returnType": "const char *", + "returnType": "char *", "params": [ { "type": "const char **", @@ -9694,7 +9694,7 @@ { "name": "TextSplit", "description": "Split text into multiple strings", - "returnType": "const char **", + "returnType": "char **", "params": [ { "type": "const char *", @@ -9747,7 +9747,7 @@ { "name": "TextToUpper", "description": "Get upper case version of provided string", - "returnType": "const char *", + "returnType": "char *", "params": [ { "type": "const char *", @@ -9758,7 +9758,7 @@ { "name": "TextToLower", "description": "Get lower case version of provided string", - "returnType": "const char *", + "returnType": "char *", "params": [ { "type": "const char *", @@ -9769,7 +9769,7 @@ { "name": "TextToPascal", "description": "Get Pascal case notation version of provided string", - "returnType": "const char *", + "returnType": "char *", "params": [ { "type": "const char *", @@ -9780,7 +9780,7 @@ { "name": "TextToSnake", "description": "Get Snake case notation version of provided string", - "returnType": "const char *", + "returnType": "char *", "params": [ { "type": "const char *", @@ -9791,7 +9791,7 @@ { "name": "TextToCamel", "description": "Get Camel case notation version of provided string", - "returnType": "const char *", + "returnType": "char *", "params": [ { "type": "const char *", diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index 2983456f3..d3130a7d9 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -6891,7 +6891,7 @@ return { { name = "TextJoin", description = "Join text strings with delimiter", - returnType = "const char *", + returnType = "char *", params = { {type = "const char **", name = "textList"}, {type = "int", name = "count"}, @@ -6901,7 +6901,7 @@ return { { name = "TextSplit", description = "Split text into multiple strings", - returnType = "const char **", + returnType = "char **", params = { {type = "const char *", name = "text"}, {type = "char", name = "delimiter"}, @@ -6930,7 +6930,7 @@ return { { name = "TextToUpper", description = "Get upper case version of provided string", - returnType = "const char *", + returnType = "char *", params = { {type = "const char *", name = "text"} } @@ -6938,7 +6938,7 @@ return { { name = "TextToLower", description = "Get lower case version of provided string", - returnType = "const char *", + returnType = "char *", params = { {type = "const char *", name = "text"} } @@ -6946,7 +6946,7 @@ return { { name = "TextToPascal", description = "Get Pascal case notation version of provided string", - returnType = "const char *", + returnType = "char *", params = { {type = "const char *", name = "text"} } @@ -6954,7 +6954,7 @@ return { { name = "TextToSnake", description = "Get Snake case notation version of provided string", - returnType = "const char *", + returnType = "char *", params = { {type = "const char *", name = "text"} } @@ -6962,7 +6962,7 @@ return { { name = "TextToCamel", description = "Get Camel case notation version of provided string", - returnType = "const char *", + returnType = "char *", params = { {type = "const char *", name = "text"} } diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index 038b43e17..4d2ed2c93 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -3704,14 +3704,14 @@ Function 429: TextInsert() (3 input parameters) Param[3]: position (type: int) Function 430: TextJoin() (3 input parameters) Name: TextJoin - Return type: const char * + Return type: char * Description: Join text strings with delimiter Param[1]: textList (type: const char **) Param[2]: count (type: int) Param[3]: delimiter (type: const char *) Function 431: TextSplit() (3 input parameters) Name: TextSplit - Return type: const char ** + Return type: char ** Description: Split text into multiple strings Param[1]: text (type: const char *) Param[2]: delimiter (type: char) @@ -3731,27 +3731,27 @@ Function 433: TextFindIndex() (2 input parameters) Param[2]: find (type: const char *) Function 434: TextToUpper() (1 input parameters) Name: TextToUpper - Return type: const char * + Return type: char * Description: Get upper case version of provided string Param[1]: text (type: const char *) Function 435: TextToLower() (1 input parameters) Name: TextToLower - Return type: const char * + Return type: char * Description: Get lower case version of provided string Param[1]: text (type: const char *) Function 436: TextToPascal() (1 input parameters) Name: TextToPascal - Return type: const char * + Return type: char * Description: Get Pascal case notation version of provided string Param[1]: text (type: const char *) Function 437: TextToSnake() (1 input parameters) Name: TextToSnake - Return type: const char * + Return type: char * Description: Get Snake case notation version of provided string Param[1]: text (type: const char *) Function 438: TextToCamel() (1 input parameters) Name: TextToCamel - Return type: const char * + Return type: char * Description: Get Camel case notation version of provided string Param[1]: text (type: const char *) Function 439: TextToInteger() (1 input parameters) diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index 734f96465..c2c645977 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -2453,12 +2453,12 @@ - + - + @@ -2472,19 +2472,19 @@ - + - + - + - + - + From b554b53ede67a934e3c0b9bf971fc57629be640f Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:36:52 +0100 Subject: [PATCH 061/793] fix pixel offset issue with `DrawRectangleLines` (#4669) --- src/rshapes.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/rshapes.c b/src/rshapes.c index 07c685b6e..f482079c8 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -807,22 +807,25 @@ void DrawRectangleGradientEx(Rectangle rec, Color topLeft, Color bottomLeft, Col // but it solves another issue: https://github.com/raysan5/raylib/issues/3884 void DrawRectangleLines(int posX, int posY, int width, int height, Color color) { - Matrix mat = rlGetMatrixModelview(); - float zoomFactor = 0.5f/mat.m0; + Matrix mat = rlGetMatrixTransform(); + float xOffset = 0.5f/mat.m0; + float yOffset = 0.5f/mat.m5; + rlBegin(RL_LINES); rlColor4ub(color.r, color.g, color.b, color.a); - rlVertex2f((float)posX - zoomFactor, (float)posY); - rlVertex2f((float)posX + (float)width + zoomFactor, (float)posY); + rlVertex2f((float)posX + xOffset, (float)posY + yOffset); + rlVertex2f((float)posX + (float)width - xOffset, (float)posY + yOffset); - rlVertex2f((float)posX + (float)width, (float)posY - zoomFactor); - rlVertex2f((float)posX + (float)width, (float)posY + (float)height + zoomFactor); + rlVertex2f((float)posX + (float)width - xOffset, (float)posY + yOffset); + rlVertex2f((float)posX + (float)width - xOffset, (float)posY + (float)height - yOffset); - rlVertex2f((float)posX + (float)width + zoomFactor, (float)posY + (float)height); - rlVertex2f((float)posX - zoomFactor, (float)posY + (float)height); + rlVertex2f((float)posX + (float)width - xOffset, (float)posY + (float)height - yOffset); + rlVertex2f((float)posX + xOffset, (float)posY + (float)height - yOffset); - rlVertex2f((float)posX, (float)posY + (float)height + zoomFactor); - rlVertex2f((float)posX, (float)posY - zoomFactor); + rlVertex2f((float)posX + xOffset, (float)posY + (float)height - yOffset); + rlVertex2f((float)posX + xOffset, (float)posY + yOffset); rlEnd(); + /* // Previous implementation, it has issues... but it does not require view matrix... #if defined(SUPPORT_QUADS_DRAW_MODE) @@ -845,7 +848,7 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color) rlVertex2f((float)posX + 1, (float)posY + (float)height); rlVertex2f((float)posX + 1, (float)posY + 1); rlEnd(); -//#endif +#endif */ } From eee86dd7c9b7b71aad131f56ebeb9ad6dd05ca69 Mon Sep 17 00:00:00 2001 From: Le Juez Victor <90587919+Bigfoot71@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:37:57 +0100 Subject: [PATCH 062/793] [build][CMake] Fix cmake configuration issue for Android (#4671) * fix cmake configuration issue for Android * review comment --- cmake/LibraryConfigurations.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake index fb7898306..00dda033a 100644 --- a/cmake/LibraryConfigurations.cmake +++ b/cmake/LibraryConfigurations.cmake @@ -69,6 +69,14 @@ elseif (${PLATFORM} MATCHES "Android") set(CMAKE_POSITION_INDEPENDENT_CODE ON) list(APPEND raylib_sources ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) include_directories(${ANDROID_NDK}/sources/android/native_app_glue) + + # NOTE: We remove '-Wl,--no-undefined' (set by default) as it conflicts with '-Wl,-undefined,dynamic_lookup' needed + # for compiling with the missing 'void main(void)' declaration in `android_main()`. + # We also remove other unnecessary or problematic flags. + + string(REPLACE "-Wl,--no-undefined -Qunused-arguments" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + string(REPLACE "-static-libstdc++" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -u ANativeActivity_onCreate -Wl,-undefined,dynamic_lookup") find_library(OPENGL_LIBRARY OpenGL) From 43dbaf21e7aff7f97148fe3f860d16ef571a2d04 Mon Sep 17 00:00:00 2001 From: Hakunamawatta <48947000+Hakunamawatta@users.noreply.github.com> Date: Sat, 11 Jan 2025 03:40:13 +1100 Subject: [PATCH 063/793] [examples] Fix broken link (#4674) --- examples/text/text_draw_3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/text/text_draw_3d.c b/examples/text/text_draw_3d.c index ed4e6ce67..8d23b0450 100644 --- a/examples/text/text_draw_3d.c +++ b/examples/text/text_draw_3d.c @@ -286,7 +286,7 @@ int main(void) DrawGrid(10, 2.0f); // Use a shader to handle the depth buffer issue with transparent textures - // NOTE: more info at https://bedroomcoders.co.uk/raylib-billboards-advanced-use/ + // NOTE: more info at https://bedroomcoders.co.uk/posts/198 BeginShaderMode(alphaDiscard); // Draw the 3D text above the red cube From 34f431b422d8d9850c4bec85d33449e60c27610f Mon Sep 17 00:00:00 2001 From: Michael Kearns <1312115+mobiuscog@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:40:48 +0000 Subject: [PATCH 064/793] Update xcode-frameworks dependency for latest zig (#4675) * Update build.zig.zon for latest framework commit * Update build.zig.zon with correct hash * Update build.zig.zon with the 'really' correct hash --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 557028e45..077865978 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .xcode_frameworks = .{ - .url = "git+https://github.com/hexops/xcode-frameworks#a6bf82e032d4d9923ad5c222d466710fcc05f249", - .hash = "12208da4dfcd9b53fb367375fb612ec73f38e53015f1ce6ae6d6e8437a637078e170", + .url = "git+https://github.com/hexops/xcode-frameworks#9a45f3ac977fd25dff77e58c6de1870b6808c4a7", + .hash = "122098b9174895f9708bc824b0f9e550c401892c40a900006459acf2cbf78acd99bb", .lazy = true, }, .emsdk = .{ From 08b089f620c361e68f82782463c9e9a318d15d1f Mon Sep 17 00:00:00 2001 From: veins1 <19636663+veins1@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:41:40 +0500 Subject: [PATCH 065/793] Reviewed shaders_deferred_render (#4676) Fixed: g-buffer textures binding Fixed: Clearing screen with white would leak onto g-buffer textures Reviewed comments --- examples/shaders/shaders_deferred_render.c | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/shaders/shaders_deferred_render.c b/examples/shaders/shaders_deferred_render.c index 52c713aa7..e5c549e5a 100644 --- a/examples/shaders/shaders_deferred_render.c +++ b/examples/shaders/shaders_deferred_render.c @@ -134,14 +134,15 @@ int main(void) } // Now we initialize the sampler2D uniform's in the deferred shader. - // We do this by setting the uniform's value to the color channel slot we earlier - // bound our textures to. + // We do this by setting the uniform's values to the texture units that + // we later bind our g-buffer textures to. rlEnableShader(deferredShader.id); - - rlSetUniformSampler(rlGetLocationUniform(deferredShader.id, "gPosition"), 0); - rlSetUniformSampler(rlGetLocationUniform(deferredShader.id, "gNormal"), 1); - rlSetUniformSampler(rlGetLocationUniform(deferredShader.id, "gAlbedoSpec"), 2); - + int texUnitPosition = 0; + int texUnitNormal = 1; + int texUnitAlbedoSpec = 2; + SetShaderValue(deferredShader, rlGetLocationUniform(deferredShader.id, "gPosition"), &texUnitPosition, RL_SHADER_UNIFORM_SAMPLER2D); + SetShaderValue(deferredShader, rlGetLocationUniform(deferredShader.id, "gNormal"), &texUnitNormal, RL_SHADER_UNIFORM_SAMPLER2D); + SetShaderValue(deferredShader, rlGetLocationUniform(deferredShader.id, "gAlbedoSpec"), &texUnitAlbedoSpec, RL_SHADER_UNIFORM_SAMPLER2D); rlDisableShader(); // Assign out lighting shader to model @@ -208,11 +209,10 @@ int main(void) // Draw // --------------------------------------------------------------------------------- BeginDrawing(); - - ClearBackground(RAYWHITE); - + // Draw to the geometry buffer by first activating it rlEnableFramebuffer(gBuffer.framebuffer); + rlClearColor(0, 0, 0, 0); rlClearScreenBuffers(); // Clear color and depth buffer rlDisableColorBlend(); @@ -246,14 +246,14 @@ int main(void) BeginMode3D(camera); rlDisableColorBlend(); rlEnableShader(deferredShader.id); - // Activate our g-buffer textures - // These will now be bound to the sampler2D uniforms `gPosition`, `gNormal`, + // Bind our g-buffer textures + // We are binding them to locations that we earlier set in sampler2D uniforms `gPosition`, `gNormal`, // and `gAlbedoSpec` - rlActiveTextureSlot(0); + rlActiveTextureSlot(texUnitPosition); rlEnableTexture(gBuffer.positionTexture); - rlActiveTextureSlot(1); + rlActiveTextureSlot(texUnitNormal); rlEnableTexture(gBuffer.normalTexture); - rlActiveTextureSlot(2); + rlActiveTextureSlot(texUnitAlbedoSpec); rlEnableTexture(gBuffer.albedoSpecTexture); // Finally, we draw a fullscreen quad to our default framebuffer @@ -269,8 +269,8 @@ int main(void) rlBlitFramebuffer(0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, 0x00000100); // GL_DEPTH_BUFFER_BIT rlDisableFramebuffer(); - // Since our shader is now done and disabled, we can draw our lights in default - // forward rendering + // Since our shader is now done and disabled, we can draw spheres + // that represent light positions in default forward rendering BeginMode3D(camera); rlEnableShader(rlGetShaderIdDefault()); for(int i = 0; i < MAX_LIGHTS; i++) From 2b2694a89fdfa85a90ce6e311d2477f2bca7be5d Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 10 Jan 2025 22:36:11 +0100 Subject: [PATCH 066/793] Fix #4680 --- src/rcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rcore.c b/src/rcore.c index 2806235cc..a90a60387 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1931,7 +1931,7 @@ bool IsFileExtension(const char *fileName, const char *ext) { #if defined(SUPPORT_MODULE_RTEXT) && defined(SUPPORT_TEXT_MANIPULATION) int extCount = 0; - const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext + char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext char fileExtLower[MAX_FILE_EXTENSION_LENGTH + 1] = { 0 }; strncpy(fileExtLower, TextToLower(fileExt), MAX_FILE_EXTENSION_LENGTH); // WARNING: Module required: rtext From 62d8969a56909a4721114860cbe1350b5dcb20eb Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 10 Jan 2025 22:56:25 +0100 Subject: [PATCH 067/793] Reviewed shader formating --- .../shaders/resources/shaders/glsl100/pbr.fs | 157 +++++++++--------- .../shaders/resources/shaders/glsl100/pbr.vs | 19 +-- 2 files changed, 91 insertions(+), 85 deletions(-) diff --git a/examples/shaders/resources/shaders/glsl100/pbr.fs b/examples/shaders/resources/shaders/glsl100/pbr.fs index 70e3b4885..a9cf1a3e0 100644 --- a/examples/shaders/resources/shaders/glsl100/pbr.fs +++ b/examples/shaders/resources/shaders/glsl100/pbr.fs @@ -59,97 +59,104 @@ uniform float ambient; // incrase reflectivity when surface view at larger angle vec3 schlickFresnel(float hDotV,vec3 refl) { - return refl + (1.0 - refl) * pow(1.0 - hDotV,5.0); + return refl + (1.0 - refl)*pow(1.0 - hDotV,5.0); } -float ggxDistribution(float nDotH,float roughness) +float ggxDistribution(float nDotH, float roughness) { - float a = roughness * roughness * roughness * roughness; - float d = nDotH * nDotH * (a - 1.0) + 1.0; - d = PI * d * d; - return a / max(d,0.0000001); + float a = roughness*roughness*roughness*roughness; + float d = nDotH*nDotH*(a - 1.0) + 1.0; + d = PI*d*d; + return a/max(d,0.0000001); } -float geomSmith(float nDotV,float nDotL,float roughness) +float geomSmith(float nDotV, float nDotL, float roughness) { - float r = roughness + 1.0; - float k = r * r / 8.0; - float ik = 1.0 - k; - float ggx1 = nDotV / (nDotV * ik + k); - float ggx2 = nDotL / (nDotL * ik + k); - return ggx1 * ggx2; + float r = roughness + 1.0; + float k = r*r/8.0; + float ik = 1.0 - k; + float ggx1 = nDotV/(nDotV*ik + k); + float ggx2 = nDotL/(nDotL*ik + k); + return ggx1*ggx2; } -vec3 pbr(){ - vec3 albedo = texture2D(albedoMap,vec2(fragTexCoord.x*tiling.x+offset.x,fragTexCoord.y*tiling.y+offset.y)).rgb; - albedo = vec3(albedoColor.x*albedo.x,albedoColor.y*albedo.y,albedoColor.z*albedo.z); - float metallic = clamp(metallicValue,0.0,1.0); - float roughness = clamp(roughnessValue,0.0,1.0); - float ao = clamp(aoValue,0.0,1.0); - if(useTexMRA == 1) { - vec4 mra = texture2D(mraMap, vec2(fragTexCoord.x * tiling.x + offset.x, fragTexCoord.y * tiling.y + offset.y)); - metallic = clamp(mra.r+metallicValue,0.04,1.0); - roughness = clamp(mra.g+roughnessValue,0.04,1.0); - ao = (mra.b+aoValue)*0.5; - } +vec3 pbr() +{ + vec3 albedo = texture2D(albedoMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb; + albedo = vec3(albedoColor.x*albedo.x, albedoColor.y*albedo.y, albedoColor.z*albedo.z); + + float metallic = clamp(metallicValue, 0.0, 1.0); + float roughness = clamp(roughnessValue, 0.0, 1.0); + float ao = clamp(aoValue, 0.0, 1.0); + + if (useTexMRA == 1) + { + vec4 mra = texture2D(mraMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)); + metallic = clamp(mra.r + metallicValue, 0.04, 1.0); + roughness = clamp(mra.g + roughnessValue, 0.04, 1.0); + ao = (mra.b + aoValue)*0.5; + } + vec3 N = normalize(fragNormal); + if (useTexNormal == 1) + { + N = texture2D(normalMap, vec2(fragTexCoord.x*tiling.x + offset.y, fragTexCoord.y*tiling.y + offset.y)).rgb; + N = normalize(N*2.0 - 1.0); + N = normalize(N*TBN); + } + + vec3 V = normalize(viewPos - fragPosition); + + vec3 e = vec3(0); + e = (texture2D(emissiveMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb).g*emissiveColor.rgb*emissivePower*float(useTexEmissive); + + // return N;//vec3(metallic,metallic,metallic); + // If dia-electric use base reflectivity of 0.04 otherwise ut is a metal use albedo as base reflectivity + vec3 baseRefl = mix(vec3(0.04), albedo.rgb, metallic); + vec3 Lo = vec3(0.0); // Acumulate lighting lum + for (int i = 0; i < 4; i++) + { + vec3 L = normalize(lights[i].position - fragPosition); // Compute light vector + vec3 H = normalize(V + L); // Compute halfway bisecting vector + float dist = length(lights[i].position - fragPosition); // Compute distance to light + float attenuation = 1.0/(dist*dist*0.23); // Compute attenuation + vec3 radiance = lights[i].color.rgb*lights[i].intensity*attenuation; // Compute input radiance, light energy comming in - vec3 N = normalize(fragNormal); - if(useTexNormal == 1) { - N = texture2D(normalMap, vec2(fragTexCoord.x * tiling.x + offset.y, fragTexCoord.y * tiling.y + offset.y)).rgb; - N = normalize(N * 2.0 - 1.0); - N = normalize(N * TBN); - } + // Cook-Torrance BRDF distribution function + float nDotV = max(dot(N,V), 0.0000001); + float nDotL = max(dot(N,L), 0.0000001); + float hDotV = max(dot(H,V), 0.0); + float nDotH = max(dot(N,H), 0.0); + float D = ggxDistribution(nDotH, roughness); // Larger the more micro-facets aligned to H + float G = geomSmith(nDotV, nDotL, roughness); // Smaller the more micro-facets shadow + vec3 F = schlickFresnel(hDotV, baseRefl); // Fresnel proportion of specular reflectance + + vec3 spec = (D*G*F)/(4.0*nDotV*nDotL); - vec3 V = normalize(viewPos - fragPosition); + // Difuse and spec light can't be above 1.0 + // kD = 1.0 - kS diffuse component is equal 1.0 - spec comonent + vec3 kD = vec3(1.0) - F; - vec3 e = vec3(0); - e = (texture2D(emissiveMap, vec2(fragTexCoord.x*tiling.x+offset.x, fragTexCoord.y*tiling.y+offset.y)).rgb).g * emissiveColor.rgb*emissivePower * float(useTexEmissive); - - //return N;//vec3(metallic,metallic,metallic); - //if dia-electric use base reflectivity of 0.04 otherwise ut is a metal use albedo as base reflectivity - vec3 baseRefl = mix(vec3(0.04),albedo.rgb,metallic); - vec3 Lo = vec3(0.0); // acumulate lighting lum - - for(int i=0;i<4;++i){ - - vec3 L = normalize(lights[i].position - fragPosition); // calc light vector - vec3 H = normalize(V + L); // calc halfway bisecting vector - float dist = length(lights[i].position - fragPosition); // calc distance to light - float attenuation = 1.0 / (dist * dist * 0.23); // calc attenuation - vec3 radiance = lights[i].color.rgb * lights[i].intensity * attenuation; // calc input radiance,light energy comming in - - //Cook-Torrance BRDF distribution function - float nDotV = max(dot(N,V),0.0000001); - float nDotL = max(dot(N,L),0.0000001); - float hDotV = max(dot(H,V),0.0); - float nDotH = max(dot(N,H),0.0); - float D = ggxDistribution(nDotH,roughness); // larger the more micro-facets aligned to H - float G = geomSmith(nDotV,nDotL,roughness); // smaller the more micro-facets shadow - vec3 F = schlickFresnel(hDotV, baseRefl); // fresnel proportion of specular reflectance - - vec3 spec = (D * G * F) / (4.0 * nDotV * nDotL); - // difuse and spec light can't be above 1.0 - // kD = 1.0 - kS diffuse component is equal 1.0 - spec comonent - vec3 kD = vec3(1.0) - F; - //mult kD by the inverse of metallnes , only non-metals should have diffuse light - kD *= 1.0 - metallic; - Lo += ((kD * albedo.rgb / PI + spec) * radiance * nDotL)*float(lights[i].enabled); // angle of light has impact on result - } - vec3 ambient_final = (ambientColor + albedo)* ambient * 0.5; - return ambient_final+Lo*ao+e; + // Mult kD by the inverse of metallnes , only non-metals should have diffuse light + kD *= 1.0 - metallic; + Lo += ((kD*albedo.rgb/PI + spec)*radiance*nDotL)*float(lights[i].enabled); // Angle of light has impact on result + } + + vec3 ambientFinal = (ambientColor + albedo)*ambient*0.5; + + return (ambientFinal + Lo*ao + e); } void main() { - vec3 color = pbr(); - - //HDR tonemapping - color = pow(color,color + vec3(1.0)); - //gamma correction - color = pow(color,vec3(1.0/2.2)); + vec3 color = pbr(); + + // HDR tonemapping + color = pow(color,color + vec3(1.0)); + + // Gamma correction + color = pow(color,vec3(1.0/2.2)); - gl_FragColor = vec4(color,1.0); - + gl_FragColor = vec4(color,1.0); } diff --git a/examples/shaders/resources/shaders/glsl100/pbr.vs b/examples/shaders/resources/shaders/glsl100/pbr.vs index 87e142e07..5a93f784f 100644 --- a/examples/shaders/resources/shaders/glsl100/pbr.vs +++ b/examples/shaders/resources/shaders/glsl100/pbr.vs @@ -26,17 +26,17 @@ const float normalOffset = 0.1; // https://github.com/glslify/glsl-inverse mat3 inverse(mat3 m) { - float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; - float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; - float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; + float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; + float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; + float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; - float b01 = a22*a11 - a12*a21; - float b11 = -a22*a10 + a12*a20; - float b21 = a21*a10 - a11*a20; + float b01 = a22*a11 - a12*a21; + float b11 = -a22*a10 + a12*a20; + float b21 = a21*a10 - a11*a20; - float det = a00*b01 + a01*b11 + a02*b21; + float det = a00*b01 + a01*b11 + a02*b21; - return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11), + return mat3(b01, (-a22*a01 + a02*a21), (a12*a01 - a02*a11), b11, (a22*a00 - a02*a20), (-a12*a00 + a02*a10), b21, (-a21*a00 + a01*a20), (a11*a00 - a01*a10))/det; } @@ -44,14 +44,13 @@ mat3 inverse(mat3 m) // https://github.com/glslify/glsl-transpose mat3 transpose(mat3 m) { - return mat3(m[0][0], m[1][0], m[2][0], + return mat3(m[0][0], m[1][0], m[2][0], m[0][1], m[1][1], m[2][1], m[0][2], m[1][2], m[2][2]); } void main() { - // calc binormal from vertex normal and tangent vec3 vertexBinormal = cross(vertexNormal, vertexTangent); // calc fragment normal based on normal transformations From 49b905077d3e2eb3c39efb466a7a7f8ff7c3034b Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 11 Jan 2025 19:36:26 +0100 Subject: [PATCH 068/793] remove trailing spaces --- src/rshapes.c | 22 +++++++++++----------- src/rtext.c | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/rshapes.c b/src/rshapes.c index f482079c8..7b967fbdb 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1163,28 +1163,28 @@ void DrawRectangleRoundedLinesEx(Rectangle rec, float roundness, int segments, f P5 ================== P4 */ const Vector2 point[16] = { - {(float)rec.x + innerRadius + 0.5f, rec.y - lineThick + 0.5f}, - {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y - lineThick + 0.5f}, + {(float)rec.x + innerRadius + 0.5f, rec.y - lineThick + 0.5f}, + {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y - lineThick + 0.5f}, {rec.x + rec.width + lineThick - 0.5f, (float)rec.y + innerRadius + 0.5f}, // PO, P1, P2 - {rec.x + rec.width + lineThick - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {rec.x + rec.width + lineThick - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height + lineThick - 0.5f}, // P3, P4 - {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height + lineThick - 0.5f}, - {rec.x - lineThick + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height + lineThick - 0.5f}, + {rec.x - lineThick + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {rec.x - lineThick + 0.5f, (float)rec.y + innerRadius + 0.5f}, // P5, P6, P7 - {(float)rec.x + innerRadius + 0.5f, rec.y + 0.5f}, + {(float)rec.x + innerRadius + 0.5f, rec.y + 0.5f}, {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + 0.5f}, // P8, P9 - {rec.x + rec.width - 0.5f, (float)rec.y + innerRadius + 0.5f}, + {rec.x + rec.width - 0.5f, (float)rec.y + innerRadius + 0.5f}, {rec.x + rec.width - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, // P10, P11 - {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height - 0.5f}, + {(float)(rec.x + rec.width) - innerRadius - 0.5f, rec.y + rec.height - 0.5f}, {(float)rec.x + innerRadius + 0.5f, rec.y + rec.height - 0.5f}, // P12, P13 - {rec.x + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {rec.x + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {rec.x + 0.5f, (float)rec.y + innerRadius + 0.5f} // P14, P15 }; const Vector2 centers[4] = { - {(float)rec.x + innerRadius + 0.5f, (float)rec.y + innerRadius + 0.5f}, + {(float)rec.x + innerRadius + 0.5f, (float)rec.y + innerRadius + 0.5f}, {(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)rec.y + innerRadius + 0.5f}, // P16, P17 - {(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, + {(float)(rec.x + rec.width) - innerRadius - 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f}, {(float)rec.x + innerRadius + 0.5f, (float)(rec.y + rec.height) - innerRadius - 0.5f} // P18, P19 }; diff --git a/src/rtext.c b/src/rtext.c index e22e14778..b93fa1c32 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -247,8 +247,8 @@ extern void LoadFontDefault(void) // we must consider data as little-endian order (alpha + gray) ((unsigned short *)imFont.data)[i + j] = 0xffff; } - else - { + else + { ((unsigned char *)imFont.data)[(i + j)*sizeof(short)] = 0xFF; ((unsigned char *)imFont.data)[(i + j)*sizeof(short) + 1] = 0x00; } From 8e450e4446b10999cdd6464abc39ad5986d6f6af Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 11 Jan 2025 19:36:46 +0100 Subject: [PATCH 069/793] Reviewed shaders formating to follow raylib coding conventions --- .../shaders/resources/shaders/glsl100/pbr.fs | 57 +++--- .../shaders/resources/shaders/glsl100/pbr.vs | 12 +- .../shaders/resources/shaders/glsl120/pbr.fs | 165 +++++++++--------- .../shaders/resources/shaders/glsl120/pbr.vs | 41 +++-- .../shaders/resources/shaders/glsl330/pbr.fs | 18 +- .../shaders/resources/shaders/glsl330/pbr.vs | 6 +- 6 files changed, 151 insertions(+), 148 deletions(-) diff --git a/examples/shaders/resources/shaders/glsl100/pbr.fs b/examples/shaders/resources/shaders/glsl100/pbr.fs index a9cf1a3e0..48688ebe9 100644 --- a/examples/shaders/resources/shaders/glsl100/pbr.fs +++ b/examples/shaders/resources/shaders/glsl100/pbr.fs @@ -54,23 +54,22 @@ uniform vec3 viewPos; uniform vec3 ambientColor; uniform float ambient; -// refl in range 0 to 1 -// returns base reflectivity to 1 -// incrase reflectivity when surface view at larger angle -vec3 schlickFresnel(float hDotV,vec3 refl) +// Reflectivity in range 0.0 to 1.0 +// NOTE: Reflectivity is increased when surface view at larger angle +vec3 SchlickFresnel(float hDotV,vec3 refl) { - return refl + (1.0 - refl)*pow(1.0 - hDotV,5.0); + return refl + (1.0 - refl)*pow(1.0 - hDotV, 5.0); } -float ggxDistribution(float nDotH, float roughness) +float GgxDistribution(float nDotH,float roughness) { float a = roughness*roughness*roughness*roughness; float d = nDotH*nDotH*(a - 1.0) + 1.0; d = PI*d*d; - return a/max(d,0.0000001); + return (a/max(d,0.0000001)); } -float geomSmith(float nDotV, float nDotL, float roughness) +float GeomSmith(float nDotV,float nDotL,float roughness) { float r = roughness + 1.0; float k = r*r/8.0; @@ -80,7 +79,7 @@ float geomSmith(float nDotV, float nDotL, float roughness) return ggx1*ggx2; } -vec3 pbr() +vec3 ComputePBR() { vec3 albedo = texture2D(albedoMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb; albedo = vec3(albedoColor.x*albedo.x, albedoColor.y*albedo.y, albedoColor.z*albedo.z); @@ -104,23 +103,23 @@ vec3 pbr() N = normalize(N*2.0 - 1.0); N = normalize(N*TBN); } - + vec3 V = normalize(viewPos - fragPosition); - - vec3 e = vec3(0); - e = (texture2D(emissiveMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb).g*emissiveColor.rgb*emissivePower*float(useTexEmissive); - + + vec3 emissive = vec3(0); + emissive = (texture2D(emissiveMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb).g*emissiveColor.rgb*emissivePower*float(useTexEmissive); + // return N;//vec3(metallic,metallic,metallic); // If dia-electric use base reflectivity of 0.04 otherwise ut is a metal use albedo as base reflectivity vec3 baseRefl = mix(vec3(0.04), albedo.rgb, metallic); - vec3 Lo = vec3(0.0); // Acumulate lighting lum + vec3 lightAccum = vec3(0.0); // Acumulate lighting lum for (int i = 0; i < 4; i++) { - vec3 L = normalize(lights[i].position - fragPosition); // Compute light vector - vec3 H = normalize(V + L); // Compute halfway bisecting vector - float dist = length(lights[i].position - fragPosition); // Compute distance to light - float attenuation = 1.0/(dist*dist*0.23); // Compute attenuation + vec3 L = normalize(lights[i].position - fragPosition); // Compute light vector + vec3 H = normalize(V + L); // Compute halfway bisecting vector + float dist = length(lights[i].position - fragPosition); // Compute distance to light + float attenuation = 1.0/(dist*dist*0.23); // Compute attenuation vec3 radiance = lights[i].color.rgb*lights[i].intensity*attenuation; // Compute input radiance, light energy comming in // Cook-Torrance BRDF distribution function @@ -128,9 +127,9 @@ vec3 pbr() float nDotL = max(dot(N,L), 0.0000001); float hDotV = max(dot(H,V), 0.0); float nDotH = max(dot(N,H), 0.0); - float D = ggxDistribution(nDotH, roughness); // Larger the more micro-facets aligned to H - float G = geomSmith(nDotV, nDotL, roughness); // Smaller the more micro-facets shadow - vec3 F = schlickFresnel(hDotV, baseRefl); // Fresnel proportion of specular reflectance + float D = GgxDistribution(nDotH, roughness); // Larger the more micro-facets aligned to H + float G = GeomSmith(nDotV, nDotL, roughness); // Smaller the more micro-facets shadow + vec3 F = SchlickFresnel(hDotV, baseRefl); // Fresnel proportion of specular reflectance vec3 spec = (D*G*F)/(4.0*nDotV*nDotL); @@ -138,25 +137,25 @@ vec3 pbr() // kD = 1.0 - kS diffuse component is equal 1.0 - spec comonent vec3 kD = vec3(1.0) - F; - // Mult kD by the inverse of metallnes , only non-metals should have diffuse light + // Mult kD by the inverse of metallnes, only non-metals should have diffuse light kD *= 1.0 - metallic; - Lo += ((kD*albedo.rgb/PI + spec)*radiance*nDotL)*float(lights[i].enabled); // Angle of light has impact on result + lightAccum += ((kD*albedo.rgb/PI + spec)*radiance*nDotL)*float(lights[i].enabled); // Angle of light has impact on result } vec3 ambientFinal = (ambientColor + albedo)*ambient*0.5; - return (ambientFinal + Lo*ao + e); + return (ambientFinal + lightAccum*ao + emissive); } void main() { - vec3 color = pbr(); - + vec3 color = ComputePBR(); + // HDR tonemapping - color = pow(color,color + vec3(1.0)); + color = pow(color, color + vec3(1.0)); // Gamma correction - color = pow(color,vec3(1.0/2.2)); + color = pow(color, vec3(1.0/2.2)); gl_FragColor = vec4(color,1.0); } diff --git a/examples/shaders/resources/shaders/glsl100/pbr.vs b/examples/shaders/resources/shaders/glsl100/pbr.vs index 5a93f784f..a55c0ea4b 100644 --- a/examples/shaders/resources/shaders/glsl100/pbr.vs +++ b/examples/shaders/resources/shaders/glsl100/pbr.vs @@ -51,16 +51,16 @@ mat3 transpose(mat3 m) void main() { - // calc binormal from vertex normal and tangent + // Compute binormal from vertex normal and tangent vec3 vertexBinormal = cross(vertexNormal, vertexTangent); - // calc fragment normal based on normal transformations - mat3 normalMatrix = transpose(inverse(mat3(matModel))); - // calc fragment position based on model transformations + // Compute fragment normal based on normal transformations + mat3 normalMatrix = transpose(inverse(mat3(matModel))); + + // Compute fragment position based on model transformations fragPosition = vec3(matModel*vec4(vertexPosition, 1.0)); fragTexCoord = vertexTexCoord*2.0; - fragNormal = normalize(normalMatrix*vertexNormal); vec3 fragTangent = normalize(normalMatrix*vertexTangent); fragTangent = normalize(fragTangent - dot(fragTangent, fragNormal)*fragNormal); @@ -70,5 +70,5 @@ void main() TBN = transpose(mat3(fragTangent, fragBinormal, fragNormal)); // Calculate final vertex position - gl_Position = mvp * vec4(vertexPosition, 1.0); + gl_Position = mvp*vec4(vertexPosition, 1.0); } diff --git a/examples/shaders/resources/shaders/glsl120/pbr.fs b/examples/shaders/resources/shaders/glsl120/pbr.fs index 1c5eee00b..63241709b 100644 --- a/examples/shaders/resources/shaders/glsl120/pbr.fs +++ b/examples/shaders/resources/shaders/glsl120/pbr.fs @@ -22,7 +22,6 @@ varying vec3 fragNormal; varying vec4 shadowPos; varying mat3 TBN; - // Input uniform values uniform int numOfLights; uniform sampler2D albedoMap; @@ -53,102 +52,108 @@ uniform vec3 viewPos; uniform vec3 ambientColor; uniform float ambient; -// refl in range 0 to 1 -// returns base reflectivity to 1 -// incrase reflectivity when surface view at larger angle -vec3 schlickFresnel(float hDotV,vec3 refl) +// Reflectivity in range 0.0 to 1.0 +// NOTE: Reflectivity is increased when surface view at larger angle +vec3 SchlickFresnel(float hDotV,vec3 refl) { - return refl + (1.0 - refl) * pow(1.0 - hDotV,5.0); + return refl + (1.0 - refl)*pow(1.0 - hDotV, 5.0); } -float ggxDistribution(float nDotH,float roughness) +float GgxDistribution(float nDotH,float roughness) { - float a = roughness * roughness * roughness * roughness; - float d = nDotH * nDotH * (a - 1.0) + 1.0; - d = PI * d * d; - return a / max(d,0.0000001); + float a = roughness*roughness*roughness*roughness; + float d = nDotH*nDotH*(a - 1.0) + 1.0; + d = PI*d*d; + return (a/max(d,0.0000001)); } -float geomSmith(float nDotV,float nDotL,float roughness) +float GeomSmith(float nDotV,float nDotL,float roughness) { - float r = roughness + 1.0; - float k = r * r / 8.0; - float ik = 1.0 - k; - float ggx1 = nDotV / (nDotV * ik + k); - float ggx2 = nDotL / (nDotL * ik + k); - return ggx1 * ggx2; + float r = roughness + 1.0; + float k = r*r/8.0; + float ik = 1.0 - k; + float ggx1 = nDotV/(nDotV*ik + k); + float ggx2 = nDotL/(nDotL*ik + k); + return ggx1*ggx2; } -vec3 pbr(){ - vec3 albedo = texture2D(albedoMap,vec2(fragTexCoord.x*tiling.x+offset.x,fragTexCoord.y*tiling.y+offset.y)).rgb; - albedo = vec3(albedoColor.x*albedo.x,albedoColor.y*albedo.y,albedoColor.z*albedo.z); - float metallic = clamp(metallicValue,0.0,1.0); - float roughness = clamp(roughnessValue,0.0,1.0); - float ao = clamp(aoValue,0.0,1.0); - if(useTexMRA == 1) { - vec4 mra = texture2D(mraMap, vec2(fragTexCoord.x * tiling.x + offset.x, fragTexCoord.y * tiling.y + offset.y)); - metallic = clamp(mra.r+metallicValue,0.04,1.0); - roughness = clamp(mra.g+roughnessValue,0.04,1.0); - ao = (mra.b+aoValue)*0.5; - } +vec3 ComputePBR() +{ + vec3 albedo = texture2D(albedoMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb; + albedo = vec3(albedoColor.x*albedo.x, albedoColor.y*albedo.y, albedoColor.z*albedo.z); + + float metallic = clamp(metallicValue, 0.0, 1.0); + float roughness = clamp(roughnessValue, 0.0, 1.0); + float ao = clamp(aoValue, 0.0, 1.0); + + if (useTexMRA == 1) + { + vec4 mra = texture2D(mraMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)); + metallic = clamp(mra.r + metallicValue, 0.04, 1.0); + roughness = clamp(mra.g + roughnessValue, 0.04, 1.0); + ao = (mra.b + aoValue)*0.5; + } + vec3 N = normalize(fragNormal); + if (useTexNormal == 1) + { + N = texture2D(normalMap, vec2(fragTexCoord.x*tiling.x + offset.y, fragTexCoord.y*tiling.y + offset.y)).rgb; + N = normalize(N*2.0 - 1.0); + N = normalize(N*TBN); + } + vec3 V = normalize(viewPos - fragPosition); - vec3 N = normalize(fragNormal); - if(useTexNormal == 1) { - N = texture2D(normalMap, vec2(fragTexCoord.x * tiling.x + offset.y, fragTexCoord.y * tiling.y + offset.y)).rgb; - N = normalize(N * 2.0 - 1.0); - N = normalize(N * TBN); - } + vec3 emissive = vec3(0); + emissive = (texture2D(emissiveMap, vec2(fragTexCoord.x*tiling.x + offset.x, fragTexCoord.y*tiling.y + offset.y)).rgb).g*emissiveColor.rgb*emissivePower*float(useTexEmissive); + + // return N;//vec3(metallic,metallic,metallic); + // If dia-electric use base reflectivity of 0.04 otherwise ut is a metal use albedo as base reflectivity + vec3 baseRefl = mix(vec3(0.04), albedo.rgb, metallic); + vec3 lightAccum = vec3(0.0); // Acumulate lighting lum + + for (int i = 0; i < 4; i++) + { + vec3 L = normalize(lights[i].position - fragPosition); // Compute light vector + vec3 H = normalize(V + L); // Compute halfway bisecting vector + float dist = length(lights[i].position - fragPosition); // Compute distance to light + float attenuation = 1.0/(dist*dist*0.23); // Compute attenuation + vec3 radiance = lights[i].color.rgb*lights[i].intensity*attenuation; // Compute input radiance, light energy comming in + + // Cook-Torrance BRDF distribution function + float nDotV = max(dot(N,V), 0.0000001); + float nDotL = max(dot(N,L), 0.0000001); + float hDotV = max(dot(H,V), 0.0); + float nDotH = max(dot(N,H), 0.0); + float D = GgxDistribution(nDotH, roughness); // Larger the more micro-facets aligned to H + float G = GeomSmith(nDotV, nDotL, roughness); // Smaller the more micro-facets shadow + vec3 F = SchlickFresnel(hDotV, baseRefl); // Fresnel proportion of specular reflectance + + vec3 spec = (D*G*F)/(4.0*nDotV*nDotL); - vec3 V = normalize(viewPos - fragPosition); + // Difuse and spec light can't be above 1.0 + // kD = 1.0 - kS diffuse component is equal 1.0 - spec comonent + vec3 kD = vec3(1.0) - F; - vec3 e = vec3(0); - e = (texture2D(emissiveMap, vec2(fragTexCoord.x*tiling.x+offset.x, fragTexCoord.y*tiling.y+offset.y)).rgb).g * emissiveColor.rgb*emissivePower * float(useTexEmissive); - - //return N;//vec3(metallic,metallic,metallic); - //if dia-electric use base reflectivity of 0.04 otherwise ut is a metal use albedo as base reflectivity - vec3 baseRefl = mix(vec3(0.04),albedo.rgb,metallic); - vec3 Lo = vec3(0.0); // acumulate lighting lum - - for(int i=0;i Date: Sat, 11 Jan 2025 23:38:21 +0100 Subject: [PATCH 070/793] REVIEWED: `TextJoin()`, convert `const char **` to `char**` It generates multiple issues: https://c-faq.com/ansi/constmismatch.html --- src/raylib.h | 2 +- src/rtext.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index f59e1c041..27a8ab049 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1510,7 +1510,7 @@ RLAPI const char *TextFormat(const char *text, ...); RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string RLAPI char *TextReplace(const char *text, const char *replace, const char *by); // Replace text string (WARNING: memory must be freed!) RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (WARNING: memory must be freed!) -RLAPI char *TextJoin(const char **textList, int count, const char *delimiter); // Join text strings with delimiter +RLAPI char *TextJoin(char **textList, int count, const char *delimiter); // Join text strings with delimiter RLAPI char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor! RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string diff --git a/src/rtext.c b/src/rtext.c index b93fa1c32..d8d290053 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1629,7 +1629,7 @@ char *TextInsert(const char *text, const char *insert, int position) // Join text strings with delimiter // REQUIRES: memset(), memcpy() -char *TextJoin(const char **textList, int count, const char *delimiter) +char *TextJoin(char **textList, int count, const char *delimiter) { static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); From 43db59d1aa65ce9a8359fd76675402271547f9da Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 11 Jan 2025 22:38:42 +0000 Subject: [PATCH 071/793] Update raylib_api.* by CI --- parser/output/raylib_api.json | 2 +- parser/output/raylib_api.lua | 2 +- parser/output/raylib_api.txt | 2 +- parser/output/raylib_api.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index c7ebeaf38..0044de007 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -9678,7 +9678,7 @@ "returnType": "char *", "params": [ { - "type": "const char **", + "type": "char **", "name": "textList" }, { diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index d3130a7d9..ccf61cb0b 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -6893,7 +6893,7 @@ return { description = "Join text strings with delimiter", returnType = "char *", params = { - {type = "const char **", name = "textList"}, + {type = "char **", name = "textList"}, {type = "int", name = "count"}, {type = "const char *", name = "delimiter"} } diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index 4d2ed2c93..896efbaff 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -3706,7 +3706,7 @@ Function 430: TextJoin() (3 input parameters) Name: TextJoin Return type: char * Description: Join text strings with delimiter - Param[1]: textList (type: const char **) + Param[1]: textList (type: char **) Param[2]: count (type: int) Param[3]: delimiter (type: const char *) Function 431: TextSplit() (3 input parameters) diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index c2c645977..241b28ae8 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -2454,7 +2454,7 @@ - + From a1896c7a90f241336a216e6fb1bc26dee4603912 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 12 Jan 2025 16:19:10 +0100 Subject: [PATCH 072/793] REVIEWED: Code/Web-Makefile formatting --- examples/Makefile | 30 +-- examples/Makefile.Web | 38 +-- examples/core/core_random_sequence.c | 264 ++++++++++---------- examples/shapes/shapes_rectangle_advanced.c | 156 +++++++----- projects/4coder/Makefile | 24 +- projects/VSCode/Makefile | 24 +- src/Makefile | 19 +- src/minshell.html | 8 +- src/shell.html | 8 +- 9 files changed, 302 insertions(+), 269 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 12d798b50..f8c26f340 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -330,20 +330,20 @@ endif ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -sUSE_GLFW=3 # Use glfw3 library (context/input management) - # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) - # -sUSE_PTHREADS=1 # multithreading support - # -sWASM=0 # disable Web Assembly, emitted by default - # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS - # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation # --source-map-base # allow debugging in browser with source map - + # --shell-file shell.html # define a custom shell .html and output extension ifeq ($(TARGET_PLATFORM),PLATFORM_WEB) LDFLAGS += -sUSE_GLFW=3 endif @@ -547,10 +547,11 @@ SHAPES = \ shapes/shapes_lines_bezier \ shapes/shapes_logo_raylib \ shapes/shapes_logo_raylib_anim \ + shapes/shapes_rectangle_advanced \ shapes/shapes_rectangle_scaling \ shapes/shapes_splines_drawing \ - shapes/shapes_top_down_lights \ - shapes/shapes_rectangle_advanced + shapes/shapes_top_down_lights + TEXTURES = \ textures/textures_background_scrolling \ @@ -603,6 +604,7 @@ MODELS = \ models/models_draw_cube_texture \ models/models_first_person_maze \ models/models_geometric_shapes \ + models/models_gpu_skinning \ models/models_heightmap \ models/models_loading \ models/models_loading_gltf \ @@ -614,9 +616,9 @@ MODELS = \ models/models_point_rendering \ models/models_rlgl_solar_system \ models/models_skybox \ + models/models_tesseract_view \ models/models_waving_cubes \ - models/models_yaw_pitch_roll \ - models/models_gpu_skinning + models/models_yaw_pitch_roll SHADERS = \ shaders/shaders_basic_lighting \ diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 90345f97d..d44b99dde 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -266,25 +266,25 @@ endif ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -sUSE_GLFW=3 # Use glfw3 library (context/input management) - # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) - # -sUSE_PTHREADS=1 # multithreading support - # -sWASM=0 # disable Web Assembly, emitted by default - # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS - # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation # --source-map-base # allow debugging in browser with source map - + # --shell-file shell.html # define a custom shell .html and output extension ifeq ($(PLATFORM),PLATFORM_WEB) LDFLAGS += -sUSE_GLFW=3 endif - LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall + LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall -s # Build using asyncify ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) @@ -428,10 +428,10 @@ SHAPES = \ shapes/shapes_lines_bezier \ shapes/shapes_logo_raylib \ shapes/shapes_logo_raylib_anim \ + shapes/shapes_rectangle_advanced \ shapes/shapes_rectangle_scaling \ shapes/shapes_splines_drawing \ - shapes/shapes_top_down_lights \ - shapes/shapes_rectangle_advanced + shapes/shapes_top_down_lights TEXTURES = \ textures/textures_background_scrolling \ @@ -477,7 +477,6 @@ TEXT = \ MODELS = \ models/models_animation \ - models/models_gpu_skinning \ models/models_billboard \ models/models_bone_socket \ models/models_box_collisions \ @@ -485,6 +484,7 @@ MODELS = \ models/models_draw_cube_texture \ models/models_first_person_maze \ models/models_geometric_shapes \ + models/models_gpu_skinning \ models/models_heightmap \ models/models_loading \ models/models_loading_gltf \ @@ -496,6 +496,7 @@ MODELS = \ models/models_point_rendering \ models/models_rlgl_solar_system \ models/models_skybox \ + models/models_tesseract_view \ models/models_waving_cubes \ models/models_yaw_pitch_roll @@ -524,8 +525,8 @@ SHADERS = \ shaders/shaders_texture_outline \ shaders/shaders_texture_tiling \ shaders/shaders_texture_waves \ - shaders/shaders_write_depth \ - shaders/shaders_vertex_displacement + shaders/shaders_vertex_displacement \ + shaders/shaders_write_depth AUDIO = \ audio/audio_mixed_processor \ @@ -637,7 +638,7 @@ core/core_input_multitouch: core/core_input_multitouch.c core/core_input_virtual_controls: core/core_input_virtual_controls.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-s USE_PTHREADS=1) +# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-sUSE_PTHREADS=1) # WARNING: For security reasons multi-threading is not supported on browsers, it requires cross-origin isolation (Oct.2021) # WARNING: It requires raylib to be compiled using -pthread, so atomic operations and thread-local data (if any) # in its source were transformed to non-atomic operations and non-thread-local data @@ -998,6 +999,9 @@ models/models_skybox: models/models_skybox.c --preload-file models/resources/shaders/glsl100/cubemap.vs@resources/shaders/glsl100/cubemap.vs \ --preload-file models/resources/shaders/glsl100/cubemap.fs@resources/shaders/glsl100/cubemap.fs +models/models_tesseract_view: models/models_tesseract_view.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) + models/models_waving_cubes: models/models_waving_cubes.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) diff --git a/examples/core/core_random_sequence.c b/examples/core/core_random_sequence.c index 2f7c3be95..417440449 100644 --- a/examples/core/core_random_sequence.c +++ b/examples/core/core_random_sequence.c @@ -18,159 +18,169 @@ #include // Required for: malloc() and free() -typedef struct ColorRect{ - Color c; - Rectangle r; +typedef struct ColorRect { + Color c; + Rectangle r; } ColorRect; +//------------------------------------------------------------------------------------ +// Module functions declaration +//------------------------------------------------------------------------------------ static Color GenerateRandomColor(); -static ColorRect* GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight); -static void ShuffleColorRectSequence(ColorRect* rectangles, int rectCount); -static void DrawTextCenterKeyHelp(const char* key, const char* text, int posX, int posY, int fontSize, Color color); +static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight); +static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount); +static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color); //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ -int main(void) { - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [core] example - Generates a random sequence"); + InitWindow(screenWidth, screenHeight, "raylib [core] example - Generates a random sequence"); - int rectCount = 20; - float rectSize = (float)screenWidth/rectCount; - ColorRect* rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight); + int rectCount = 20; + float rectSize = (float)screenWidth/rectCount; + ColorRect *rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight); - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - if(IsKeyPressed(KEY_SPACE)) + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key { - ShuffleColorRectSequence(rectangles, rectCount); + // Update + //---------------------------------------------------------------------------------- + if (IsKeyPressed(KEY_SPACE)) ShuffleColorRectSequence(rectangles, rectCount); + + if (IsKeyPressed(KEY_UP)) + { + rectCount++; + rectSize = (float)screenWidth/rectCount; + free(rectangles); + rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight); + } + + if (IsKeyPressed(KEY_DOWN)) + { + if (rectCount >= 4) + { + rectCount--; + rectSize = (float)screenWidth/rectCount; + free(rectangles); + rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f*screenHeight); + } + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + int fontSize = 20; + for (int i = 0; i < rectCount; i++) + { + DrawRectangleRec(rectangles[i].r, rectangles[i].c); + DrawTextCenterKeyHelp("SPACE", "to shuffle the sequence.", 10, screenHeight - 96, fontSize, BLACK); + DrawTextCenterKeyHelp("UP", "to add a rectangle and generate a new sequence.", 10, screenHeight - 64, fontSize, BLACK); + DrawTextCenterKeyHelp("DOWN", "to remove a rectangle and generate a new sequence.", 10, screenHeight - 32, fontSize, BLACK); + } + + const char *rectCountText = TextFormat("%d rectangles", rectCount); + int rectCountTextSize = MeasureText(rectCountText, fontSize); + DrawText(rectCountText, screenWidth - rectCountTextSize - 10, 10, fontSize, BLACK); + + DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- } - if(IsKeyPressed(KEY_UP)) - { - rectCount++; - rectSize = (float)screenWidth/rectCount; - free(rectangles); - rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight); - } + // De-Initialization + //-------------------------------------------------------------------------------------- + free(rectangles); + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- - if(IsKeyPressed(KEY_DOWN)) - { - if(rectCount >= 4){ - rectCount--; - rectSize = (float)screenWidth/rectCount; - free(rectangles); - rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight); - } - } - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - int fontSize = 20; - for(int x=0;xc = r2->c; - r1->r.height = r2->r.height; - r1->r.y = r2->r.y; - r2->c = tmp.c; - r2->r.height = tmp.r.height; - r2->r.y = tmp.r.y; - - } - UnloadRandomSequence(seq); + for (int i = 0; i < rectCount; i++) + { + int rectHeight = (int)Remap((float)seq[i], 0, rectCount - 1, 0, screenHeight); + + rectangles[i].c = GenerateRandomColor(); + rectangles[i].r = CLITERAL(Rectangle){ startX + i*rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight }; + } + + UnloadRandomSequence(seq); + + return rectangles; } -static void DrawTextCenterKeyHelp(const char* key, const char* text, int posX, int posY, int fontSize, Color color) +static void ShuffleColorRectSequence(ColorRect *rectangles, int rectCount) { - int spaceSize = MeasureText(" ", fontSize); - int pressSize = MeasureText("Press", fontSize); - int keySize = MeasureText(key, fontSize); - int textSize = MeasureText(text, fontSize); - int totalSize = pressSize + 2 * spaceSize + keySize + 2 * spaceSize + textSize; - int textSizeCurrent = 0; + int *seq = LoadRandomSequence(rectCount, 0, rectCount - 1); + + for (int i1 = 0; i1 < rectCount; i1++) + { + ColorRect *r1 = &rectangles[i1]; + ColorRect *r2 = &rectangles[seq[i1]]; - DrawText("Press", posX, posY, fontSize, color); - textSizeCurrent += pressSize + 2 * spaceSize; - DrawText(key, posX + textSizeCurrent, posY, fontSize, RED); - DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED); - textSizeCurrent += keySize + 2 * spaceSize; - DrawText(text, posX + textSizeCurrent, posY, fontSize, color); + // Swap only the color and height + ColorRect tmp = *r1; + r1->c = r2->c; + r1->r.height = r2->r.height; + r1->r.y = r2->r.y; + r2->c = tmp.c; + r2->r.height = tmp.r.height; + r2->r.y = tmp.r.y; + } + + UnloadRandomSequence(seq); +} + +static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, int posY, int fontSize, Color color) +{ + int spaceSize = MeasureText(" ", fontSize); + int pressSize = MeasureText("Press", fontSize); + int keySize = MeasureText(key, fontSize); + int textSize = MeasureText(text, fontSize); + int totalSize = pressSize + 2*spaceSize + keySize + 2*spaceSize + textSize; + int textSizeCurrent = 0; + + DrawText("Press", posX, posY, fontSize, color); + textSizeCurrent += pressSize + 2*spaceSize; + DrawText(key, posX + textSizeCurrent, posY, fontSize, RED); + DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED); + textSizeCurrent += keySize + 2*spaceSize; + DrawText(text, posX + textSizeCurrent, posY, fontSize, color); } \ No newline at end of file diff --git a/examples/shapes/shapes_rectangle_advanced.c b/examples/shapes/shapes_rectangle_advanced.c index e885a10ee..6dd7d2e7e 100644 --- a/examples/shapes/shapes_rectangle_advanced.c +++ b/examples/shapes/shapes_rectangle_advanced.c @@ -1,10 +1,87 @@ +/******************************************************************************************* +* +* raylib [shapes] example - Rectangle advanced +* +* Example originally created with raylib 5.5, last time updated with raylib 5.5 +* +* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software +* +* Copyright (c) 2024-2025 raylib contributors and Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + #include "raylib.h" + #include "rlgl.h" + #include // Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness -// Adapted from both `DrawRectangleRounded` and `DrawRectangleGradientH` -void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right) +static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right); + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [shapes] example - rectangle avanced"); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update rectangle bounds + //---------------------------------------------------------------------------------- + float width = GetScreenWidth()/2.0f, height = GetScreenHeight()/6.0f; + Rectangle rec = { + GetScreenWidth() / 2.0f - width/2, + GetScreenHeight() / 2.0f - 5*(height/2), + width, height + }; + //-------------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + ClearBackground(RAYWHITE); + + // Draw All Rectangles with different roundess for each side and different gradients + DrawRectangleRoundedGradientH(rec, 0.8f, 0.8f, 36, BLUE, RED); + + rec.y += rec.height + 1; + DrawRectangleRoundedGradientH(rec, 0.5f, 1.0f, 36, RED, PINK); + + rec.y += rec.height + 1; + DrawRectangleRoundedGradientH(rec, 1.0f, 0.5f, 36, RED, BLUE); + + rec.y += rec.height + 1; + DrawRectangleRoundedGradientH(rec, 0.0f, 1.0f, 36, BLUE, BLACK); + + rec.y += rec.height + 1; + DrawRectangleRoundedGradientH(rec, 1.0f, 0.0f, 36, BLUE, PINK); + EndDrawing(); + //-------------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} + +// Draw rectangle with rounded edges and horizontal gradient, with options to choose side of roundness +// NOTE: Adapted from both 'DrawRectangleRounded()' and 'DrawRectangleGradientH()' raylib [rshapes] implementations +static void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float roundnessRight, int segments, Color left, Color right) { // Neither side is rounded if ((roundnessLeft <= 0.0f && roundnessRight <= 0.0f) || (rec.width < 1) || (rec.height < 1 )) @@ -29,7 +106,7 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou float stepLength = 90.0f/(float)segments; /* - Diagram Copied here for reference, original at `DrawRectangleRounded` source code + Diagram Copied here for reference, original at 'DrawRectangleRounded()' source code P0____________________P1 /| |\ @@ -113,12 +190,9 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou } } - // - // Here we use the `Diagram` to guide ourselves to which point receives what color. - // + // Here we use the 'Diagram' to guide ourselves to which point receives what color // By choosing the color correctly associated with a pointe the gradient effect - // will naturally come from OpenGL interpolation. - // + // will naturally come from OpenGL interpolation // [2] Upper Rectangle rlColor4ub(left.r, left.g, left.b, left.a); @@ -187,27 +261,25 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou rlSetTexture(0); #else - // - // Here we use the `Diagram` to guide ourselves to which point receives what color. - // + // Here we use the 'Diagram' to guide ourselves to which point receives what color. // By choosing the color correctly associated with a pointe the gradient effect // will naturally come from OpenGL interpolation. // But this time instead of Quad, we think in triangles. - // rlBegin(RL_TRIANGLES); - // Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner for (int k = 0; k < 4; ++k) { - Color color; - float radius; + Color color = { 0 }; + float radius = 0.0f; if (k == 0) color = left, radius = radiusLeft; // [1] Upper Left Corner if (k == 1) color = right, radius = radiusRight; // [3] Upper Right Corner if (k == 2) color = right, radius = radiusRight; // [5] Lower Right Corner if (k == 3) color = left, radius = radiusLeft; // [7] Lower Left Corner + float angle = angles[k]; const Vector2 center = centers[k]; + for (int i = 0; i < segments; i++) { rlColor4ub(color.r, color.g, color.b, color.a); @@ -274,57 +346,3 @@ void DrawRectangleRoundedGradientH(Rectangle rec, float roundnessLeft, float rou rlEnd(); #endif } - -int main(int argc, char *argv[]) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - rectangle avanced"); - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update rectangle bounds - //---------------------------------------------------------------------------------- - float width = GetScreenWidth()/2.0f, height = GetScreenHeight()/6.0f; - Rectangle rec = { - GetScreenWidth() / 2.0f - width/2, - GetScreenHeight() / 2.0f - (5)*(height/2), - width, height - }; - //-------------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - ClearBackground(RAYWHITE); - - // Draw All Rectangles with different roundess for each side and different gradients - DrawRectangleRoundedGradientH(rec, 0.8f, 0.8f, 36, BLUE, RED); - - rec.y += rec.height + 1; - DrawRectangleRoundedGradientH(rec, 0.5f, 1.0f, 36, RED, PINK); - - rec.y += rec.height + 1; - DrawRectangleRoundedGradientH(rec, 1.0f, 0.5f, 36, RED, BLUE); - - rec.y += rec.height + 1; - DrawRectangleRoundedGradientH(rec, 0.0f, 1.0f, 36, BLUE, BLACK); - - rec.y += rec.height + 1; - DrawRectangleRoundedGradientH(rec, 1.0f, 0.0f, 36, BLUE, PINK); - EndDrawing(); - //-------------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - return 0; -} - diff --git a/projects/4coder/Makefile b/projects/4coder/Makefile index 641731291..1b598eed5 100644 --- a/projects/4coder/Makefile +++ b/projects/4coder/Makefile @@ -219,21 +219,23 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 --preload-file resources + # --source-map-base # allow debugging in browser with source map + # --shell-file shell.html # define a custom shell .html and output extension + CFLAGS += -Os -sUSE_GLFW=3 -sTOTAL_MEMORY=16777216 --preload-file resources -sMINIFY_HTML=0 ifeq ($(BUILD_MODE), DEBUG) - CFLAGS += -s ASSERTIONS=1 --profiling + CFLAGS += -sASSERTIONS=1 --profiling endif # Define a custom shell .html and output extension diff --git a/projects/VSCode/Makefile b/projects/VSCode/Makefile index 72b850d9b..389a12cf9 100644 --- a/projects/VSCode/Makefile +++ b/projects/VSCode/Makefile @@ -225,21 +225,23 @@ endif ifeq ($(PLATFORM),PLATFORM_WEB) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -s USE_GLFW=3 # Use glfw3 library (context/input management) - # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -s USE_PTHREADS=1 # multithreading support - # -s WASM=0 # disable Web Assembly, emitted by default - # -s EMTERPRETIFY=1 # enable emscripten code interpreter (very slow) - # -s EMTERPRETIFY_ASYNC=1 # support synchronous loops by emterpreter - # -s FORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -s ASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation - CFLAGS += -Os -s USE_GLFW=3 -s TOTAL_MEMORY=16777216 --preload-file resources + # --source-map-base # allow debugging in browser with source map + # --shell-file shell.html # define a custom shell .html and output extension + CFLAGS += -Os -sUSE_GLFW=3 -sTOTAL_MEMORY=16777216 --preload-file resources -sMINIFY_HTML=0 ifeq ($(BUILD_MODE), DEBUG) - CFLAGS += -s ASSERTIONS=1 --profiling + CFLAGS += -sASSERTIONS=1 --profiling endif # Define a custom shell .html and output extension diff --git a/src/Makefile b/src/Makefile index 37554b2a0..a626db52e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -369,20 +369,23 @@ endif ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW)) # -Os # size optimization # -O2 # optimization level 2, if used, also set --memory-init-file 0 - # -sUSE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker! - # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! - # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) - # -sUSE_PTHREADS=1 # multithreading support - # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data - # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) - # -sGL_ENABLE_GET_PROC_ADDRESS # enable using the *glGetProcAddress() family of functions, required for extensions loading + # -sUSE_GLFW=3 # Use glfw3 library (context/input management) + # -sALLOW_MEMORY_GROWTH=1 # to allow memory resizing -> WARNING: Audio buffers could FAIL! + # -sTOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) (67108864 = 64MB) + # -sUSE_PTHREADS=1 # multithreading support + # -sWASM=0 # disable Web Assembly, emitted by default + # -sASYNCIFY # lets synchronous C/C++ code interact with asynchronous JS + # -sFORCE_FILESYSTEM=1 # force filesystem to load/save files data + # -sASSERTIONS=1 # enable runtime checks for common memory allocation errors (-O1 and above turn it off) + # -sMINIFY_HTML=0 # minify generated html from shell.html # --profiling # include information for code profiling # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --preload-file resources # specify a resources folder for data compilation + # --source-map-base # allow debugging in browser with source map + # --shell-file shell.html # define a custom shell .html and output extension ifeq ($(RAYLIB_BUILD_MODE),DEBUG) CFLAGS += -sASSERTIONS=1 --profiling endif - #CFLAGS += -sGL_ENABLE_GET_PROC_ADDRESS endif ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) # Compiler flags for arquitecture diff --git a/src/minshell.html b/src/minshell.html index 4068ca36c..ec7158841 100644 --- a/src/minshell.html +++ b/src/minshell.html @@ -34,12 +34,8 @@