Remove trailing spaces

This commit is contained in:
Ray
2026-03-25 16:51:02 +01:00
parent 5dd4036ed0
commit 0f0983c065
23 changed files with 184 additions and 185 deletions

View File

@ -110,16 +110,16 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText(TextFormat("sine frequency: %i", sineFrequency), screenWidth - 220, 10, 20, RED); DrawText(TextFormat("sine frequency: %i", sineFrequency), screenWidth - 220, 10, 20, RED);
DrawText(TextFormat("pan: %.2f", pan), screenWidth - 220, 30, 20, RED); DrawText(TextFormat("pan: %.2f", pan), screenWidth - 220, 30, 20, RED);
DrawText("Up/down to change frequency", 10, 10, 20, DARKGRAY); DrawText("Up/down to change frequency", 10, 10, 20, DARKGRAY);
DrawText("Left/right to pan", 10, 30, 20, DARKGRAY); DrawText("Left/right to pan", 10, 30, 20, DARKGRAY);
int windowStart = (GetTime() - sineStartTime)*SAMPLE_RATE; int windowStart = (GetTime() - sineStartTime)*SAMPLE_RATE;
int windowSize = 0.1f*SAMPLE_RATE; int windowSize = 0.1f*SAMPLE_RATE;
int wavelength = SAMPLE_RATE/sineFrequency; int wavelength = SAMPLE_RATE/sineFrequency;
// Draw a sine wave with the same frequency as the one being sent to the audio stream // Draw a sine wave with the same frequency as the one being sent to the audio stream
for (int i = 0; i < screenWidth; i++) for (int i = 0; i < screenWidth; i++)
{ {

View File

@ -73,7 +73,7 @@ int main(void)
} }
// Draw UI info // Draw UI info
DrawText(TextFormat("CURRENT MONITOR: %i/%i (%ix%i)", currentMonitor + 1, GetMonitorCount(), DrawText(TextFormat("CURRENT MONITOR: %i/%i (%ix%i)", currentMonitor + 1, GetMonitorCount(),
GetMonitorWidth(currentMonitor), GetMonitorHeight(currentMonitor)), 50, 50, 20, DARKGRAY); GetMonitorWidth(currentMonitor), GetMonitorHeight(currentMonitor)), 50, 50, 20, DARKGRAY);
DrawText(TextFormat("WINDOW POSITION: %ix%i", (int)windowPos.x, (int)windowPos.y), 50, 90, 20, DARKGRAY); DrawText(TextFormat("WINDOW POSITION: %ix%i", (int)windowPos.x, (int)windowPos.y), 50, 90, 20, DARKGRAY);
DrawText(TextFormat("SCREEN SIZE: %ix%i", GetScreenWidth(), GetScreenHeight()), 50, 130, 20, DARKGRAY); DrawText(TextFormat("SCREEN SIZE: %ix%i", GetScreenWidth(), GetScreenHeight()), 50, 130, 20, DARKGRAY);

View File

@ -4,7 +4,7 @@
* *
* Example complexity rating: [★★☆☆] 2/4 * Example complexity rating: [★★☆☆] 2/4
* *
* NOTE: raylib defined keys refer to ENG-US Keyboard layout, * NOTE: raylib defined keys refer to ENG-US Keyboard layout,
* mapping to other layouts is up to the user * mapping to other layouts is up to the user
* *
* Example originally created with raylib 5.6, last time updated with raylib 5.6 * Example originally created with raylib 5.6, last time updated with raylib 5.6
@ -43,20 +43,20 @@ int main(void)
int line01KeyWidths[15] = { 0 }; int line01KeyWidths[15] = { 0 };
for (int i = 0; i < 15; i++) line01KeyWidths[i] = 45; for (int i = 0; i < 15; i++) line01KeyWidths[i] = 45;
line01KeyWidths[13] = 62; // PRINTSCREEN line01KeyWidths[13] = 62; // PRINTSCREEN
int line01Keys[15] = { int line01Keys[15] = {
KEY_ESCAPE, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_ESCAPE, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5,
KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11,
KEY_F12, KEY_PRINT_SCREEN, KEY_PAUSE KEY_F12, KEY_PRINT_SCREEN, KEY_PAUSE
}; };
// Keyboard line 02 // Keyboard line 02
int line02KeyWidths[15] = { 0 }; int line02KeyWidths[15] = { 0 };
for (int i = 0; i < 15; i++) line02KeyWidths[i] = 45; for (int i = 0; i < 15; i++) line02KeyWidths[i] = 45;
line02KeyWidths[0] = 25; // GRAVE line02KeyWidths[0] = 25; // GRAVE
line02KeyWidths[13] = 82; // BACKSPACE line02KeyWidths[13] = 82; // BACKSPACE
int line02Keys[15] = { int line02Keys[15] = {
KEY_GRAVE, KEY_ONE, KEY_TWO, KEY_THREE, KEY_FOUR, KEY_GRAVE, KEY_ONE, KEY_TWO, KEY_THREE, KEY_FOUR,
KEY_FIVE, KEY_SIX, KEY_SEVEN, KEY_EIGHT, KEY_NINE, KEY_FIVE, KEY_SIX, KEY_SEVEN, KEY_EIGHT, KEY_NINE,
KEY_ZERO, KEY_MINUS, KEY_EQUAL, KEY_BACKSPACE, KEY_DELETE }; KEY_ZERO, KEY_MINUS, KEY_EQUAL, KEY_BACKSPACE, KEY_DELETE };
// Keyboard line 03 // Keyboard line 03
@ -103,7 +103,7 @@ int main(void)
KEY_SPACE, KEY_RIGHT_ALT, 162, KEY_NULL, KEY_SPACE, KEY_RIGHT_ALT, 162, KEY_NULL,
KEY_RIGHT_CONTROL, KEY_LEFT, KEY_DOWN, KEY_RIGHT KEY_RIGHT_CONTROL, KEY_LEFT, KEY_DOWN, KEY_RIGHT
}; };
Vector2 keyboardOffset = { 26, 80 }; Vector2 keyboardOffset = { 26, 80 };
SetTargetFPS(60); SetTargetFPS(60);
@ -128,23 +128,23 @@ int main(void)
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("KEYBOARD LAYOUT: ENG-US", 26, 38, 20, LIGHTGRAY); DrawText("KEYBOARD LAYOUT: ENG-US", 26, 38, 20, LIGHTGRAY);
// Keyboard line 01 - 15 keys // Keyboard line 01 - 15 keys
// ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, IMP, CLOSE // ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, IMP, CLOSE
for (int i = 0, recOffsetX = 0; i < 15; i++) for (int i = 0, recOffsetX = 0; i < 15; i++)
{ {
GuiKeyboardKey((Rectangle){ keyboardOffset.x + recOffsetX, keyboardOffset.y, (float)line01KeyWidths[i], 30.0f }, line01Keys[i]); GuiKeyboardKey((Rectangle){ keyboardOffset.x + recOffsetX, keyboardOffset.y, (float)line01KeyWidths[i], 30.0f }, line01Keys[i]);
recOffsetX += line01KeyWidths[i] + KEY_REC_SPACING; recOffsetX += line01KeyWidths[i] + KEY_REC_SPACING;
} }
// Keyboard line 02 - 15 keys // Keyboard line 02 - 15 keys
// `, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -, =, BACKSPACE, DEL // `, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -, =, BACKSPACE, DEL
for (int i = 0, recOffsetX = 0; i < 15; i++) for (int i = 0, recOffsetX = 0; i < 15; i++)
{ {
GuiKeyboardKey((Rectangle){ keyboardOffset.x + recOffsetX, keyboardOffset.y + 30 + KEY_REC_SPACING, (float)line02KeyWidths[i], 38.0f }, line02Keys[i]); GuiKeyboardKey((Rectangle){ keyboardOffset.x + recOffsetX, keyboardOffset.y + 30 + KEY_REC_SPACING, (float)line02KeyWidths[i], 38.0f }, line02Keys[i]);
recOffsetX += line02KeyWidths[i] + KEY_REC_SPACING; recOffsetX += line02KeyWidths[i] + KEY_REC_SPACING;
} }
// Keyboard line 03 - 15 keys // Keyboard line 03 - 15 keys
// TAB, Q, W, E, R, T, Y, U, I, O, P, [, ], \, INS // TAB, Q, W, E, R, T, Y, U, I, O, P, [, ], \, INS
for (int i = 0, recOffsetX = 0; i < 15; i++) for (int i = 0, recOffsetX = 0; i < 15; i++)
@ -324,8 +324,8 @@ static void GuiKeyboardKey(Rectangle bounds, int key)
DrawText(GetKeyText(key), (int)(bounds.x + 4), (int)(bounds.y + 4), 10, DARKGRAY); DrawText(GetKeyText(key), (int)(bounds.x + 4), (int)(bounds.y + 4), 10, DARKGRAY);
} }
} }
if (CheckCollisionPointRec(GetMousePosition(), bounds)) if (CheckCollisionPointRec(GetMousePosition(), bounds))
{ {
DrawRectangleRec(bounds, Fade(RED, 0.2f)); DrawRectangleRec(bounds, Fade(RED, 0.2f));
DrawRectangleLinesEx(bounds, 3.0f, RED); DrawRectangleLinesEx(bounds, 3.0f, RED);

View File

@ -43,7 +43,7 @@
// Module Functions Declaration // Module Functions Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
static bool IsUpperBodyBone(const char *boneName); static bool IsUpperBodyBone(const char *boneName);
static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim1, int frame1, static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim1, int frame1,
ModelAnimation *anim2, int frame2, float blend, bool upperBodyBlend); ModelAnimation *anim2, int frame2, float blend, bool upperBodyBlend);
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -86,7 +86,7 @@ int main(void)
int animIndex1 = 3; // Attack animation (index 3) int animIndex1 = 3; // Attack animation (index 3)
int animCurrentFrame0 = 0; int animCurrentFrame0 = 0;
int animCurrentFrame1 = 0; int animCurrentFrame1 = 0;
// Validate indices // Validate indices
if (animIndex0 >= animCount) animIndex0 = 0; if (animIndex0 >= animCount) animIndex0 = 0;
if (animIndex1 >= animCount) animIndex1 = (animCount > 1) ? 1 : 0; if (animIndex1 >= animCount) animIndex1 = (animCount > 1) ? 1 : 0;
@ -109,7 +109,7 @@ int main(void)
// Update animation frames // Update animation frames
ModelAnimation anim0 = anims[animIndex0]; ModelAnimation anim0 = anims[animIndex0];
ModelAnimation anim1 = anims[animIndex1]; ModelAnimation anim1 = anims[animIndex1];
animCurrentFrame0 = (animCurrentFrame0 + 1)%anim0.keyframeCount; animCurrentFrame0 = (animCurrentFrame0 + 1)%anim0.keyframeCount;
animCurrentFrame1 = (animCurrentFrame1 + 1)%anim1.keyframeCount; animCurrentFrame1 = (animCurrentFrame1 + 1)%anim1.keyframeCount;
@ -117,11 +117,11 @@ int main(void)
// When upperBodyBlend is ON: upper body = attack (1.0), lower body = walk (0.0) // When upperBodyBlend is ON: upper body = attack (1.0), lower body = walk (0.0)
// When upperBodyBlend is OFF: uniform blend at 0.5 (50% walk, 50% attack) // When upperBodyBlend is OFF: uniform blend at 0.5 (50% walk, 50% attack)
float blendFactor = (upperBodyBlend? 1.0f : 0.5f); float blendFactor = (upperBodyBlend? 1.0f : 0.5f);
UpdateModelAnimationBones(&model, &anim0, animCurrentFrame0, UpdateModelAnimationBones(&model, &anim0, animCurrentFrame0,
&anim1, animCurrentFrame1, blendFactor, upperBodyBlend); &anim1, animCurrentFrame1, blendFactor, upperBodyBlend);
// raylib provided animation blending function // raylib provided animation blending function
//UpdateModelAnimationEx(model, anim0, (float)animCurrentFrame0, //UpdateModelAnimationEx(model, anim0, (float)animCurrentFrame0,
// anim1, (float)animCurrentFrame1, blendFactor); // anim1, (float)animCurrentFrame1, blendFactor);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -142,8 +142,8 @@ int main(void)
// Draw UI // Draw UI
DrawText(TextFormat("ANIM 0: %s", anim0.name), 10, 10, 20, GRAY); DrawText(TextFormat("ANIM 0: %s", anim0.name), 10, 10, 20, GRAY);
DrawText(TextFormat("ANIM 1: %s", anim1.name), 10, 40, 20, GRAY); DrawText(TextFormat("ANIM 1: %s", anim1.name), 10, 40, 20, GRAY);
DrawText(TextFormat("[SPACE] Toggle blending mode: %s", DrawText(TextFormat("[SPACE] Toggle blending mode: %s",
upperBodyBlend? "Upper/Lower Body Blending" : "Uniform Blending"), upperBodyBlend? "Upper/Lower Body Blending" : "Uniform Blending"),
10, GetScreenHeight() - 30, 20, DARKGRAY); 10, GetScreenHeight() - 30, 20, DARKGRAY);
EndDrawing(); EndDrawing();
@ -180,7 +180,7 @@ static bool IsUpperBodyBone(const char *boneName)
{ {
return true; return true;
} }
// Check if bone name contains upper body keywords // Check if bone name contains upper body keywords
if (strstr(boneName, "spine") != NULL || strstr(boneName, "chest") != NULL || if (strstr(boneName, "spine") != NULL || strstr(boneName, "chest") != NULL ||
strstr(boneName, "neck") != NULL || strstr(boneName, "head") != NULL || strstr(boneName, "neck") != NULL || strstr(boneName, "head") != NULL ||
@ -189,12 +189,12 @@ static bool IsUpperBodyBone(const char *boneName)
{ {
return true; return true;
} }
return false; return false;
} }
// Blend two animations per-bone with selective upper/lower body blending // Blend two animations per-bone with selective upper/lower body blending
static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim0, int frame0, static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim0, int frame0,
ModelAnimation *anim1, int frame1, float blend, bool upperBodyBlend) ModelAnimation *anim1, int frame1, float blend, bool upperBodyBlend)
{ {
// Validate inputs // Validate inputs
@ -204,59 +204,59 @@ static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim0, int f
{ {
// Clamp blend factor to [0, 1] // Clamp blend factor to [0, 1]
blend = fminf(1.0f, fmaxf(0.0f, blend)); blend = fminf(1.0f, fmaxf(0.0f, blend));
// Ensure frame indices are valid // Ensure frame indices are valid
if (frame0 >= anim0->keyframeCount) frame0 = anim0->keyframeCount - 1; if (frame0 >= anim0->keyframeCount) frame0 = anim0->keyframeCount - 1;
if (frame1 >= anim1->keyframeCount) frame1 = anim1->keyframeCount - 1; if (frame1 >= anim1->keyframeCount) frame1 = anim1->keyframeCount - 1;
if (frame0 < 0) frame0 = 0; if (frame0 < 0) frame0 = 0;
if (frame1 < 0) frame1 = 0; if (frame1 < 0) frame1 = 0;
// Get bone count (use minimum of all to be safe) // Get bone count (use minimum of all to be safe)
int boneCount = model->skeleton.boneCount; int boneCount = model->skeleton.boneCount;
if (anim0->boneCount < boneCount) boneCount = anim0->boneCount; if (anim0->boneCount < boneCount) boneCount = anim0->boneCount;
if (anim1->boneCount < boneCount) boneCount = anim1->boneCount; if (anim1->boneCount < boneCount) boneCount = anim1->boneCount;
// Blend each bone // Blend each bone
for (int boneIndex = 0; boneIndex < boneCount; boneIndex++) for (int boneIndex = 0; boneIndex < boneCount; boneIndex++)
{ {
// Determine blend factor for this bone // Determine blend factor for this bone
float boneBlendFactor = blend; float boneBlendFactor = blend;
// If upper body blending is enabled, use different blend factors for upper vs lower body // If upper body blending is enabled, use different blend factors for upper vs lower body
if (upperBodyBlend) if (upperBodyBlend)
{ {
const char *boneName = model->skeleton.bones[boneIndex].name; const char *boneName = model->skeleton.bones[boneIndex].name;
bool isUpperBody = IsUpperBodyBone(boneName); bool isUpperBody = IsUpperBodyBone(boneName);
// Upper body: use anim1 (attack), Lower body: use anim0 (walk) // Upper body: use anim1 (attack), Lower body: use anim0 (walk)
// blend = 0.0 means full anim0 (walk), 1.0 means full anim1 (attack) // blend = 0.0 means full anim0 (walk), 1.0 means full anim1 (attack)
if (isUpperBody) boneBlendFactor = blend; // Upper body: blend towards anim1 (attack) if (isUpperBody) boneBlendFactor = blend; // Upper body: blend towards anim1 (attack)
else boneBlendFactor = 1.0f - blend; // Lower body: blend towards anim0 (walk) - invert the blend else boneBlendFactor = 1.0f - blend; // Lower body: blend towards anim0 (walk) - invert the blend
} }
// Get transforms from both animations // Get transforms from both animations
Transform *bindTransform = &model->skeleton.bindPose[boneIndex]; Transform *bindTransform = &model->skeleton.bindPose[boneIndex];
Transform *animTransform0 = &anim0->keyframePoses[frame0][boneIndex]; Transform *animTransform0 = &anim0->keyframePoses[frame0][boneIndex];
Transform *animTransform1 = &anim1->keyframePoses[frame1][boneIndex]; Transform *animTransform1 = &anim1->keyframePoses[frame1][boneIndex];
// Blend the transforms // Blend the transforms
Transform blended = { 0 }; Transform blended = { 0 };
blended.translation = Vector3Lerp(animTransform0->translation, animTransform1->translation, boneBlendFactor); blended.translation = Vector3Lerp(animTransform0->translation, animTransform1->translation, boneBlendFactor);
blended.rotation = QuaternionSlerp(animTransform0->rotation, animTransform1->rotation, boneBlendFactor); blended.rotation = QuaternionSlerp(animTransform0->rotation, animTransform1->rotation, boneBlendFactor);
blended.scale = Vector3Lerp(animTransform0->scale, animTransform1->scale, boneBlendFactor); blended.scale = Vector3Lerp(animTransform0->scale, animTransform1->scale, boneBlendFactor);
// Convert bind pose to matrix // Convert bind pose to matrix
Matrix bindMatrix = MatrixMultiply(MatrixMultiply( Matrix bindMatrix = MatrixMultiply(MatrixMultiply(
MatrixScale(bindTransform->scale.x, bindTransform->scale.y, bindTransform->scale.z), MatrixScale(bindTransform->scale.x, bindTransform->scale.y, bindTransform->scale.z),
QuaternionToMatrix(bindTransform->rotation)), QuaternionToMatrix(bindTransform->rotation)),
MatrixTranslate(bindTransform->translation.x, bindTransform->translation.y, bindTransform->translation.z)); MatrixTranslate(bindTransform->translation.x, bindTransform->translation.y, bindTransform->translation.z));
// Convert blended transform to matrix // Convert blended transform to matrix
Matrix blendedMatrix = MatrixMultiply(MatrixMultiply( Matrix blendedMatrix = MatrixMultiply(MatrixMultiply(
MatrixScale(blended.scale.x, blended.scale.y, blended.scale.z), MatrixScale(blended.scale.x, blended.scale.y, blended.scale.z),
QuaternionToMatrix(blended.rotation)), QuaternionToMatrix(blended.rotation)),
MatrixTranslate(blended.translation.x, blended.translation.y, blended.translation.z)); MatrixTranslate(blended.translation.x, blended.translation.y, blended.translation.z));
// Calculate final bone matrix (similar to UpdateModelAnimationBones) // Calculate final bone matrix (similar to UpdateModelAnimationBones)
model->boneMatrices[boneIndex] = MatrixMultiply(MatrixInvert(bindMatrix), blendedMatrix); model->boneMatrices[boneIndex] = MatrixMultiply(MatrixInvert(bindMatrix), blendedMatrix);
} }
@ -276,7 +276,7 @@ static void UpdateModelAnimationBones(Model *model, ModelAnimation *anim0, int f
bool bufferUpdateRequired = false; // Flag to check when anim vertex information is updated bool bufferUpdateRequired = false; // Flag to check when anim vertex information is updated
// Skip if missing bone data or missing anim buffers initialization // Skip if missing bone data or missing anim buffers initialization
if ((mesh.boneWeights == NULL) || (mesh.boneIndices == NULL) || if ((mesh.boneWeights == NULL) || (mesh.boneIndices == NULL) ||
(mesh.animVertices == NULL) || (mesh.animNormals == NULL)) continue; (mesh.animVertices == NULL) || (mesh.animNormals == NULL)) continue;
for (int vCounter = 0; vCounter < vertexValuesCount; vCounter += 3) for (int vCounter = 0; vCounter < vertexValuesCount; vCounter += 3)

View File

@ -3,7 +3,7 @@
* raylib [models] example - animation blending * raylib [models] example - animation blending
* *
* Example complexity rating: [★★★★] 4/4 * Example complexity rating: [★★★★] 4/4
* *
* Example originally created with raylib 5.5, last time updated with raylib 6.0 * Example originally created with raylib 5.5, last time updated with raylib 6.0
* *
* Example contributed by Kirandeep (@Kirandeep-Singh-Khehra) and reviewed by Ramon Santamaria (@raysan5) * Example contributed by Kirandeep (@Kirandeep-Singh-Khehra) and reviewed by Ramon Santamaria (@raysan5)
@ -57,7 +57,7 @@ int main(void)
// WARNING: It requires SUPPORT_GPU_SKINNING enabled on raylib (disabled by default) // WARNING: It requires SUPPORT_GPU_SKINNING enabled on raylib (disabled by default)
Shader skinningShader = LoadShader(TextFormat("resources/shaders/glsl%i/skinning.vs", GLSL_VERSION), Shader skinningShader = LoadShader(TextFormat("resources/shaders/glsl%i/skinning.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/skinning.fs", GLSL_VERSION)); TextFormat("resources/shaders/glsl%i/skinning.fs", GLSL_VERSION));
// Assign skinning shader to all materials shaders // Assign skinning shader to all materials shaders
//for (int i = 0; i < model.materialCount; i++) model.materials[i].shader = skinningShader; //for (int i = 0; i < model.materialCount; i++) model.materials[i].shader = skinningShader;
@ -105,7 +105,7 @@ int main(void)
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera, CAMERA_ORBITAL); UpdateCamera(&camera, CAMERA_ORBITAL);
if (IsKeyPressed(KEY_P)) animPause = !animPause; if (IsKeyPressed(KEY_P)) animPause = !animPause;
if (!animPause) if (!animPause)
@ -127,7 +127,7 @@ int main(void)
} }
// Set animation transition // Set animation transition
animTransition = true; animTransition = true;
animBlendTimeCounter = 0.0f; animBlendTimeCounter = 0.0f;
animBlendFactor = 0.0f; animBlendFactor = 0.0f;
} }
@ -182,7 +182,7 @@ int main(void)
animCurrentFrame0 += animFrameSpeed0; animCurrentFrame0 += animFrameSpeed0;
if (animCurrentFrame0 >= anims[animIndex0].keyframeCount) animCurrentFrame0 = 0.0f; if (animCurrentFrame0 >= anims[animIndex0].keyframeCount) animCurrentFrame0 = 0.0f;
UpdateModelAnimation(model, anims[animIndex0], animCurrentFrame0); UpdateModelAnimation(model, anims[animIndex0], animCurrentFrame0);
//UpdateModelAnimationEx(model, anims[animIndex0], animCurrentFrame0, //UpdateModelAnimationEx(model, anims[animIndex0], animCurrentFrame0,
// anims[animIndex1], animCurrentFrame1, 0.0f); // Same as above, first animation frame blend // anims[animIndex1], animCurrentFrame1, 0.0f); // Same as above, first animation frame blend
} }
else if (currentAnimPlaying == 1) else if (currentAnimPlaying == 1)
@ -191,7 +191,7 @@ int main(void)
animCurrentFrame1 += animFrameSpeed1; animCurrentFrame1 += animFrameSpeed1;
if (animCurrentFrame1 >= anims[animIndex1].keyframeCount) animCurrentFrame1 = 0.0f; if (animCurrentFrame1 >= anims[animIndex1].keyframeCount) animCurrentFrame1 = 0.0f;
UpdateModelAnimation(model, anims[animIndex1], animCurrentFrame1); UpdateModelAnimation(model, anims[animIndex1], animCurrentFrame1);
//UpdateModelAnimationEx(model, anims[animIndex0], animCurrentFrame0, //UpdateModelAnimationEx(model, anims[animIndex0], animCurrentFrame0,
// anims[animIndex1], animCurrentFrame1, 1.0f); // Same as above, second animation frame blend // anims[animIndex1], animCurrentFrame1, 1.0f); // Same as above, second animation frame blend
} }
} }
@ -213,7 +213,7 @@ int main(void)
DrawModel(model, position, 1.0f, WHITE); // Draw animated model DrawModel(model, position, 1.0f, WHITE); // Draw animated model
DrawGrid(10, 1.0f); DrawGrid(10, 1.0f);
EndMode3D(); EndMode3D();
if (animTransition) DrawText("ANIM TRANSITION BLENDING!", 170, 50, 30, BLUE); if (animTransition) DrawText("ANIM TRANSITION BLENDING!", 170, 50, 30, BLUE);
@ -221,18 +221,18 @@ int main(void)
// Draw UI elements // Draw UI elements
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
if (dropdownEditMode0) GuiDisable(); if (dropdownEditMode0) GuiDisable();
GuiSlider((Rectangle){ 10, 38, 160, 12 }, GuiSlider((Rectangle){ 10, 38, 160, 12 },
NULL, TextFormat("x%.1f", animFrameSpeed0), &animFrameSpeed0, 0.1f, 2.0f); NULL, TextFormat("x%.1f", animFrameSpeed0), &animFrameSpeed0, 0.1f, 2.0f);
GuiEnable(); GuiEnable();
if (dropdownEditMode1) GuiDisable(); if (dropdownEditMode1) GuiDisable();
GuiSlider((Rectangle){ GetScreenWidth() - 170.0f, 38, 160, 12 }, GuiSlider((Rectangle){ GetScreenWidth() - 170.0f, 38, 160, 12 },
TextFormat("%.1fx", animFrameSpeed1), NULL, &animFrameSpeed1, 0.1f, 2.0f); TextFormat("%.1fx", animFrameSpeed1), NULL, &animFrameSpeed1, 0.1f, 2.0f);
GuiEnable(); GuiEnable();
// Draw animation selectors for blending transition // Draw animation selectors for blending transition
// NOTE: Transition does not start until requested // NOTE: Transition does not start until requested
GuiSetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING, 1); GuiSetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING, 1);
if (GuiDropdownBox((Rectangle){ 10, 10, 160, 24 }, TextJoin(animNames, animCount, ";"), if (GuiDropdownBox((Rectangle){ 10, 10, 160, 24 }, TextJoin(animNames, animCount, ";"),
&animIndex0, dropdownEditMode0)) dropdownEditMode0 = !dropdownEditMode0; &animIndex0, dropdownEditMode0)) dropdownEditMode0 = !dropdownEditMode0;
// Blending process progress bar // Blending process progress bar
@ -249,7 +249,7 @@ int main(void)
TextFormat("FRAME: %.2f / %i", animFrameProgress0, anims[animIndex0].keyframeCount), TextFormat("FRAME: %.2f / %i", animFrameProgress0, anims[animIndex0].keyframeCount),
&animFrameProgress0, 0.0f, (float)anims[animIndex0].keyframeCount); &animFrameProgress0, 0.0f, (float)anims[animIndex0].keyframeCount);
for (int i = 0; i < anims[animIndex0].keyframeCount; i++) for (int i = 0; i < anims[animIndex0].keyframeCount; i++)
DrawRectangle(60 + (int)(((float)(GetScreenWidth() - 180)/(float)anims[animIndex0].keyframeCount)*(float)i), DrawRectangle(60 + (int)(((float)(GetScreenWidth() - 180)/(float)anims[animIndex0].keyframeCount)*(float)i),
GetScreenHeight() - 60, 1, 20, BLUE); GetScreenHeight() - 60, 1, 20, BLUE);
// Draw playing timeline with keyframes for anim1[] // Draw playing timeline with keyframes for anim1[]
@ -257,7 +257,7 @@ int main(void)
TextFormat("FRAME: %.2f / %i", animFrameProgress1, anims[animIndex1].keyframeCount), TextFormat("FRAME: %.2f / %i", animFrameProgress1, anims[animIndex1].keyframeCount),
&animFrameProgress1, 0.0f, (float)anims[animIndex1].keyframeCount); &animFrameProgress1, 0.0f, (float)anims[animIndex1].keyframeCount);
for (int i = 0; i < anims[animIndex1].keyframeCount; i++) for (int i = 0; i < anims[animIndex1].keyframeCount; i++)
DrawRectangle(60 + (int)(((float)(GetScreenWidth() - 180)/(float)anims[animIndex1].keyframeCount)*(float)i), DrawRectangle(60 + (int)(((float)(GetScreenWidth() - 180)/(float)anims[animIndex1].keyframeCount)*(float)i),
GetScreenHeight() - 30, 1, 20, BLUE); GetScreenHeight() - 30, 1, 20, BLUE);
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
@ -270,7 +270,7 @@ int main(void)
UnloadModelAnimations(anims, animCount); // Unload model animation UnloadModelAnimations(anims, animCount); // Unload model animation
UnloadModel(model); // Unload model and meshes/material UnloadModel(model); // Unload model and meshes/material
UnloadShader(skinningShader); // Unload GPU skinning shader UnloadShader(skinningShader); // Unload GPU skinning shader
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -94,26 +94,26 @@ int main(void)
BeginMode3D(camera); BeginMode3D(camera);
DrawModel(model, position, 1.0f, WHITE); DrawModel(model, position, 1.0f, WHITE);
DrawGrid(10, 1.0f); DrawGrid(10, 1.0f);
EndMode3D(); EndMode3D();
// Draw UI, select anim and playing speed // Draw UI, select anim and playing speed
GuiSetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING, 1); GuiSetStyle(DROPDOWNBOX, DROPDOWN_ITEMS_SPACING, 1);
if (GuiDropdownBox((Rectangle){ 10, 10, 140, 24 }, TextJoin(animNames, animCount, ";"), if (GuiDropdownBox((Rectangle){ 10, 10, 140, 24 }, TextJoin(animNames, animCount, ";"),
&animIndex, dropdownEditMode)) dropdownEditMode = !dropdownEditMode; &animIndex, dropdownEditMode)) dropdownEditMode = !dropdownEditMode;
GuiSlider((Rectangle){ 260, 10, 500, 24 }, "FRAME SPEED: ", TextFormat("x%.1f", animFrameSpeed), GuiSlider((Rectangle){ 260, 10, 500, 24 }, "FRAME SPEED: ", TextFormat("x%.1f", animFrameSpeed),
&animFrameSpeed, 0.1f, 2.0f); &animFrameSpeed, 0.1f, 2.0f);
// Draw playing timeline with keyframes // Draw playing timeline with keyframes
GuiLabel((Rectangle){ 10, GetScreenHeight() - 64.0f, GetScreenWidth() - 20.0f, 24 }, GuiLabel((Rectangle){ 10, GetScreenHeight() - 64.0f, GetScreenWidth() - 20.0f, 24 },
TextFormat("CURRENT FRAME: %.2f / %i", animFrameProgress, anims[animIndex].keyframeCount)); TextFormat("CURRENT FRAME: %.2f / %i", animFrameProgress, anims[animIndex].keyframeCount));
GuiProgressBar((Rectangle){ 10, GetScreenHeight() - 40.0f, GetScreenWidth() - 20.0f, 24 }, NULL, NULL, GuiProgressBar((Rectangle){ 10, GetScreenHeight() - 40.0f, GetScreenWidth() - 20.0f, 24 }, NULL, NULL,
&animFrameProgress, 0.0f, (float)anims[animIndex].keyframeCount); &animFrameProgress, 0.0f, (float)anims[animIndex].keyframeCount);
for (int i = 0; i < anims[animIndex].keyframeCount; i++) for (int i = 0; i < anims[animIndex].keyframeCount; i++)
DrawRectangle(10 + (int)(((float)(GetScreenWidth() - 20)/(float)anims[animIndex].keyframeCount)*(float)i), DrawRectangle(10 + (int)(((float)(GetScreenWidth() - 20)/(float)anims[animIndex].keyframeCount)*(float)i),
GetScreenHeight() - 40, 1, 24, BLUE); GetScreenHeight() - 40, 1, 24, BLUE);
EndDrawing(); EndDrawing();

View File

@ -60,7 +60,7 @@ int main(void)
} }
} }
} }
SetTargetFPS(60); SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -109,7 +109,7 @@ int main(void)
} }
} }
} }
// Remove the closest voxel if one was hit // Remove the closest voxel if one was hit
if (voxelFound) if (voxelFound)
{ {
@ -145,9 +145,9 @@ int main(void)
} }
} }
} }
EndMode3D(); EndMode3D();
// Draw reference point for raycasting to delete blocks // Draw reference point for raycasting to delete blocks
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 4, RED); DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 4, RED);
@ -161,7 +161,7 @@ int main(void)
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadModel(cubeModel); UnloadModel(cubeModel);
CloseWindow(); CloseWindow();
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -92,7 +92,7 @@ int main(void)
} }
else else
{ {
// TODO: WARNING: On PLATFORM_WEB it requires a big amount of memory to process input image // TODO: WARNING: On PLATFORM_WEB it requires a big amount of memory to process input image
// and generate the required cubemap image to be passed to rlLoadTextureCubemap() // and generate the required cubemap image to be passed to rlLoadTextureCubemap()
Image image = LoadImage("resources/skybox.png"); Image image = LoadImage("resources/skybox.png");
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = LoadTextureCubemap(image, CUBEMAP_LAYOUT_AUTO_DETECT); skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = LoadTextureCubemap(image, CUBEMAP_LAYOUT_AUTO_DETECT);

View File

@ -41,7 +41,7 @@ int main(void)
Model model = LoadModel("resources/models/obj/plane.obj"); // Load model Model model = LoadModel("resources/models/obj/plane.obj"); // Load model
Texture2D texture = LoadTexture("resources/models/obj/plane_diffuse.png"); // Load model texture Texture2D texture = LoadTexture("resources/models/obj/plane_diffuse.png"); // Load model texture
SetTextureWrap(texture, TEXTURE_WRAP_REPEAT); // Force Repeat to avoid issue on Web version SetTextureWrap(texture, TEXTURE_WRAP_REPEAT); // Force Repeat to avoid issue on Web version
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture

View File

@ -52,7 +52,7 @@ int main(void)
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
camera.fovy = 45.0f; camera.fovy = 45.0f;
camera.projection = CAMERA_PERSPECTIVE; camera.projection = CAMERA_PERSPECTIVE;
// Load model // Load model
Model model = LoadModel("resources/models/old_car_new.glb"); Model model = LoadModel("resources/models/old_car_new.glb");
@ -61,7 +61,7 @@ int main(void)
TextFormat("resources/shaders/glsl%i/cel.vs", GLSL_VERSION), TextFormat("resources/shaders/glsl%i/cel.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/cel.fs", GLSL_VERSION)); TextFormat("resources/shaders/glsl%i/cel.fs", GLSL_VERSION));
celShader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(celShader, "viewPos"); celShader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(celShader, "viewPos");
// Apply cel shader to model, keep copy of default shader // Apply cel shader to model, keep copy of default shader
Shader defaultShader = model.materials[0].shader; Shader defaultShader = model.materials[0].shader;
model.materials[0].shader = celShader; model.materials[0].shader = celShader;
@ -134,16 +134,16 @@ int main(void)
// Outline pass: cull front faces, draw extruded back faces as silhouette // Outline pass: cull front faces, draw extruded back faces as silhouette
float thickness = 0.005f; float thickness = 0.005f;
SetShaderValue(outlineShader, outlineThicknessLoc, &thickness, SHADER_UNIFORM_FLOAT); SetShaderValue(outlineShader, outlineThicknessLoc, &thickness, SHADER_UNIFORM_FLOAT);
rlSetCullFace(RL_CULL_FACE_FRONT); rlSetCullFace(RL_CULL_FACE_FRONT);
model.materials[0].shader = outlineShader; model.materials[0].shader = outlineShader;
DrawModel(model, Vector3Zero(), 0.75f, WHITE); DrawModel(model, Vector3Zero(), 0.75f, WHITE);
if (celEnabled) model.materials[0].shader = celShader; // Apply cel shader to model if (celEnabled) model.materials[0].shader = celShader; // Apply cel shader to model
else model.materials[0].shader = defaultShader; // Apply default shader to model else model.materials[0].shader = defaultShader; // Apply default shader to model
rlSetCullFace(RL_CULL_FACE_BACK); rlSetCullFace(RL_CULL_FACE_BACK);
} }
@ -167,7 +167,7 @@ int main(void)
UnloadModel(model); UnloadModel(model);
UnloadShader(celShader); UnloadShader(celShader);
UnloadShader(outlineShader); UnloadShader(outlineShader);
CloseWindow(); CloseWindow();
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -210,7 +210,7 @@ int main(void)
rlClearColor(0, 0, 0, 0); rlClearColor(0, 0, 0, 0);
rlClearScreenBuffers(); // Clear color and depth buffer rlClearScreenBuffers(); // Clear color and depth buffer
rlDisableColorBlend(); rlDisableColorBlend();
BeginMode3D(camera); BeginMode3D(camera);
// NOTE: We have to use rlEnableShader here. `BeginShaderMode` or thus `rlSetShader` // NOTE: We have to use rlEnableShader here. `BeginShaderMode` or thus `rlSetShader`
// will not work, as they won't immediately load the shader program // will not work, as they won't immediately load the shader program
@ -226,7 +226,7 @@ int main(void)
} }
rlDisableShader(); rlDisableShader();
EndMode3D(); EndMode3D();
rlEnableColorBlend(); rlEnableColorBlend();
// Go back to the default framebufferId (0) and draw our deferred shading // Go back to the default framebufferId (0) and draw our deferred shading

View File

@ -59,7 +59,7 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - game of life"); InitWindow(screenWidth, screenHeight, "raylib [shaders] example - game of life");
const int menuWidth = 100; const int menuWidth = 100;
@ -81,7 +81,7 @@ int main(void)
{ "Puffer train", { 0.1f, 0.5f } }, { "Glider Gun", { 0.2f, 0.2f } }, { "Breeder", { 0.1f, 0.5f } }, { "Puffer train", { 0.1f, 0.5f } }, { "Glider Gun", { 0.2f, 0.2f } }, { "Breeder", { 0.1f, 0.5f } },
{ "Random", { 0.5f, 0.5f } } { "Random", { 0.5f, 0.5f } }
}; };
const int numberOfPresets = sizeof(presetPatterns)/sizeof(presetPatterns[0]); const int numberOfPresets = sizeof(presetPatterns)/sizeof(presetPatterns[0]);
int zoom = 1; int zoom = 1;
@ -90,7 +90,7 @@ int main(void)
int framesPerStep = 1; int framesPerStep = 1;
int frame = 0; int frame = 0;
int preset = -1; // No button pressed for preset int preset = -1; // No button pressed for preset
int mode = MODE_RUN; // Starting mode: running int mode = MODE_RUN; // Starting mode: running
bool buttonZoomIn = false; // Button states: false not pressed bool buttonZoomIn = false; // Button states: false not pressed
bool buttonZomOut = false; bool buttonZomOut = false;
@ -185,7 +185,7 @@ int main(void)
EndTextureMode(); EndTextureMode();
imageToDraw = (Image*)RL_MALLOC(sizeof(Image)); imageToDraw = (Image*)RL_MALLOC(sizeof(Image));
*imageToDraw = LoadImageFromTexture(worldOnScreen.texture); *imageToDraw = LoadImageFromTexture(worldOnScreen.texture);
UnloadRenderTexture(worldOnScreen); UnloadRenderTexture(worldOnScreen);
} }
@ -199,9 +199,9 @@ int main(void)
if (mouseY >= sizeInWorldY) mouseY = sizeInWorldY - 1; if (mouseY >= sizeInWorldY) mouseY = sizeInWorldY - 1;
if (firstColor == -1) firstColor = (GetImageColor(*imageToDraw, mouseX, mouseY).r < 5)? 0 : 1; if (firstColor == -1) firstColor = (GetImageColor(*imageToDraw, mouseX, mouseY).r < 5)? 0 : 1;
const int prevColor = (GetImageColor(*imageToDraw, mouseX, mouseY).r < 5)? 0 : 1; const int prevColor = (GetImageColor(*imageToDraw, mouseX, mouseY).r < 5)? 0 : 1;
ImageDrawPixel(imageToDraw, mouseX, mouseY, (firstColor) ? BLACK : RAYWHITE); ImageDrawPixel(imageToDraw, mouseX, mouseY, (firstColor) ? BLACK : RAYWHITE);
if (prevColor != firstColor) UpdateTextureRec(currentWorld->texture, (Rectangle){ floorf(offsetX), floorf(offsetY), (float)(sizeInWorldX), (float)(sizeInWorldY) }, imageToDraw->data); if (prevColor != firstColor) UpdateTextureRec(currentWorld->texture, (Rectangle){ floorf(offsetX), floorf(offsetY), (float)(sizeInWorldX), (float)(sizeInWorldY) }, imageToDraw->data);
} }
else firstColor = -1; else firstColor = -1;
@ -228,7 +228,7 @@ int main(void)
BeginTextureMode(*currentWorld); BeginTextureMode(*currentWorld);
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
EndTextureMode(); EndTextureMode();
UpdateTextureRec(currentWorld->texture, (Rectangle){ worldWidth*presetPatterns[preset].position.x - pattern.width/2.0f, UpdateTextureRec(currentWorld->texture, (Rectangle){ worldWidth*presetPatterns[preset].position.x - pattern.width/2.0f,
worldHeight*presetPatterns[preset].position.y - pattern.height/2.0f, worldHeight*presetPatterns[preset].position.y - pattern.height/2.0f,
(float)(pattern.width), (float)(pattern.height) }, pattern.data); (float)(pattern.width), (float)(pattern.height) }, pattern.data);
@ -256,7 +256,7 @@ int main(void)
} }
UnloadImage(pattern); UnloadImage(pattern);
mode = MODE_PAUSE; mode = MODE_PAUSE;
offsetX = worldWidth*presetPatterns[preset].position.x - (float)windowWidth/zoom/2.0f; offsetX = worldWidth*presetPatterns[preset].position.x - (float)windowWidth/zoom/2.0f;
offsetY = worldHeight*presetPatterns[preset].position.y - (float)windowHeight/zoom/2.0f; offsetY = worldHeight*presetPatterns[preset].position.y - (float)windowHeight/zoom/2.0f;
@ -293,7 +293,7 @@ int main(void)
// Draw to screen // Draw to screen
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
DrawTexturePro(currentWorld->texture, textureSourceToScreen, textureOnScreen, (Vector2){ 0, 0 }, 0.0f, WHITE); DrawTexturePro(currentWorld->texture, textureSourceToScreen, textureOnScreen, (Vector2){ 0, 0 }, 0.0f, WHITE);
DrawLine(windowWidth, 0, windowWidth, screenHeight, (Color){ 218, 218, 218, 255 }); DrawLine(windowWidth, 0, windowWidth, screenHeight, (Color){ 218, 218, 218, 255 });

View File

@ -31,7 +31,7 @@ typedef struct Ball {
Vector2 speed; Vector2 speed;
Vector2 prevPosition; Vector2 prevPosition;
float radius; float radius;
float friction; float friction;
float elasticity; float elasticity;
Color color; Color color;
bool grabbed; bool grabbed;
@ -62,7 +62,7 @@ int main(void)
.color = BLUE, .color = BLUE,
.grabbed = false .grabbed = false
}; };
int ballCount = 1; int ballCount = 1;
Ball *grabbedBall = NULL; // A pointer to the current ball that is grabbed Ball *grabbedBall = NULL; // A pointer to the current ball that is grabbed
Vector2 pressOffset = { 0 }; // Mouse press offset relative to the ball that grabbedd Vector2 pressOffset = { 0 }; // Mouse press offset relative to the ball that grabbedd
@ -157,10 +157,10 @@ int main(void)
{ {
ball->position.x = screenWidth - ball->radius; // Ball repositioning ball->position.x = screenWidth - ball->radius; // Ball repositioning
ball->speed.x = -ball->speed.x*ball->elasticity; // Elasticity makes the ball lose 10% of its velocity on hit ball->speed.x = -ball->speed.x*ball->elasticity; // Elasticity makes the ball lose 10% of its velocity on hit
} }
// Does the ball hit the screen left boundary? // Does the ball hit the screen left boundary?
else if ((ball->position.x - ball->radius) <= 0) else if ((ball->position.x - ball->radius) <= 0)
{ {
ball->position.x = ball->radius; ball->position.x = ball->radius;
ball->speed.x = -ball->speed.x*ball->elasticity; ball->speed.x = -ball->speed.x*ball->elasticity;
} }
@ -170,9 +170,9 @@ int main(void)
{ {
ball->position.y = screenHeight - ball->radius; ball->position.y = screenHeight - ball->radius;
ball->speed.y = -ball->speed.y*ball->elasticity; ball->speed.y = -ball->speed.y*ball->elasticity;
} }
else if ((ball->position.y - ball->radius) <= 0) else if ((ball->position.y - ball->radius) <= 0)
{ {
ball->position.y = ball->radius; ball->position.y = ball->radius;
ball->speed.y = -ball->speed.y*ball->elasticity; ball->speed.y = -ball->speed.y*ball->elasticity;
} }

View File

@ -72,7 +72,7 @@ typedef struct EasingFuncs {
// Module Functions Declaration // Module Functions Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Function used when "no easing" is selected for any axis // Function used when "no easing" is selected for any axis
static float NoEase(float t, float b, float c, float d); static float NoEase(float t, float b, float c, float d);
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition

View File

@ -46,13 +46,13 @@ int main(void)
float size = (float)GetScreenHeight(); float size = (float)GetScreenHeight();
int strokeCount = 0; int strokeCount = 0;
Vector2 *hilbertPath = LoadHilbertPath(order, size, &strokeCount); Vector2 *hilbertPath = LoadHilbertPath(order, size, &strokeCount);
int prevOrder = order; int prevOrder = order;
int prevSize = (int)size; // NOTE: Size from slider is float but for comparison we use int int prevSize = (int)size; // NOTE: Size from slider is float but for comparison we use int
int counter = 0; int counter = 0;
float thick = 2.0f; float thick = 2.0f;
bool animate = true; bool animate = true;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -68,19 +68,19 @@ int main(void)
{ {
UnloadHilbertPath(hilbertPath); UnloadHilbertPath(hilbertPath);
hilbertPath = LoadHilbertPath(order, size, &strokeCount); hilbertPath = LoadHilbertPath(order, size, &strokeCount);
if (animate) counter = 0; if (animate) counter = 0;
else counter = strokeCount; else counter = strokeCount;
prevOrder = order; prevOrder = order;
prevSize = (int)size; prevSize = (int)size;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
if (counter < strokeCount) if (counter < strokeCount)
@ -90,7 +90,7 @@ int main(void)
{ {
DrawLineEx(hilbertPath[i], hilbertPath[i - 1], thick, ColorFromHSV(((float)i/strokeCount)*360.0f, 1.0f, 1.0f)); DrawLineEx(hilbertPath[i], hilbertPath[i - 1], thick, ColorFromHSV(((float)i/strokeCount)*360.0f, 1.0f, 1.0f));
} }
counter += 1; counter += 1;
} }
else else
@ -101,13 +101,13 @@ int main(void)
DrawLineEx(hilbertPath[i], hilbertPath[i - 1], thick, ColorFromHSV(((float)i/strokeCount)*360.0f, 1.0f, 1.0f)); DrawLineEx(hilbertPath[i], hilbertPath[i - 1], thick, ColorFromHSV(((float)i/strokeCount)*360.0f, 1.0f, 1.0f));
} }
} }
// Draw UI using raygui // Draw UI using raygui
GuiCheckBox((Rectangle){ 450, 50, 20, 20 }, "ANIMATE GENERATION ON CHANGE", &animate); GuiCheckBox((Rectangle){ 450, 50, 20, 20 }, "ANIMATE GENERATION ON CHANGE", &animate);
GuiSpinner((Rectangle){ 585, 100, 180, 30 }, "HILBERT CURVE ORDER: ", &order, 2, 8, false); GuiSpinner((Rectangle){ 585, 100, 180, 30 }, "HILBERT CURVE ORDER: ", &order, 2, 8, false);
GuiSlider((Rectangle){ 524, 150, 240, 24 }, "THICKNESS: ", NULL, &thick, 1.0f, 10.0f); GuiSlider((Rectangle){ 524, 150, 240, 24 }, "THICKNESS: ", NULL, &thick, 1.0f, 10.0f);
GuiSlider((Rectangle){ 524, 190, 240, 24 }, "TOTAL SIZE: ", NULL, &size, 10.0f, GetScreenHeight()*1.5f); GuiSlider((Rectangle){ 524, 190, 240, 24 }, "TOTAL SIZE: ", NULL, &size, 10.0f, GetScreenHeight()*1.5f);
EndDrawing(); EndDrawing();
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
} }
@ -116,7 +116,7 @@ int main(void)
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadHilbertPath(hilbertPath); UnloadHilbertPath(hilbertPath);
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
@ -133,14 +133,14 @@ static Vector2 *LoadHilbertPath(int order, float size, int *strokeCount)
*strokeCount = N*N; *strokeCount = N*N;
Vector2 *hilbertPath = (Vector2 *)RL_CALLOC(*strokeCount, sizeof(Vector2)); Vector2 *hilbertPath = (Vector2 *)RL_CALLOC(*strokeCount, sizeof(Vector2));
for (int i = 0; i < *strokeCount; i++) for (int i = 0; i < *strokeCount; i++)
{ {
hilbertPath[i] = ComputeHilbertStep(order, i); hilbertPath[i] = ComputeHilbertStep(order, i);
hilbertPath[i].x = hilbertPath[i].x*len + len/2.0f; hilbertPath[i].x = hilbertPath[i].x*len + len/2.0f;
hilbertPath[i].y = hilbertPath[i].y*len + len/2.0f; hilbertPath[i].y = hilbertPath[i].y*len + len/2.0f;
} }
return hilbertPath; return hilbertPath;
} }
@ -160,7 +160,7 @@ static Vector2 ComputeHilbertStep(int order, int index)
[2] = { .x = 1, .y = 1 }, [2] = { .x = 1, .y = 1 },
[3] = { .x = 1, .y = 0 }, [3] = { .x = 1, .y = 0 },
}; };
int hilbertIndex = index&3; int hilbertIndex = index&3;
Vector2 vect = hilbertPoints[hilbertIndex]; Vector2 vect = hilbertPoints[hilbertIndex];
float temp = 0.0f; float temp = 0.0f;
@ -171,7 +171,7 @@ static Vector2 ComputeHilbertStep(int order, int index)
index = index >> 2; index = index >> 2;
hilbertIndex = index&3; hilbertIndex = index&3;
len = 1 << j; len = 1 << j;
switch (hilbertIndex) switch (hilbertIndex)
{ {
case 0: case 0:
@ -191,6 +191,6 @@ static Vector2 ComputeHilbertStep(int order, int index)
default: break; default: break;
} }
} }
return vect; return vect;
} }

View File

@ -106,7 +106,7 @@ int main(void)
if (generations > 0) rebuild = true; if (generations > 0) rebuild = true;
} }
} }
if (rebuild) if (rebuild)
{ {
RL_FREE(ls.production); // Free previous production for re-creation RL_FREE(ls.production); // Free previous production for re-creation
@ -118,15 +118,15 @@ int main(void)
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground( RAYWHITE ); ClearBackground( RAYWHITE );
if (generations > 0) DrawPenroseLSystem(&ls); if (generations > 0) DrawPenroseLSystem(&ls);
DrawText("penrose l-system", 10, 10, 20, DARKGRAY); DrawText("penrose l-system", 10, 10, 20, DARKGRAY);
DrawText("press up or down to change generations", 10, 30, 20, DARKGRAY); DrawText("press up or down to change generations", 10, 30, 20, DARKGRAY);
DrawText(TextFormat("generations: %d", generations), 10, 50, 20, DARKGRAY); DrawText(TextFormat("generations: %d", generations), 10, 50, 20, DARKGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@ -171,11 +171,11 @@ static PenroseLSystem CreatePenroseLSystem(float drawLength)
.drawLength = drawLength, .drawLength = drawLength,
.theta = 36.0f // Degrees .theta = 36.0f // Degrees
}; };
ls.production = (char *)RL_MALLOC(sizeof(char)*STR_MAX_SIZE); ls.production = (char *)RL_MALLOC(sizeof(char)*STR_MAX_SIZE);
ls.production[0] = '\0'; ls.production[0] = '\0';
strncpy(ls.production, "[X]++[X]++[X]++[X]++[X]", STR_MAX_SIZE); strncpy(ls.production, "[X]++[X]++[X]++[X]++[X]", STR_MAX_SIZE);
return ls; return ls;
} }
@ -211,7 +211,7 @@ static void BuildProductionStep(PenroseLSystem *ls)
ls->drawLength *= 0.5f; ls->drawLength *= 0.5f;
strncpy(ls->production, newProduction, STR_MAX_SIZE); strncpy(ls->production, newProduction, STR_MAX_SIZE);
RL_FREE(newProduction); RL_FREE(newProduction);
} }
@ -228,9 +228,9 @@ static void DrawPenroseLSystem(PenroseLSystem *ls)
int repeats = 1; int repeats = 1;
int productionLength = (int)strnlen(ls->production, STR_MAX_SIZE); int productionLength = (int)strnlen(ls->production, STR_MAX_SIZE);
ls->steps += 12; ls->steps += 12;
if (ls->steps > productionLength) ls->steps = productionLength; if (ls->steps > productionLength) ls->steps = productionLength;
for (int i = 0; i < ls->steps; i++) for (int i = 0; i < ls->steps; i++)
{ {
char step = ls->production[i]; char step = ls->production[i];
@ -244,24 +244,24 @@ static void DrawPenroseLSystem(PenroseLSystem *ls)
turtle.origin.y += ls->drawLength*sinf(radAngle); turtle.origin.y += ls->drawLength*sinf(radAngle);
Vector2 startPosScreen = { startPosWorld.x + screenCenter.x, startPosWorld.y + screenCenter.y }; Vector2 startPosScreen = { startPosWorld.x + screenCenter.x, startPosWorld.y + screenCenter.y };
Vector2 endPosScreen = { turtle.origin.x + screenCenter.x, turtle.origin.y + screenCenter.y }; Vector2 endPosScreen = { turtle.origin.x + screenCenter.x, turtle.origin.y + screenCenter.y };
DrawLineEx(startPosScreen, endPosScreen, 2, Fade(BLACK, 0.2f)); DrawLineEx(startPosScreen, endPosScreen, 2, Fade(BLACK, 0.2f));
} }
repeats = 1; repeats = 1;
} }
else if (step == '+') else if (step == '+')
{ {
for (int j = 0; j < repeats; j++) turtle.angle += ls->theta; for (int j = 0; j < repeats; j++) turtle.angle += ls->theta;
repeats = 1; repeats = 1;
} }
else if (step == '-') else if (step == '-')
{ {
for (int j = 0; j < repeats; j++) turtle.angle += -ls->theta; for (int j = 0; j < repeats; j++) turtle.angle += -ls->theta;
repeats = 1; repeats = 1;
} }
else if (step == '[') PushTurtleState(turtle); else if (step == '[') PushTurtleState(turtle);
else if (step == ']') turtle = PopTurtleState(); else if (step == ']') turtle = PopTurtleState();
else if ((step >= 48) && (step <= 57)) repeats = (int) step - 48; else if ((step >= 48) && (step <= 57)) repeats = (int) step - 48;

View File

@ -33,7 +33,7 @@ typedef struct TextParticle {
Vector2 ppos; // Previous position Vector2 ppos; // Previous position
float padding; float padding;
float borderWidth; float borderWidth;
float friction; float friction;
float elasticity; float elasticity;
Color color; Color color;
bool grabbed; bool grabbed;
@ -118,7 +118,7 @@ int main(void)
if (IsKeyDown(KEY_LEFT_SHIFT)) if (IsKeyDown(KEY_LEFT_SHIFT))
{ {
ShatterTextParticle(tp, i, textParticles, &particleCount); ShatterTextParticle(tp, i, textParticles, &particleCount);
} }
else else
{ {
SliceTextParticle(tp, i, TextLength(tp->text)/2, textParticles, &particleCount); SliceTextParticle(tp, i, TextLength(tp->text)/2, textParticles, &particleCount);
@ -158,33 +158,33 @@ int main(void)
TextParticle *tp = &textParticles[i]; TextParticle *tp = &textParticles[i];
// The text particle is not grabbed // The text particle is not grabbed
if (!tp->grabbed) if (!tp->grabbed)
{ {
// text particle repositioning using the velocity // text particle repositioning using the velocity
tp->rect.x += tp->vel.x * delta; tp->rect.x += tp->vel.x * delta;
tp->rect.y += tp->vel.y * delta; tp->rect.y += tp->vel.y * delta;
// Does the text particle hit the screen right boundary? // Does the text particle hit the screen right boundary?
if ((tp->rect.x + tp->rect.width) >= screenWidth) if ((tp->rect.x + tp->rect.width) >= screenWidth)
{ {
tp->rect.x = screenWidth - tp->rect.width; // Text particle repositioning tp->rect.x = screenWidth - tp->rect.width; // Text particle repositioning
tp->vel.x = -tp->vel.x*tp->elasticity; // Elasticity makes the text particle lose 10% of its velocity on hit tp->vel.x = -tp->vel.x*tp->elasticity; // Elasticity makes the text particle lose 10% of its velocity on hit
} }
// Does the text particle hit the screen left boundary? // Does the text particle hit the screen left boundary?
else if (tp->rect.x <= 0) else if (tp->rect.x <= 0)
{ {
tp->rect.x = 0.0f; tp->rect.x = 0.0f;
tp->vel.x = -tp->vel.x*tp->elasticity; tp->vel.x = -tp->vel.x*tp->elasticity;
} }
// The same for y axis // The same for y axis
if ((tp->rect.y + tp->rect.height) >= screenHeight) if ((tp->rect.y + tp->rect.height) >= screenHeight)
{ {
tp->rect.y = screenHeight - tp->rect.height; tp->rect.y = screenHeight - tp->rect.height;
tp->vel.y = -tp->vel.y*tp->elasticity; tp->vel.y = -tp->vel.y*tp->elasticity;
} }
else if (tp->rect.y <= 0) else if (tp->rect.y <= 0)
{ {
tp->rect.y = 0.0f; tp->rect.y = 0.0f;
tp->vel.y = -tp->vel.y*tp->elasticity; tp->vel.y = -tp->vel.y*tp->elasticity;
} }
@ -264,9 +264,9 @@ int main(void)
void PrepareFirstTextParticle(const char* text, TextParticle *tps, int *particleCount) void PrepareFirstTextParticle(const char* text, TextParticle *tps, int *particleCount)
{ {
tps[0] = CreateTextParticle( tps[0] = CreateTextParticle(
text, text,
GetScreenWidth()/2.0f, GetScreenWidth()/2.0f,
GetScreenHeight()/2.0f, GetScreenHeight()/2.0f,
RAYWHITE RAYWHITE
); );
*particleCount = 1; *particleCount = 1;
@ -317,7 +317,7 @@ void SliceTextParticleByChar(TextParticle *tp, char charToSlice, TextParticle *t
{ {
int tokenCount = 0; int tokenCount = 0;
char **tokens = TextSplit(tp->text, charToSlice, &tokenCount); char **tokens = TextSplit(tp->text, charToSlice, &tokenCount);
if (tokenCount > 1) if (tokenCount > 1)
{ {
int textLength = TextLength(tp->text); int textLength = TextLength(tp->text);

View File

@ -51,7 +51,7 @@ int main(void)
{ {
// Unload textures to avoid memory leaks // Unload textures to avoid memory leaks
for (int i = 0; i < MAX_TEXTURE_COLLECTION; i++) UnloadTexture(collection[i].texture); for (int i = 0; i < MAX_TEXTURE_COLLECTION; i++) UnloadTexture(collection[i].texture);
currentCollectionIndex = 0; currentCollectionIndex = 0;
} }
@ -59,7 +59,7 @@ int main(void)
(currentCollectionIndex < MAX_TEXTURE_COLLECTION)) (currentCollectionIndex < MAX_TEXTURE_COLLECTION))
{ {
Image image = GetClipboardImage(); Image image = GetClipboardImage();
if (IsImageValid(image)) if (IsImageValid(image))
{ {
collection[currentCollectionIndex].texture = LoadTextureFromImage(image); collection[currentCollectionIndex].texture = LoadTextureFromImage(image);
@ -76,15 +76,15 @@ int main(void)
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
for (int i = 0; i < currentCollectionIndex; i++) for (int i = 0; i < currentCollectionIndex; i++)
{ {
if (IsTextureValid(collection[i].texture)) if (IsTextureValid(collection[i].texture))
{ {
DrawTexturePro(collection[i].texture, DrawTexturePro(collection[i].texture,
(Rectangle){0,0,collection[i].texture.width, collection[i].texture.height}, (Rectangle){0,0,collection[i].texture.width, collection[i].texture.height},
(Rectangle){collection[i].position.x,collection[i].position.y,collection[i].texture.width, collection[i].texture.height}, (Rectangle){collection[i].position.x,collection[i].position.y,collection[i].texture.width, collection[i].texture.height},
(Vector2){collection[i].texture.width*0.5f, collection[i].texture.height*0.5f}, (Vector2){collection[i].texture.width*0.5f, collection[i].texture.height*0.5f},
0.0f, WHITE); 0.0f, WHITE);
} }
} }

View File

@ -3,7 +3,7 @@
* raylib textures example - magnifying glass * raylib textures example - magnifying glass
* *
* Example complexity rating: [★★★☆] 3/4 * Example complexity rating: [★★★☆] 3/4
* *
* Example originally created with raylib 5.6, last time updated with raylib 5.6 * Example originally created with raylib 5.6, last time updated with raylib 5.6
* *
* Example contributed by Luke Vaughan (@badram) and reviewed by Ramon Santamaria (@raysan5) * Example contributed by Luke Vaughan (@badram) and reviewed by Ramon Santamaria (@raysan5)
@ -29,18 +29,18 @@ int main(void)
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - magnifying glass"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - magnifying glass");
Texture2D bunny = LoadTexture("resources/raybunny.png"); Texture2D bunny = LoadTexture("resources/raybunny.png");
Texture2D parrots = LoadTexture("resources/parrots.png"); Texture2D parrots = LoadTexture("resources/parrots.png");
// Use image draw to generate a mask texture instead of loading it from a file. // Use image draw to generate a mask texture instead of loading it from a file.
Image circle = GenImageColor(256, 256, BLANK); Image circle = GenImageColor(256, 256, BLANK);
ImageDrawCircle(&circle, 128, 128, 128, WHITE); ImageDrawCircle(&circle, 128, 128, 128, WHITE);
Texture2D mask = LoadTextureFromImage(circle); // Copy the mask image from RAM to VRAM Texture2D mask = LoadTextureFromImage(circle); // Copy the mask image from RAM to VRAM
UnloadImage(circle); // Unload the image from RAM UnloadImage(circle); // Unload the image from RAM
RenderTexture2D magnifiedWorld = LoadRenderTexture(256, 256); RenderTexture2D magnifiedWorld = LoadRenderTexture(256, 256);
Camera2D camera = { 0 }; Camera2D camera = { 0 };
// Set magnifying glass zoom // Set magnifying glass zoom
camera.zoom = 2; camera.zoom = 2;
@ -71,7 +71,7 @@ int main(void)
DrawTexture(parrots, 144, 33, WHITE); DrawTexture(parrots, 144, 33, WHITE);
DrawText("Use the magnifying glass to find hidden bunnies!", 154, 6, 20, BLACK); DrawText("Use the magnifying glass to find hidden bunnies!", 154, 6, 20, BLACK);
// Render to a the magnifying glass // Render to a the magnifying glass
BeginTextureMode(magnifiedWorld); BeginTextureMode(magnifiedWorld);
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);

View File

@ -52,7 +52,7 @@ int main(void)
float hue = t*t; float hue = t*t;
float saturation = t; float saturation = t;
float value = t; float value = t;
palette[i] = ColorFromHSV(250.0f + 150.0f*hue, saturation, value); palette[i] = ColorFromHSV(250.0f + 150.0f*hue, saturation, value);
} }
@ -92,14 +92,14 @@ int main(void)
{ {
unsigned int i = x + y*imageWidth; unsigned int i = x + y*imageWidth;
unsigned char colorIndex = indexBuffer[i]; unsigned char colorIndex = indexBuffer[i];
if (colorIndex != 0) if (colorIndex != 0)
{ {
// Move pixel a row above // Move pixel a row above
indexBuffer[i] = 0; indexBuffer[i] = 0;
int moveX = GetRandomValue(0, 2) - 1; int moveX = GetRandomValue(0, 2) - 1;
int newX = x + moveX; int newX = x + moveX;
if ((newX > 0) && (newX < imageWidth)) if ((newX > 0) && (newX < imageWidth))
{ {
unsigned int iabove = i - imageWidth + moveX; unsigned int iabove = i - imageWidth + moveX;
@ -130,7 +130,7 @@ int main(void)
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawTextureEx(screenTexture, (Vector2){ 0, 0 }, 0.0f, 2.0f, WHITE); DrawTextureEx(screenTexture, (Vector2){ 0, 0 }, 0.0f, 2.0f, WHITE);

58
src/external/rlsw.h vendored
View File

@ -2281,7 +2281,7 @@ static inline sw_pixel_write_color_f sw_pixel_get_write_color_func(sw_pixelforma
{ {
case SW_PIXELFORMAT_COLOR_GRAYSCALE: return sw_pixel_write_color_GRAYSCALE; case SW_PIXELFORMAT_COLOR_GRAYSCALE: return sw_pixel_write_color_GRAYSCALE;
case SW_PIXELFORMAT_COLOR_GRAYALPHA: return sw_pixel_write_color_GRAYALPHA; case SW_PIXELFORMAT_COLOR_GRAYALPHA: return sw_pixel_write_color_GRAYALPHA;
case SW_PIXELFORMAT_COLOR_R3G3B2: return sw_pixel_write_color_R3G3B2; case SW_PIXELFORMAT_COLOR_R3G3B2: return sw_pixel_write_color_R3G3B2;
case SW_PIXELFORMAT_COLOR_R5G6B5: return sw_pixel_write_color_R5G6B5; case SW_PIXELFORMAT_COLOR_R5G6B5: return sw_pixel_write_color_R5G6B5;
case SW_PIXELFORMAT_COLOR_R8G8B8: return sw_pixel_write_color_R8G8B8; case SW_PIXELFORMAT_COLOR_R8G8B8: return sw_pixel_write_color_R8G8B8;
case SW_PIXELFORMAT_COLOR_R5G5B5A1: return sw_pixel_write_color_R5G5B5A1; case SW_PIXELFORMAT_COLOR_R5G5B5A1: return sw_pixel_write_color_R5G5B5A1;
@ -2472,7 +2472,7 @@ static inline void sw_texture_sample_linear(float *SW_RESTRICT color, const sw_t
static inline void sw_texture_sample(float *SW_RESTRICT color, const sw_texture_t *SW_RESTRICT tex, static inline void sw_texture_sample(float *SW_RESTRICT color, const sw_texture_t *SW_RESTRICT tex,
float u, float v, float dUdx, float dUdy, float dVdx, float dVdy) float u, float v, float dUdx, float dUdy, float dVdx, float dVdy)
{ {
// NOTE: Commented there is the previous method used // NOTE: Commented there is the previous method used
// There was no need to compute the square root because // There was no need to compute the square root because
// using the squared value, the comparison remains (L2 > 1.0f*1.0f) // using the squared value, the comparison remains (L2 > 1.0f*1.0f)
//float du = sqrtf(dUdx*dUdx + dUdy*dUdy); //float du = sqrtf(dUdx*dUdx + dUdy*dUdy);
@ -2673,7 +2673,7 @@ static inline void sw_framebuffer_output_copy(void *dst, const sw_texture_t *buf
} }
} }
static inline void sw_framebuffer_output_blit(void *dst, const sw_texture_t *buffer, static inline void sw_framebuffer_output_blit(void *dst, const sw_texture_t *buffer,
int xDst, int yDst, int wDst, int hDst, int xSrc, int ySrc, int wSrc, int hSrc, sw_pixelformat_t format) int xDst, int yDst, int wDst, int hDst, int xSrc, int ySrc, int wSrc, int hSrc, sw_pixelformat_t format)
{ {
const uint8_t *srcBase = buffer->pixels; const uint8_t *srcBase = buffer->pixels;
@ -3007,25 +3007,25 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#define RLSW_TEMPLATE_RASTER_TRIANGLE BASE #define RLSW_TEMPLATE_RASTER_TRIANGLE BASE
#include __FILE__ // IWYU pragma: keep #include __FILE__ // IWYU pragma: keep
#undef RLSW_TEMPLATE_RASTER_TRIANGLE #undef RLSW_TEMPLATE_RASTER_TRIANGLE
#define RLSW_TEMPLATE_RASTER_TRIANGLE TEX #define RLSW_TEMPLATE_RASTER_TRIANGLE TEX
#define SW_ENABLE_TEXTURE #define SW_ENABLE_TEXTURE
#include __FILE__ #include __FILE__
#undef SW_ENABLE_TEXTURE #undef SW_ENABLE_TEXTURE
#undef RLSW_TEMPLATE_RASTER_TRIANGLE #undef RLSW_TEMPLATE_RASTER_TRIANGLE
#define RLSW_TEMPLATE_RASTER_TRIANGLE DEPTH #define RLSW_TEMPLATE_RASTER_TRIANGLE DEPTH
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
#include __FILE__ #include __FILE__
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef RLSW_TEMPLATE_RASTER_TRIANGLE #undef RLSW_TEMPLATE_RASTER_TRIANGLE
#define RLSW_TEMPLATE_RASTER_TRIANGLE BLEND #define RLSW_TEMPLATE_RASTER_TRIANGLE BLEND
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
#include __FILE__ #include __FILE__
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef RLSW_TEMPLATE_RASTER_TRIANGLE #undef RLSW_TEMPLATE_RASTER_TRIANGLE
#define RLSW_TEMPLATE_RASTER_TRIANGLE TEX_DEPTH #define RLSW_TEMPLATE_RASTER_TRIANGLE TEX_DEPTH
#define SW_ENABLE_TEXTURE #define SW_ENABLE_TEXTURE
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
@ -3033,7 +3033,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef SW_ENABLE_TEXTURE #undef SW_ENABLE_TEXTURE
#undef RLSW_TEMPLATE_RASTER_TRIANGLE #undef RLSW_TEMPLATE_RASTER_TRIANGLE
#define RLSW_TEMPLATE_RASTER_TRIANGLE TEX_BLEND #define RLSW_TEMPLATE_RASTER_TRIANGLE TEX_BLEND
#define SW_ENABLE_TEXTURE #define SW_ENABLE_TEXTURE
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
@ -3041,7 +3041,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef SW_ENABLE_TEXTURE #undef SW_ENABLE_TEXTURE
#undef RLSW_TEMPLATE_RASTER_TRIANGLE #undef RLSW_TEMPLATE_RASTER_TRIANGLE
#define RLSW_TEMPLATE_RASTER_TRIANGLE DEPTH_BLEND #define RLSW_TEMPLATE_RASTER_TRIANGLE DEPTH_BLEND
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
@ -3049,7 +3049,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef RLSW_TEMPLATE_RASTER_TRIANGLE #undef RLSW_TEMPLATE_RASTER_TRIANGLE
#define RLSW_TEMPLATE_RASTER_TRIANGLE TEX_DEPTH_BLEND #define RLSW_TEMPLATE_RASTER_TRIANGLE TEX_DEPTH_BLEND
#define SW_ENABLE_TEXTURE #define SW_ENABLE_TEXTURE
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
@ -3059,7 +3059,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef SW_ENABLE_TEXTURE #undef SW_ENABLE_TEXTURE
#undef RLSW_TEMPLATE_RASTER_TRIANGLE #undef RLSW_TEMPLATE_RASTER_TRIANGLE
// Dispatch table (auto-generated from SW_RASTER_VARIANTS) // Dispatch table (auto-generated from SW_RASTER_VARIANTS)
#define SW_TABLE_ENTRY(NAME, FLAGS) [FLAGS] = sw_raster_triangle_##NAME, #define SW_TABLE_ENTRY(NAME, FLAGS) [FLAGS] = sw_raster_triangle_##NAME,
static const sw_raster_triangle_f SW_RASTER_TRIANGLE_TABLE[] = { static const sw_raster_triangle_f SW_RASTER_TRIANGLE_TABLE[] = {
@ -3106,25 +3106,25 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#define RLSW_TEMPLATE_RASTER_QUAD BASE #define RLSW_TEMPLATE_RASTER_QUAD BASE
#include __FILE__ // IWYU pragma: keep #include __FILE__ // IWYU pragma: keep
#undef RLSW_TEMPLATE_RASTER_QUAD #undef RLSW_TEMPLATE_RASTER_QUAD
#define RLSW_TEMPLATE_RASTER_QUAD TEX #define RLSW_TEMPLATE_RASTER_QUAD TEX
#define SW_ENABLE_TEXTURE #define SW_ENABLE_TEXTURE
#include __FILE__ #include __FILE__
#undef SW_ENABLE_TEXTURE #undef SW_ENABLE_TEXTURE
#undef RLSW_TEMPLATE_RASTER_QUAD #undef RLSW_TEMPLATE_RASTER_QUAD
#define RLSW_TEMPLATE_RASTER_QUAD DEPTH #define RLSW_TEMPLATE_RASTER_QUAD DEPTH
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
#include __FILE__ #include __FILE__
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef RLSW_TEMPLATE_RASTER_QUAD #undef RLSW_TEMPLATE_RASTER_QUAD
#define RLSW_TEMPLATE_RASTER_QUAD BLEND #define RLSW_TEMPLATE_RASTER_QUAD BLEND
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
#include __FILE__ #include __FILE__
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef RLSW_TEMPLATE_RASTER_QUAD #undef RLSW_TEMPLATE_RASTER_QUAD
#define RLSW_TEMPLATE_RASTER_QUAD TEX_DEPTH #define RLSW_TEMPLATE_RASTER_QUAD TEX_DEPTH
#define SW_ENABLE_TEXTURE #define SW_ENABLE_TEXTURE
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
@ -3132,7 +3132,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef SW_ENABLE_TEXTURE #undef SW_ENABLE_TEXTURE
#undef RLSW_TEMPLATE_RASTER_QUAD #undef RLSW_TEMPLATE_RASTER_QUAD
#define RLSW_TEMPLATE_RASTER_QUAD TEX_BLEND #define RLSW_TEMPLATE_RASTER_QUAD TEX_BLEND
#define SW_ENABLE_TEXTURE #define SW_ENABLE_TEXTURE
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
@ -3140,7 +3140,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef SW_ENABLE_TEXTURE #undef SW_ENABLE_TEXTURE
#undef RLSW_TEMPLATE_RASTER_QUAD #undef RLSW_TEMPLATE_RASTER_QUAD
#define RLSW_TEMPLATE_RASTER_QUAD DEPTH_BLEND #define RLSW_TEMPLATE_RASTER_QUAD DEPTH_BLEND
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
@ -3148,7 +3148,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef RLSW_TEMPLATE_RASTER_QUAD #undef RLSW_TEMPLATE_RASTER_QUAD
#define RLSW_TEMPLATE_RASTER_QUAD TEX_DEPTH_BLEND #define RLSW_TEMPLATE_RASTER_QUAD TEX_DEPTH_BLEND
#define SW_ENABLE_TEXTURE #define SW_ENABLE_TEXTURE
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
@ -3158,7 +3158,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef SW_ENABLE_TEXTURE #undef SW_ENABLE_TEXTURE
#undef RLSW_TEMPLATE_RASTER_QUAD #undef RLSW_TEMPLATE_RASTER_QUAD
// Dispatch table (auto-generated from SW_RASTER_VARIANTS) // Dispatch table (auto-generated from SW_RASTER_VARIANTS)
#define SW_TABLE_ENTRY(NAME, FLAGS) [FLAGS] = sw_raster_quad_##NAME, #define SW_TABLE_ENTRY(NAME, FLAGS) [FLAGS] = sw_raster_quad_##NAME,
static const sw_raster_quad_f SW_RASTER_QUAD_TABLE[] = { static const sw_raster_quad_f SW_RASTER_QUAD_TABLE[] = {
@ -3202,19 +3202,19 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#define RLSW_TEMPLATE_RASTER_LINE BASE #define RLSW_TEMPLATE_RASTER_LINE BASE
#include __FILE__ // IWYU pragma: keep #include __FILE__ // IWYU pragma: keep
#undef RLSW_TEMPLATE_RASTER_LINE #undef RLSW_TEMPLATE_RASTER_LINE
#define RLSW_TEMPLATE_RASTER_LINE DEPTH #define RLSW_TEMPLATE_RASTER_LINE DEPTH
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
#include __FILE__ #include __FILE__
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef RLSW_TEMPLATE_RASTER_LINE #undef RLSW_TEMPLATE_RASTER_LINE
#define RLSW_TEMPLATE_RASTER_LINE BLEND #define RLSW_TEMPLATE_RASTER_LINE BLEND
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
#include __FILE__ #include __FILE__
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef RLSW_TEMPLATE_RASTER_LINE #undef RLSW_TEMPLATE_RASTER_LINE
#define RLSW_TEMPLATE_RASTER_LINE DEPTH_BLEND #define RLSW_TEMPLATE_RASTER_LINE DEPTH_BLEND
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
@ -3222,7 +3222,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef RLSW_TEMPLATE_RASTER_LINE #undef RLSW_TEMPLATE_RASTER_LINE
// Dispatch table (auto-generated from SW_RASTER_VARIANTS) // Dispatch table (auto-generated from SW_RASTER_VARIANTS)
#define SW_TABLE_ENTRY0(NAME, FLAGS) [FLAGS] = sw_raster_line_##NAME, #define SW_TABLE_ENTRY0(NAME, FLAGS) [FLAGS] = sw_raster_line_##NAME,
#define SW_TABLE_ENTRY1(NAME, FLAGS) [FLAGS] = sw_raster_line_thick_##NAME, #define SW_TABLE_ENTRY1(NAME, FLAGS) [FLAGS] = sw_raster_line_thick_##NAME,
@ -3266,19 +3266,19 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#define RLSW_TEMPLATE_RASTER_POINT BASE #define RLSW_TEMPLATE_RASTER_POINT BASE
#include __FILE__ // IWYU pragma: keep #include __FILE__ // IWYU pragma: keep
#undef RLSW_TEMPLATE_RASTER_POINT #undef RLSW_TEMPLATE_RASTER_POINT
#define RLSW_TEMPLATE_RASTER_POINT DEPTH #define RLSW_TEMPLATE_RASTER_POINT DEPTH
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
#include __FILE__ #include __FILE__
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef RLSW_TEMPLATE_RASTER_POINT #undef RLSW_TEMPLATE_RASTER_POINT
#define RLSW_TEMPLATE_RASTER_POINT BLEND #define RLSW_TEMPLATE_RASTER_POINT BLEND
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
#include __FILE__ #include __FILE__
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef RLSW_TEMPLATE_RASTER_POINT #undef RLSW_TEMPLATE_RASTER_POINT
#define RLSW_TEMPLATE_RASTER_POINT DEPTH_BLEND #define RLSW_TEMPLATE_RASTER_POINT DEPTH_BLEND
#define SW_ENABLE_DEPTH_TEST #define SW_ENABLE_DEPTH_TEST
#define SW_ENABLE_BLEND #define SW_ENABLE_BLEND
@ -3286,7 +3286,7 @@ static bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VERTICES]
#undef SW_ENABLE_BLEND #undef SW_ENABLE_BLEND
#undef SW_ENABLE_DEPTH_TEST #undef SW_ENABLE_DEPTH_TEST
#undef RLSW_TEMPLATE_RASTER_POINT #undef RLSW_TEMPLATE_RASTER_POINT
// Dispatch table (auto-generated from SW_RASTER_VARIANTS) // Dispatch table (auto-generated from SW_RASTER_VARIANTS)
#define SW_TABLE_ENTRY(NAME, FLAGS) [FLAGS] = sw_raster_point_##NAME, #define SW_TABLE_ENTRY(NAME, FLAGS) [FLAGS] = sw_raster_point_##NAME,
static const sw_raster_point_f SW_RASTER_POINT_TABLE[] = { static const sw_raster_point_f SW_RASTER_POINT_TABLE[] = {
@ -5171,7 +5171,7 @@ void swFramebufferTexture2D(SWattachment attach, uint32_t texture)
RLSW.colorBuffer = sw_pool_get(&RLSW.texturePool, texture); RLSW.colorBuffer = sw_pool_get(&RLSW.texturePool, texture);
} break; } break;
case SW_DEPTH_ATTACHMENT: case SW_DEPTH_ATTACHMENT:
{ {
fb->depthAttachment = texture; fb->depthAttachment = texture;
RLSW.depthBuffer = sw_pool_get(&RLSW.texturePool, texture); RLSW.depthBuffer = sw_pool_get(&RLSW.texturePool, texture);
} break; } break;
@ -5262,7 +5262,7 @@ void swGetFramebufferAttachmentParameteriv(SWattachment attachment, SWattachget
static void SW_RASTER_TRIANGLE_SPAN(const sw_vertex_t *start, const sw_vertex_t *end, float dUdy, float dVdy) static void SW_RASTER_TRIANGLE_SPAN(const sw_vertex_t *start, const sw_vertex_t *end, float dUdy, float dVdy)
{ {
// Gets the start/end coordinates and skip empty lines // Gets the start/end coordinates and skip empty lines
int xStart = (int)start->position[0]; int xStart = (int)start->position[0];
int xEnd = (int)end->position[0]; int xEnd = (int)end->position[0];
if (xStart == xEnd) return; if (xStart == xEnd) return;

View File

@ -684,7 +684,7 @@ void InitWindow(int width, int height, const char *title)
} }
// Initialize render dimensions for embedded platforms // Initialize render dimensions for embedded platforms
// NOTE: On desktop platforms (GLFW, SDL, etc.), CORE.Window.render.width/height are set during window creation // NOTE: On desktop platforms (GLFW, SDL, etc.), CORE.Window.render.width/height are set during window creation
// On embedded platforms with no window manager, InitPlatform() doesn't set these values, so they should be initialized // On embedded platforms with no window manager, InitPlatform() doesn't set these values, so they should be initialized
// here from screen dimensions (which are set from the InitWindow parameters) // here from screen dimensions (which are set from the InitWindow parameters)
if ((CORE.Window.render.width == 0) || (CORE.Window.render.height == 0)) if ((CORE.Window.render.width == 0) || (CORE.Window.render.height == 0))

View File

@ -2265,7 +2265,6 @@ int GetCodepoint(const char *text, int *codepointSize)
0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
*/ */
int codepoint = 0x3f; // Codepoint (defaults to '?') int codepoint = 0x3f; // Codepoint (defaults to '?')
*codepointSize = 1; *codepointSize = 1;
if (text == NULL) return codepoint; if (text == NULL) return codepoint;