Merge branch 'master' of github.com:raysan5/raylib

This commit is contained in:
Jeff Myers 2024-06-25 16:01:11 -07:00
commit 606051950a
24 changed files with 483 additions and 404 deletions

View File

@ -97,7 +97,7 @@ int main(void)
DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
for (int i = 0; i < 400; i++)
{
DrawLine(201 + i, 232 - averageVolume[i] * 32, 201 + i, 232, MAROON);
DrawLine(201 + i, 232 - (int)averageVolume[i] * 32, 201 + i, 232, MAROON);
}
DrawRectangleLines(199, 199, 402, 34, GRAY);

View File

@ -133,10 +133,10 @@ int main(void)
for (int i = 0; i < envItemsLength; i++) DrawRectangleRec(envItems[i].rect, envItems[i].color);
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40, 40 };
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f };
DrawRectangleRec(playerRect, RED);
DrawCircle(player.position.x, player.position.y, 5, GOLD);
DrawCircleV(player.position, 5.0f, GOLD);
EndMode2D();

View File

@ -36,7 +36,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
boxPositionY -= (GetMouseWheelMove()*scrollSpeed);
boxPositionY -= (int)(GetMouseWheelMove()*scrollSpeed);
//----------------------------------------------------------------------------------
// Draw

View File

@ -41,7 +41,7 @@ int main(void) {
int rectCount = 20;
float rectSize = (float)screenWidth/rectCount;
ColorRect* rectangles = GenerateRandomColorRectSequence(rectCount, rectSize, screenWidth, 0.75f * screenHeight);
ColorRect* rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -62,7 +62,7 @@ int main(void) {
rectCount++;
rectSize = (float)screenWidth/rectCount;
free(rectangles);
rectangles = GenerateRandomColorRectSequence(rectCount, rectSize, screenWidth, 0.75f * screenHeight);
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
}
if(IsKeyPressed(KEY_DOWN))
@ -71,7 +71,7 @@ int main(void) {
rectCount--;
rectSize = (float)screenWidth/rectCount;
free(rectangles);
rectangles = GenerateRandomColorRectSequence(rectCount, rectSize, screenWidth, 0.75f * screenHeight);
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
}
}
@ -121,17 +121,17 @@ static Color GenerateRandomColor()
}
static ColorRect* GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight){
int *seq = LoadRandomSequence(rectCount, 0, rectCount-1);
ColorRect* rectangles = (ColorRect *)malloc(rectCount*sizeof(ColorRect));
int *seq = LoadRandomSequence((unsigned int)rectCount, 0, (unsigned int)rectCount-1);
ColorRect* rectangles = (ColorRect *)malloc((int)rectCount*sizeof(ColorRect));
float rectSeqWidth = rectCount * rectWidth;
int startX = (screenWidth - rectSeqWidth) * 0.5f;
float startX = (screenWidth - rectSeqWidth) * 0.5f;
for(int x=0;x<rectCount;x++){
int rectHeight = Remap(seq[x], 0, rectCount-1, 0, screenHeight);
int rectHeight = (int)Remap((float)seq[x], 0, rectCount-1, 0, screenHeight);
rectangles[x].c = GenerateRandomColor();
rectangles[x].r = CLITERAL(Rectangle){
startX + x * rectWidth, screenHeight - rectHeight, rectWidth, rectHeight
startX + x * rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight
};
}
UnloadRandomSequence(seq);

View File

@ -69,18 +69,18 @@ int main(void)
rotation += 60.0f*GetFrameTime(); // Rotate the rectangles, 60 degrees per second
// Make the camera move to demonstrate the effect
cameraX = (sinf(GetTime())*50.0f) - 10.0f;
cameraY = cosf(GetTime())*30.0f;
cameraX = (sinf((float)GetTime())*50.0f) - 10.0f;
cameraY = cosf((float)GetTime())*30.0f;
// Set the camera's target to the values computed above
screenSpaceCamera.target = (Vector2){ cameraX, cameraY };
// Round worldSpace coordinates, keep decimals into screenSpace coordinates
worldSpaceCamera.target.x = (int)screenSpaceCamera.target.x;
worldSpaceCamera.target.x = truncf(screenSpaceCamera.target.x);
screenSpaceCamera.target.x -= worldSpaceCamera.target.x;
screenSpaceCamera.target.x *= virtualRatio;
worldSpaceCamera.target.y = (int)screenSpaceCamera.target.y;
worldSpaceCamera.target.y = truncf(screenSpaceCamera.target.y);
screenSpaceCamera.target.y -= worldSpaceCamera.target.y;
screenSpaceCamera.target.y *= virtualRatio;
//----------------------------------------------------------------------------------

View File

@ -177,7 +177,7 @@ int LoadStorageValue(unsigned int position)
if (fileData != NULL)
{
if (dataSize < (position*4)) TraceLog(LOG_WARNING, "FILEIO: [%s] Failed to find storage position: %i", STORAGE_DATA_FILE, position);
if (dataSize < ((int)(position*4))) TraceLog(LOG_WARNING, "FILEIO: [%s] Failed to find storage position: %i", STORAGE_DATA_FILE, position);
else
{
int *dataPtr = (int *)fileData;

View File

@ -67,7 +67,7 @@ int main(void)
DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE);
// Draw cube with an applied texture, but only a defined rectangle piece of the texture
DrawCubeTextureRec(texture, (Rectangle){ 0, texture.height/2, texture.width/2, texture.height/2 },
DrawCubeTextureRec(texture, (Rectangle){ 0.0f, texture.height/2.0f, texture.width/2.0f, texture.height/2.0f },
(Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE);
DrawGrid(10, 1.0f); // Draw a grid

View File

@ -281,7 +281,7 @@ int main(void)
.id = gBuffer.positionTexture,
.width = screenWidth,
.height = screenHeight,
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE);
}, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, Vector2Zero(), RAYWHITE);
DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
} break;
@ -291,7 +291,7 @@ int main(void)
.id = gBuffer.normalTexture,
.width = screenWidth,
.height = screenHeight,
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE);
}, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, Vector2Zero(), RAYWHITE);
DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
} break;
@ -301,7 +301,7 @@ int main(void)
.id = gBuffer.albedoSpecTexture,
.width = screenWidth,
.height = screenHeight,
}, (Rectangle) { 0, 0, screenWidth, -screenHeight }, Vector2Zero(), RAYWHITE);
}, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, Vector2Zero(), RAYWHITE);
DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
} break;

View File

@ -69,8 +69,8 @@ int main(void)
DrawLineBezier(startPoint, endPoint, 4.0f, BLUE);
// Draw start-end spline circles with some details
DrawCircleV(startPoint, CheckCollisionPointCircle(mouse, startPoint, 10.0f)? 14 : 8, moveStartPoint? RED : BLUE);
DrawCircleV(endPoint, CheckCollisionPointCircle(mouse, endPoint, 10.0f)? 14 : 8, moveEndPoint? RED : BLUE);
DrawCircleV(startPoint, CheckCollisionPointCircle(mouse, startPoint, 10.0f)? 14.0f : 8.0f, moveStartPoint? RED : BLUE);
DrawCircleV(endPoint, CheckCollisionPointCircle(mouse, endPoint, 10.0f)? 14.0f : 8.0f, moveEndPoint? RED : BLUE);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -242,7 +242,7 @@ int main(void)
(splineTypeActive != SPLINE_BEZIER) &&
(i < pointCount - 1)) DrawLineV(points[i], points[i + 1], GRAY);
DrawText(TextFormat("[%.0f, %.0f]", points[i].x, points[i].y), points[i].x, points[i].y + 10, 10, BLACK);
DrawText(TextFormat("[%.0f, %.0f]", points[i].x, points[i].y), (int)points[i].x, (int)points[i].y + 10, 10, BLACK);
}
}

View File

@ -7351,7 +7351,7 @@
},
{
"name": "ImageKernelConvolution",
"description": "Apply Custom Square image convolution kernel",
"description": "Apply custom square convolution kernel to image",
"returnType": "void",
"params": [
{
@ -7359,7 +7359,7 @@
"name": "image"
},
{
"type": "float *",
"type": "const float *",
"name": "kernel"
},
{
@ -7817,6 +7817,33 @@
}
]
},
{
"name": "ImageDrawLineEx",
"description": "Draw a line defining thickness within an image",
"returnType": "void",
"params": [
{
"type": "Image *",
"name": "dst"
},
{
"type": "Vector2",
"name": "start"
},
{
"type": "Vector2",
"name": "end"
},
{
"type": "int",
"name": "thick"
},
{
"type": "Color",
"name": "color"
}
]
},
{
"name": "ImageDrawCircle",
"description": "Draw a filled circle within an image",

View File

@ -5617,11 +5617,11 @@ return {
},
{
name = "ImageKernelConvolution",
description = "Apply Custom Square image convolution kernel",
description = "Apply custom square convolution kernel to image",
returnType = "void",
params = {
{type = "Image *", name = "image"},
{type = "float *", name = "kernel"},
{type = "const float *", name = "kernel"},
{type = "int", name = "kernelSize"}
}
},
@ -5879,6 +5879,18 @@ return {
{type = "Color", name = "color"}
}
},
{
name = "ImageDrawLineEx",
description = "Draw a line defining thickness within an image",
returnType = "void",
params = {
{type = "Image *", name = "dst"},
{type = "Vector2", name = "start"},
{type = "Vector2", name = "end"},
{type = "int", name = "thick"},
{type = "Color", name = "color"}
}
},
{
name = "ImageDrawCircle",
description = "Draw a filled circle within an image",

File diff suppressed because it is too large Load Diff

View File

@ -670,7 +670,7 @@
<Param type="unsigned int" name="frames" desc="" />
</Callback>
</Callbacks>
<Functions count="571">
<Functions count="572">
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
<Param type="int" name="width" desc="" />
<Param type="int" name="height" desc="" />
@ -1842,9 +1842,9 @@
<Param type="Image *" name="image" desc="" />
<Param type="int" name="blurSize" desc="" />
</Function>
<Function name="ImageKernelConvolution" retType="void" paramCount="3" desc="Apply Custom Square image convolution kernel">
<Function name="ImageKernelConvolution" retType="void" paramCount="3" desc="Apply custom square convolution kernel to image">
<Param type="Image *" name="image" desc="" />
<Param type="float *" name="kernel" desc="" />
<Param type="const float *" name="kernel" desc="" />
<Param type="int" name="kernelSize" desc="" />
</Function>
<Function name="ImageResize" retType="void" paramCount="3" desc="Resize image (Bicubic scaling algorithm)">
@ -1966,6 +1966,13 @@
<Param type="Vector2" name="end" desc="" />
<Param type="Color" name="color" desc="" />
</Function>
<Function name="ImageDrawLineEx" retType="void" paramCount="5" desc="Draw a line defining thickness within an image">
<Param type="Image *" name="dst" desc="" />
<Param type="Vector2" name="start" desc="" />
<Param type="Vector2" name="end" desc="" />
<Param type="int" name="thick" desc="" />
<Param type="Color" name="color" desc="" />
</Function>
<Function name="ImageDrawCircle" retType="void" paramCount="5" desc="Draw a filled circle within an image">
<Param type="Image *" name="dst" desc="" />
<Param type="int" name="centerX" desc="" />

View File

@ -202,7 +202,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@ -219,7 +219,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
@ -237,7 +237,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@ -258,7 +258,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@ -281,7 +281,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
@ -303,7 +303,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
@ -325,7 +325,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
@ -353,7 +353,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>CompileAsC</CompileAs>
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>

View File

@ -34,8 +34,12 @@
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
<style>
body { margin: 0px; }
canvas.emscripten { border: 0px none; background-color: black; }
body {
margin: 0px;
overflow: hidden;
background-color: black;
}
canvas.emscripten { border: 0px none; background-color: black;}
</style>
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
<script type='text/javascript'>

View File

@ -1342,7 +1342,7 @@ RLAPI void ImageAlphaClear(Image *image, Color color, float threshold);
RLAPI void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel
RLAPI void ImageBlurGaussian(Image *image, int blurSize); // Apply Gaussian blur using a box blur approximation
RLAPI void ImageKernelConvolution(Image *image, float *kernel, int kernelSize); // Apply Custom Square image convolution kernel
RLAPI void ImageKernelConvolution(Image *image, const float *kernel, int kernelSize); // Apply custom square convolution kernel to image
RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm)
RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm)
RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color
@ -1373,6 +1373,7 @@ RLAPI void ImageDrawPixel(Image *dst, int posX, int posY, Color color);
RLAPI void ImageDrawPixelV(Image *dst, Vector2 position, Color color); // Draw pixel within an image (Vector version)
RLAPI void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw line within an image
RLAPI void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color); // Draw line within an image (Vector version)
RLAPI void ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, int thick, Color color); // Draw a line defining thickness within an image
RLAPI void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color); // Draw a filled circle within an image
RLAPI void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color); // Draw a filled circle within an image (Vector version)
RLAPI void ImageDrawCircleLines(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle outline within an image

View File

@ -856,7 +856,7 @@ void EndDrawing(void)
#ifndef GIF_RECORD_FRAMERATE
#define GIF_RECORD_FRAMERATE 10
#endif
gifFrameCounter += GetFrameTime()*1000;
gifFrameCounter += (unsigned int)(GetFrameTime()*1000);
// NOTE: We record one gif frame depending on the desired gif framerate
if (gifFrameCounter > 1000/GIF_RECORD_FRAMERATE)

View File

@ -1406,7 +1406,7 @@ void rlBegin(int mode)
}
}
void rlEnd() { glEnd(); }
void rlEnd(void) { glEnd(); }
void rlVertex2i(int x, int y) { glVertex2i(x, y); }
void rlVertex2f(float x, float y) { glVertex2f(x, y); }
void rlVertex3f(float x, float y, float z) { glVertex3f(x, y, z); }
@ -3945,7 +3945,9 @@ void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool norma
// Additional types (depends on OpenGL version or extensions):
// - GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_FIXED,
// - GL_INT_2_10_10_10_REV, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10F_11F_11F_REV
glVertexAttribPointer(index, compSize, type, normalized, stride, (void *)offset);
size_t offsetNative = offset;
glVertexAttribPointer(index, compSize, type, normalized, stride, (void *)offsetNative);
#endif
}

View File

@ -4871,7 +4871,11 @@ static BoneInfo *LoadBoneInfoGLTF(cgltf_skin skin, int *boneCount)
for (unsigned int i = 0; i < skin.joints_count; i++)
{
cgltf_node node = *skin.joints[i];
if (node.name != NULL) strncpy(bones[i].name, node.name, sizeof(bones[i].name));
if (node.name != NULL)
{
strncpy(bones[i].name, node.name, sizeof(bones[i].name));
bones[i].name[sizeof(bones[i].name) - 1] = '\0';
}
// Find parent bone index
unsigned int parentIndex = -1;

View File

@ -178,9 +178,8 @@ void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color colo
{
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
// WARNING: Adding 0.5f offset to "center" point on selected pixel
rlVertex2f((float)startPosX + 0.5f, (float)startPosY + 0.5f);
rlVertex2f((float)endPosX + 0.5f, (float)endPosY + 0.5f);
rlVertex2f((float)startPosX, (float)startPosY);
rlVertex2f((float)endPosX, (float)endPosY);
rlEnd();
}
@ -189,9 +188,8 @@ void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
{
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
// WARNING: Adding 0.5f offset to "center" point on selected pixel
rlVertex2f(startPos.x + 0.5f, startPos.y + 0.5f);
rlVertex2f(endPos.x + 0.5f, endPos.y + 0.5f);
rlVertex2f(startPos.x, startPos.y);
rlVertex2f(endPos.x, endPos.y);
rlEnd();
}

View File

@ -362,11 +362,7 @@ Font LoadFont(const char *fileName)
UnloadImage(image);
}
if (font.texture.id == 0)
{
TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load font texture -> Using default font", fileName);
font = GetFontDefault();
}
if (font.texture.id == 0) TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load font texture -> Using default font", fileName);
else
{
SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default, we set point filter (the best performance)
@ -394,7 +390,6 @@ Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepoi
UnloadFileData(fileData);
}
else font = GetFontDefault();
return font;
}
@ -2297,7 +2292,7 @@ static Font LoadBMFont(const char *fileName)
}
else
{
font.glyphs[i].image = GenImageColor(font.recs[i].width, font.recs[i].height, BLACK);
font.glyphs[i].image = GenImageColor((int)font.recs[i].width, (int)font.recs[i].height, BLACK);
TRACELOG(LOG_WARNING, "FONT: [%s] Some characters data not correctly provided", fileName);
}
}

View File

@ -2156,8 +2156,9 @@ void ImageBlurGaussian(Image *image, int blurSize)
ImageFormat(image, format);
}
// The kernel matrix is assumed to be square. Only supply the width of the kernel
void ImageKernelConvolution(Image *image, float* kernel, int kernelSize)
// Apply custom square convolution kernel to image
// NOTE: The convolution kernel matrix is expected to be square
void ImageKernelConvolution(Image *image, const float *kernel, int kernelSize)
{
if ((image->data == NULL) || (image->width == 0) || (image->height == 0) || kernel == NULL) return;
@ -3403,98 +3404,112 @@ void ImageDrawPixelV(Image *dst, Vector2 position, Color color)
// Draw line within an image
void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color)
{
// Using Bresenham's algorithm as described in
// Drawing Lines with Pixels - Joshua Scott - March 2012
// https://classic.csunplugged.org/wp-content/uploads/2014/12/Lines.pdf
// Calculate differences in coordinates
int shortLen = endPosY - startPosY;
int longLen = endPosX - startPosX;
bool yLonger = false;
int changeInX = (endPosX - startPosX);
int absChangeInX = (changeInX < 0)? -changeInX : changeInX;
int changeInY = (endPosY - startPosY);
int absChangeInY = (changeInY < 0)? -changeInY : changeInY;
int startU, startV, endU, stepV; // Substitutions, either U = X, V = Y or vice versa. See loop at end of function
//int endV; // Not needed but left for better understanding, check code below
int A, B, P; // See linked paper above, explained down in the main loop
int reversedXY = (absChangeInY < absChangeInX);
if (reversedXY)
// Determine if the line is more vertical than horizontal
if (abs(shortLen) > abs(longLen))
{
A = 2*absChangeInY;
B = A - 2*absChangeInX;
P = A - absChangeInX;
// Swap the lengths if the line is more vertical
int temp = shortLen;
shortLen = longLen;
longLen = temp;
yLonger = true;
}
if (changeInX > 0)
// Initialize variables for drawing loop
int endVal = longLen;
int sgnInc = 1;
// Adjust direction increment based on longLen sign
if (longLen < 0)
{
startU = startPosX;
startV = startPosY;
endU = endPosX;
//endV = endPosY;
longLen = -longLen;
sgnInc = -1;
}
// Calculate fixed-point increment for shorter length
int decInc = (longLen == 0)? 0 : (shortLen<<16) / longLen;
// Draw the line pixel by pixel
if (yLonger)
{
// If line is more vertical, iterate over y-axis
for (int i = 0, j = 0; i != endVal; i += sgnInc, j += decInc)
{
// Calculate pixel position and draw it
ImageDrawPixel(dst, startPosX + (j>>16), startPosY + i, color);
}
}
else
{
startU = endPosX;
startV = endPosY;
endU = startPosX;
//endV = startPosY;
// Since start and end are reversed
changeInX = -changeInX;
changeInY = -changeInY;
}
stepV = (changeInY < 0)? -1 : 1;
ImageDrawPixel(dst, startU, startV, color); // At this point they are correctly ordered...
}
else
// If line is more horizontal, iterate over x-axis
for (int i = 0, j = 0; i != endVal; i += sgnInc, j += decInc)
{
A = 2*absChangeInX;
B = A - 2*absChangeInY;
P = A - absChangeInY;
if (changeInY > 0)
{
startU = startPosY;
startV = startPosX;
endU = endPosY;
//endV = endPosX;
// Calculate pixel position and draw it
ImageDrawPixel(dst, startPosX + i, startPosY + (j>>16), color);
}
else
{
startU = endPosY;
startV = endPosX;
endU = startPosY;
//endV = startPosX;
// Since start and end are reversed
changeInX = -changeInX;
changeInY = -changeInY;
}
stepV = (changeInX < 0)? -1 : 1;
ImageDrawPixel(dst, startV, startU, color); // ... but need to be reversed here. Repeated in the main loop below
}
// We already drew the start point. If we started at startU + 0, the line would be crooked and too short
for (int u = startU + 1, v = startV; u <= endU; u++)
{
if (P >= 0)
{
v += stepV; // Adjusts whenever we stray too far from the direct line. Details in the linked paper above
P += B; // Remembers that we corrected our path
}
else P += A; // Remembers how far we are from the direct line
if (reversedXY) ImageDrawPixel(dst, u, v, color);
else ImageDrawPixel(dst, v, u, color);
}
}
// Draw line within an image (Vector version)
void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color)
{
ImageDrawLine(dst, (int)start.x, (int)start.y, (int)end.x, (int)end.y, color);
// Round start and end positions to nearest integer coordinates
int x1 = (int)(start.x + 0.5f);
int y1 = (int)(start.y + 0.5f);
int x2 = (int)(end.x + 0.5f);
int y2 = (int)(end.y + 0.5f);
// Draw a vertical line using ImageDrawLine function
ImageDrawLine(dst, x1, y1, x2, y2, color);
}
// Draw a line defining thickness within an image
void ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, int thick, Color color)
{
// Round start and end positions to nearest integer coordinates
int x1 = (int)(start.x + 0.5f);
int y1 = (int)(start.y + 0.5f);
int x2 = (int)(end.x + 0.5f);
int y2 = (int)(end.y + 0.5f);
// Calculate differences in x and y coordinates
int dx = x2 - x1;
int dy = y2 - y1;
// Draw the main line between (x1, y1) and (x2, y2)
ImageDrawLine(dst, x1, y1, x2, y2, color);
// Determine if the line is more horizontal or vertical
if (dx != 0 && abs(dy/dx) < 1)
{
// Line is more horizontal
// Calculate half the width of the line
int wy = (thick - 1)*sqrtf(dx*dx + dy*dy)/(2*abs(dx));
// Draw additional lines above and below the main line
for (int i = 1; i <= wy; i++)
{
ImageDrawLine(dst, x1, y1 - i, x2, y2 - i, color); // Draw above the main line
ImageDrawLine(dst, x1, y1 + i, x2, y2 + i, color); // Draw below the main line
}
}
else if (dy != 0)
{
// Line is more vertical or perfectly horizontal
// Calculate half the width of the line
int wx = (thick - 1)*sqrtf(dx*dx + dy*dy)/(2*abs(dy));
// Draw additional lines to the left and right of the main line
for (int i = 1; i <= wx; i++)
{
ImageDrawLine(dst, x1 - i, y1, x2 - i, y2, color); // Draw left of the main line
ImageDrawLine(dst, x1 + i, y1, x2 + i, y2, color); // Draw right of the main line
}
}
}
// Draw circle within an image
@ -3632,10 +3647,10 @@ void ImageDrawTriangle(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color col
{
// Calculate the 2D bounding box of the triangle
// Determine the minimum and maximum x and y coordinates of the triangle vertices
int xMin = (v1.x < v2.x)? ((v1.x < v3.x)? v1.x : v3.x) : ((v2.x < v3.x)? v2.x : v3.x);
int yMin = (v1.y < v2.y)? ((v1.y < v3.y)? v1.y : v3.y) : ((v2.y < v3.y)? v2.y : v3.y);
int xMax = (v1.x > v2.x)? ((v1.x > v3.x)? v1.x : v3.x) : ((v2.x > v3.x)? v2.x : v3.x);
int yMax = (v1.y > v2.y)? ((v1.y > v3.y)? v1.y : v3.y) : ((v2.y > v3.y)? v2.y : v3.y);
int xMin = (int)((v1.x < v2.x)? ((v1.x < v3.x) ? v1.x : v3.x) : ((v2.x < v3.x) ? v2.x : v3.x));
int yMin = (int)((v1.y < v2.y)? ((v1.y < v3.y) ? v1.y : v3.y) : ((v2.y < v3.y) ? v2.y : v3.y));
int xMax = (int)((v1.x > v2.x)? ((v1.x > v3.x) ? v1.x : v3.x) : ((v2.x > v3.x) ? v2.x : v3.x));
int yMax = (int)((v1.y > v2.y)? ((v1.y > v3.y) ? v1.y : v3.y) : ((v2.y > v3.y) ? v2.y : v3.y));
// Clamp the bounding box to the image dimensions
if (xMin < 0) xMin = 0;
@ -3650,9 +3665,9 @@ void ImageDrawTriangle(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color col
// Barycentric interpolation setup
// Calculate the step increments for the barycentric coordinates
int w1XStep = v3.y - v2.y, w1YStep = v2.x - v3.x;
int w2XStep = v1.y - v3.y, w2YStep = v3.x - v1.x;
int w3XStep = v2.y - v1.y, w3YStep = v1.x - v2.x;
int w1XStep = (int)(v3.y - v2.y), w1YStep = (int)(v2.x - v3.x);
int w2XStep = (int)(v1.y - v3.y), w2YStep = (int)(v3.x - v1.x);
int w3XStep = (int)(v2.y - v1.y), w3YStep = (int)(v1.x - v2.x);
// If the triangle is a back face, invert the steps
if (isBackFace)
@ -3663,9 +3678,9 @@ void ImageDrawTriangle(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color col
}
// Calculate the initial barycentric coordinates for the top-left point of the bounding box
int w1Row = (xMin - v2.x)*w1XStep + w1YStep*(yMin - v2.y);
int w2Row = (xMin - v3.x)*w2XStep + w2YStep*(yMin - v3.y);
int w3Row = (xMin - v1.x)*w3XStep + w3YStep*(yMin - v1.y);
int w1Row = (int)((xMin - v2.x)*w1XStep + w1YStep*(yMin - v2.y));
int w2Row = (int)((xMin - v3.x)*w2XStep + w2YStep*(yMin - v3.y));
int w3Row = (int)((xMin - v1.x)*w3XStep + w3YStep*(yMin - v1.y));
// Rasterization loop
// Iterate through each pixel in the bounding box
@ -3699,10 +3714,10 @@ void ImageDrawTriangleEx(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c
{
// Calculate the 2D bounding box of the triangle
// Determine the minimum and maximum x and y coordinates of the triangle vertices
int xMin = (v1.x < v2.x)? ((v1.x < v3.x)? v1.x : v3.x) : ((v2.x < v3.x)? v2.x : v3.x);
int yMin = (v1.y < v2.y)? ((v1.y < v3.y)? v1.y : v3.y) : ((v2.y < v3.y)? v2.y : v3.y);
int xMax = (v1.x > v2.x)? ((v1.x > v3.x)? v1.x : v3.x) : ((v2.x > v3.x)? v2.x : v3.x);
int yMax = (v1.y > v2.y)? ((v1.y > v3.y)? v1.y : v3.y) : ((v2.y > v3.y)? v2.y : v3.y);
int xMin = (int)((v1.x < v2.x)? ((v1.x < v3.x)? v1.x : v3.x) : ((v2.x < v3.x)? v2.x : v3.x));
int yMin = (int)((v1.y < v2.y)? ((v1.y < v3.y)? v1.y : v3.y) : ((v2.y < v3.y)? v2.y : v3.y));
int xMax = (int)((v1.x > v2.x)? ((v1.x > v3.x)? v1.x : v3.x) : ((v2.x > v3.x)? v2.x : v3.x));
int yMax = (int)((v1.y > v2.y)? ((v1.y > v3.y)? v1.y : v3.y) : ((v2.y > v3.y)? v2.y : v3.y));
// Clamp the bounding box to the image dimensions
if (xMin < 0) xMin = 0;
@ -3717,9 +3732,9 @@ void ImageDrawTriangleEx(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c
// Barycentric interpolation setup
// Calculate the step increments for the barycentric coordinates
int w1XStep = v3.y - v2.y, w1YStep = v2.x - v3.x;
int w2XStep = v1.y - v3.y, w2YStep = v3.x - v1.x;
int w3XStep = v2.y - v1.y, w3YStep = v1.x - v2.x;
int w1XStep = (int)(v3.y - v2.y), w1YStep = (int)(v2.x - v3.x);
int w2XStep = (int)(v1.y - v3.y), w2YStep = (int)(v3.x - v1.x);
int w3XStep = (int)(v2.y - v1.y), w3YStep = (int)(v1.x - v2.x);
// If the triangle is a back face, invert the steps
if (isBackFace)
@ -3730,9 +3745,9 @@ void ImageDrawTriangleEx(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c
}
// Calculate the initial barycentric coordinates for the top-left point of the bounding box
int w1Row = (xMin - v2.x)*w1XStep + w1YStep*(yMin - v2.y);
int w2Row = (xMin - v3.x)*w2XStep + w2YStep*(yMin - v3.y);
int w3Row = (xMin - v1.x)*w3XStep + w3YStep*(yMin - v1.y);
int w1Row = (int)((xMin - v2.x)*w1XStep + w1YStep*(yMin - v2.y));
int w2Row = (int)((xMin - v3.x)*w2XStep + w2YStep*(yMin - v3.y));
int w3Row = (int)((xMin - v1.x)*w3XStep + w3YStep*(yMin - v1.y));
// Calculate the inverse of the sum of the barycentric coordinates for normalization
// NOTE 1: Here, we act as if we multiply by 255 the reciprocal, which avoids additional
@ -3785,9 +3800,9 @@ void ImageDrawTriangleEx(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c
// Draw triangle outline within an image
void ImageDrawTriangleLines(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color)
{
ImageDrawLine(dst, v1.x, v1.y, v2.x, v2.y, color);
ImageDrawLine(dst, v2.x, v2.y, v3.x, v3.y, color);
ImageDrawLine(dst, v3.x, v3.y, v1.x, v1.y, color);
ImageDrawLine(dst, (int)v1.x, (int)v1.y, (int)v2.x, (int)v2.y, color);
ImageDrawLine(dst, (int)v2.x, (int)v2.y, (int)v3.x, (int)v3.y, color);
ImageDrawLine(dst, (int)v3.x, (int)v3.y, (int)v1.x, (int)v1.y, color);
}
// Draw a triangle fan defined by points within an image (first vertex is the center)

View File

@ -141,6 +141,11 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB
}
#output {
border-left: 0px none;
border-right: 0px none;
border-bottom: 0px none;
padding-left: 0;
padding-right: 0;
width: 100%;
height: 140px;
margin: 0 auto;