Merge branch 'master' of github.com:raysan5/raylib
This commit is contained in:
commit
606051950a
|
|
@ -97,7 +97,7 @@ int main(void)
|
||||||
DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
|
DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
|
||||||
for (int i = 0; i < 400; i++)
|
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);
|
DrawRectangleLines(199, 199, 402, 34, GRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,10 +133,10 @@ int main(void)
|
||||||
|
|
||||||
for (int i = 0; i < envItemsLength; i++) DrawRectangleRec(envItems[i].rect, envItems[i].color);
|
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);
|
DrawRectangleRec(playerRect, RED);
|
||||||
|
|
||||||
DrawCircle(player.position.x, player.position.y, 5, GOLD);
|
DrawCircleV(player.position, 5.0f, GOLD);
|
||||||
|
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
boxPositionY -= (GetMouseWheelMove()*scrollSpeed);
|
boxPositionY -= (int)(GetMouseWheelMove()*scrollSpeed);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ int main(void) {
|
||||||
|
|
||||||
int rectCount = 20;
|
int rectCount = 20;
|
||||||
float rectSize = (float)screenWidth/rectCount;
|
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);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -62,7 +62,7 @@ int main(void) {
|
||||||
rectCount++;
|
rectCount++;
|
||||||
rectSize = (float)screenWidth/rectCount;
|
rectSize = (float)screenWidth/rectCount;
|
||||||
free(rectangles);
|
free(rectangles);
|
||||||
rectangles = GenerateRandomColorRectSequence(rectCount, rectSize, screenWidth, 0.75f * screenHeight);
|
rectangles = GenerateRandomColorRectSequence((float)rectCount, rectSize, (float)screenWidth, 0.75f * screenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IsKeyPressed(KEY_DOWN))
|
if(IsKeyPressed(KEY_DOWN))
|
||||||
|
|
@ -71,7 +71,7 @@ int main(void) {
|
||||||
rectCount--;
|
rectCount--;
|
||||||
rectSize = (float)screenWidth/rectCount;
|
rectSize = (float)screenWidth/rectCount;
|
||||||
free(rectangles);
|
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){
|
static ColorRect* GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight){
|
||||||
int *seq = LoadRandomSequence(rectCount, 0, rectCount-1);
|
int *seq = LoadRandomSequence((unsigned int)rectCount, 0, (unsigned int)rectCount-1);
|
||||||
ColorRect* rectangles = (ColorRect *)malloc(rectCount*sizeof(ColorRect));
|
ColorRect* rectangles = (ColorRect *)malloc((int)rectCount*sizeof(ColorRect));
|
||||||
|
|
||||||
float rectSeqWidth = rectCount * rectWidth;
|
float rectSeqWidth = rectCount * rectWidth;
|
||||||
int startX = (screenWidth - rectSeqWidth) * 0.5f;
|
float startX = (screenWidth - rectSeqWidth) * 0.5f;
|
||||||
|
|
||||||
for(int x=0;x<rectCount;x++){
|
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].c = GenerateRandomColor();
|
||||||
rectangles[x].r = CLITERAL(Rectangle){
|
rectangles[x].r = CLITERAL(Rectangle){
|
||||||
startX + x * rectWidth, screenHeight - rectHeight, rectWidth, rectHeight
|
startX + x * rectWidth, screenHeight - rectHeight, rectWidth, (float)rectHeight
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
UnloadRandomSequence(seq);
|
UnloadRandomSequence(seq);
|
||||||
|
|
|
||||||
|
|
@ -69,18 +69,18 @@ int main(void)
|
||||||
rotation += 60.0f*GetFrameTime(); // Rotate the rectangles, 60 degrees per second
|
rotation += 60.0f*GetFrameTime(); // Rotate the rectangles, 60 degrees per second
|
||||||
|
|
||||||
// Make the camera move to demonstrate the effect
|
// Make the camera move to demonstrate the effect
|
||||||
cameraX = (sinf(GetTime())*50.0f) - 10.0f;
|
cameraX = (sinf((float)GetTime())*50.0f) - 10.0f;
|
||||||
cameraY = cosf(GetTime())*30.0f;
|
cameraY = cosf((float)GetTime())*30.0f;
|
||||||
|
|
||||||
// Set the camera's target to the values computed above
|
// Set the camera's target to the values computed above
|
||||||
screenSpaceCamera.target = (Vector2){ cameraX, cameraY };
|
screenSpaceCamera.target = (Vector2){ cameraX, cameraY };
|
||||||
|
|
||||||
// Round worldSpace coordinates, keep decimals into screenSpace coordinates
|
// 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 -= worldSpaceCamera.target.x;
|
||||||
screenSpaceCamera.target.x *= virtualRatio;
|
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 -= worldSpaceCamera.target.y;
|
||||||
screenSpaceCamera.target.y *= virtualRatio;
|
screenSpaceCamera.target.y *= virtualRatio;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ int LoadStorageValue(unsigned int position)
|
||||||
|
|
||||||
if (fileData != NULL)
|
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
|
else
|
||||||
{
|
{
|
||||||
int *dataPtr = (int *)fileData;
|
int *dataPtr = (int *)fileData;
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ int main(void)
|
||||||
DrawCubeTexture(texture, (Vector3){ -2.0f, 2.0f, 0.0f }, 2.0f, 4.0f, 2.0f, WHITE);
|
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
|
// 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);
|
(Vector3){ 2.0f, 1.0f, 0.0f }, 2.0f, 2.0f, 2.0f, WHITE);
|
||||||
|
|
||||||
DrawGrid(10, 1.0f); // Draw a grid
|
DrawGrid(10, 1.0f); // Draw a grid
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ int main(void)
|
||||||
.id = gBuffer.positionTexture,
|
.id = gBuffer.positionTexture,
|
||||||
.width = screenWidth,
|
.width = screenWidth,
|
||||||
.height = screenHeight,
|
.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);
|
DrawText("POSITION TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -291,7 +291,7 @@ int main(void)
|
||||||
.id = gBuffer.normalTexture,
|
.id = gBuffer.normalTexture,
|
||||||
.width = screenWidth,
|
.width = screenWidth,
|
||||||
.height = screenHeight,
|
.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);
|
DrawText("NORMAL TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
|
||||||
} break;
|
} break;
|
||||||
|
|
@ -301,7 +301,7 @@ int main(void)
|
||||||
.id = gBuffer.albedoSpecTexture,
|
.id = gBuffer.albedoSpecTexture,
|
||||||
.width = screenWidth,
|
.width = screenWidth,
|
||||||
.height = screenHeight,
|
.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);
|
DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
|
||||||
} break;
|
} break;
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,8 @@ int main(void)
|
||||||
DrawLineBezier(startPoint, endPoint, 4.0f, BLUE);
|
DrawLineBezier(startPoint, endPoint, 4.0f, BLUE);
|
||||||
|
|
||||||
// Draw start-end spline circles with some details
|
// Draw start-end spline circles with some details
|
||||||
DrawCircleV(startPoint, CheckCollisionPointCircle(mouse, startPoint, 10.0f)? 14 : 8, moveStartPoint? RED : BLUE);
|
DrawCircleV(startPoint, CheckCollisionPointCircle(mouse, startPoint, 10.0f)? 14.0f : 8.0f, moveStartPoint? RED : BLUE);
|
||||||
DrawCircleV(endPoint, CheckCollisionPointCircle(mouse, endPoint, 10.0f)? 14 : 8, moveEndPoint? RED : BLUE);
|
DrawCircleV(endPoint, CheckCollisionPointCircle(mouse, endPoint, 10.0f)? 14.0f : 8.0f, moveEndPoint? RED : BLUE);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ int main(void)
|
||||||
(splineTypeActive != SPLINE_BEZIER) &&
|
(splineTypeActive != SPLINE_BEZIER) &&
|
||||||
(i < pointCount - 1)) DrawLineV(points[i], points[i + 1], GRAY);
|
(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7351,7 +7351,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ImageKernelConvolution",
|
"name": "ImageKernelConvolution",
|
||||||
"description": "Apply Custom Square image convolution kernel",
|
"description": "Apply custom square convolution kernel to image",
|
||||||
"returnType": "void",
|
"returnType": "void",
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
|
|
@ -7359,7 +7359,7 @@
|
||||||
"name": "image"
|
"name": "image"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "float *",
|
"type": "const float *",
|
||||||
"name": "kernel"
|
"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",
|
"name": "ImageDrawCircle",
|
||||||
"description": "Draw a filled circle within an image",
|
"description": "Draw a filled circle within an image",
|
||||||
|
|
|
||||||
|
|
@ -5617,11 +5617,11 @@ return {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "ImageKernelConvolution",
|
name = "ImageKernelConvolution",
|
||||||
description = "Apply Custom Square image convolution kernel",
|
description = "Apply custom square convolution kernel to image",
|
||||||
returnType = "void",
|
returnType = "void",
|
||||||
params = {
|
params = {
|
||||||
{type = "Image *", name = "image"},
|
{type = "Image *", name = "image"},
|
||||||
{type = "float *", name = "kernel"},
|
{type = "const float *", name = "kernel"},
|
||||||
{type = "int", name = "kernelSize"}
|
{type = "int", name = "kernelSize"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -5879,6 +5879,18 @@ return {
|
||||||
{type = "Color", name = "color"}
|
{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",
|
name = "ImageDrawCircle",
|
||||||
description = "Draw a filled circle within an image",
|
description = "Draw a filled circle within an image",
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -670,7 +670,7 @@
|
||||||
<Param type="unsigned int" name="frames" desc="" />
|
<Param type="unsigned int" name="frames" desc="" />
|
||||||
</Callback>
|
</Callback>
|
||||||
</Callbacks>
|
</Callbacks>
|
||||||
<Functions count="571">
|
<Functions count="572">
|
||||||
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
||||||
<Param type="int" name="width" desc="" />
|
<Param type="int" name="width" desc="" />
|
||||||
<Param type="int" name="height" desc="" />
|
<Param type="int" name="height" desc="" />
|
||||||
|
|
@ -1842,9 +1842,9 @@
|
||||||
<Param type="Image *" name="image" desc="" />
|
<Param type="Image *" name="image" desc="" />
|
||||||
<Param type="int" name="blurSize" desc="" />
|
<Param type="int" name="blurSize" desc="" />
|
||||||
</Function>
|
</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="Image *" name="image" desc="" />
|
||||||
<Param type="float *" name="kernel" desc="" />
|
<Param type="const float *" name="kernel" desc="" />
|
||||||
<Param type="int" name="kernelSize" desc="" />
|
<Param type="int" name="kernelSize" desc="" />
|
||||||
</Function>
|
</Function>
|
||||||
<Function name="ImageResize" retType="void" paramCount="3" desc="Resize image (Bicubic scaling algorithm)">
|
<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="Vector2" name="end" desc="" />
|
||||||
<Param type="Color" name="color" desc="" />
|
<Param type="Color" name="color" desc="" />
|
||||||
</Function>
|
</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">
|
<Function name="ImageDrawCircle" retType="void" paramCount="5" desc="Draw a filled circle within an image">
|
||||||
<Param type="Image *" name="dst" desc="" />
|
<Param type="Image *" name="dst" desc="" />
|
||||||
<Param type="int" name="centerX" desc="" />
|
<Param type="int" name="centerX" desc="" />
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<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>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -219,7 +219,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<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>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/FS %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
|
@ -237,7 +237,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<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>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -258,7 +258,7 @@
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<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>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -281,7 +281,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<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>
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||||
|
|
@ -303,7 +303,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<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>
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||||
|
|
@ -325,7 +325,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<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>
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||||
|
|
@ -353,7 +353,7 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<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>
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,12 @@
|
||||||
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
|
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body { margin: 0px; }
|
body {
|
||||||
canvas.emscripten { border: 0px none; background-color: black; }
|
margin: 0px;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
canvas.emscripten { border: 0px none; background-color: black;}
|
||||||
</style>
|
</style>
|
||||||
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
|
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
|
|
|
||||||
|
|
@ -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 ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image
|
||||||
RLAPI void ImageAlphaPremultiply(Image *image); // Premultiply alpha channel
|
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 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 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 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
|
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 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 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 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 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 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
|
RLAPI void ImageDrawCircleLines(Image *dst, int centerX, int centerY, int radius, Color color); // Draw circle outline within an image
|
||||||
|
|
|
||||||
|
|
@ -856,7 +856,7 @@ void EndDrawing(void)
|
||||||
#ifndef GIF_RECORD_FRAMERATE
|
#ifndef GIF_RECORD_FRAMERATE
|
||||||
#define GIF_RECORD_FRAMERATE 10
|
#define GIF_RECORD_FRAMERATE 10
|
||||||
#endif
|
#endif
|
||||||
gifFrameCounter += GetFrameTime()*1000;
|
gifFrameCounter += (unsigned int)(GetFrameTime()*1000);
|
||||||
|
|
||||||
// NOTE: We record one gif frame depending on the desired gif framerate
|
// NOTE: We record one gif frame depending on the desired gif framerate
|
||||||
if (gifFrameCounter > 1000/GIF_RECORD_FRAMERATE)
|
if (gifFrameCounter > 1000/GIF_RECORD_FRAMERATE)
|
||||||
|
|
|
||||||
|
|
@ -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 rlVertex2i(int x, int y) { glVertex2i(x, y); }
|
||||||
void rlVertex2f(float x, float y) { glVertex2f(x, y); }
|
void rlVertex2f(float x, float y) { glVertex2f(x, y); }
|
||||||
void rlVertex3f(float x, float y, float z) { glVertex3f(x, y, z); }
|
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):
|
// Additional types (depends on OpenGL version or extensions):
|
||||||
// - GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_FIXED,
|
// - 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
|
// - 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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4871,7 +4871,11 @@ static BoneInfo *LoadBoneInfoGLTF(cgltf_skin skin, int *boneCount)
|
||||||
for (unsigned int i = 0; i < skin.joints_count; i++)
|
for (unsigned int i = 0; i < skin.joints_count; i++)
|
||||||
{
|
{
|
||||||
cgltf_node node = *skin.joints[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
|
// Find parent bone index
|
||||||
unsigned int parentIndex = -1;
|
unsigned int parentIndex = -1;
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ Rectangle GetShapesTextureRectangle(void)
|
||||||
// Draw a pixel
|
// Draw a pixel
|
||||||
void DrawPixel(int posX, int posY, Color color)
|
void DrawPixel(int posX, int posY, Color color)
|
||||||
{
|
{
|
||||||
DrawPixelV((Vector2){ (float)posX, (float)posY }, color);
|
DrawPixelV((Vector2){ (float)posX, (float)posY }, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a pixel (Vector version)
|
// Draw a pixel (Vector version)
|
||||||
|
|
@ -178,9 +178,8 @@ void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color colo
|
||||||
{
|
{
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
// WARNING: Adding 0.5f offset to "center" point on selected pixel
|
rlVertex2f((float)startPosX, (float)startPosY);
|
||||||
rlVertex2f((float)startPosX + 0.5f, (float)startPosY + 0.5f);
|
rlVertex2f((float)endPosX, (float)endPosY);
|
||||||
rlVertex2f((float)endPosX + 0.5f, (float)endPosY + 0.5f);
|
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,9 +188,8 @@ void DrawLineV(Vector2 startPos, Vector2 endPos, Color color)
|
||||||
{
|
{
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
// WARNING: Adding 0.5f offset to "center" point on selected pixel
|
rlVertex2f(startPos.x, startPos.y);
|
||||||
rlVertex2f(startPos.x + 0.5f, startPos.y + 0.5f);
|
rlVertex2f(endPos.x, endPos.y);
|
||||||
rlVertex2f(endPos.x + 0.5f, endPos.y + 0.5f);
|
|
||||||
rlEnd();
|
rlEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -362,11 +362,7 @@ Font LoadFont(const char *fileName)
|
||||||
UnloadImage(image);
|
UnloadImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font.texture.id == 0)
|
if (font.texture.id == 0) TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load font texture -> Using default font", fileName);
|
||||||
{
|
|
||||||
TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load font texture -> Using default font", fileName);
|
|
||||||
font = GetFontDefault();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetTextureFilter(font.texture, TEXTURE_FILTER_POINT); // By default, we set point filter (the best performance)
|
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);
|
UnloadFileData(fileData);
|
||||||
}
|
}
|
||||||
else font = GetFontDefault();
|
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
@ -2297,7 +2292,7 @@ static Font LoadBMFont(const char *fileName)
|
||||||
}
|
}
|
||||||
else
|
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);
|
TRACELOG(LOG_WARNING, "FONT: [%s] Some characters data not correctly provided", fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
217
src/rtextures.c
217
src/rtextures.c
|
|
@ -2156,8 +2156,9 @@ void ImageBlurGaussian(Image *image, int blurSize)
|
||||||
ImageFormat(image, format);
|
ImageFormat(image, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The kernel matrix is assumed to be square. Only supply the width of the kernel
|
// Apply custom square convolution kernel to image
|
||||||
void ImageKernelConvolution(Image *image, float* kernel, int kernelSize)
|
// 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;
|
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
|
// Draw line within an image
|
||||||
void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color)
|
void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color)
|
||||||
{
|
{
|
||||||
// Using Bresenham's algorithm as described in
|
// Calculate differences in coordinates
|
||||||
// Drawing Lines with Pixels - Joshua Scott - March 2012
|
int shortLen = endPosY - startPosY;
|
||||||
// https://classic.csunplugged.org/wp-content/uploads/2014/12/Lines.pdf
|
int longLen = endPosX - startPosX;
|
||||||
|
bool yLonger = false;
|
||||||
|
|
||||||
int changeInX = (endPosX - startPosX);
|
// Determine if the line is more vertical than horizontal
|
||||||
int absChangeInX = (changeInX < 0)? -changeInX : changeInX;
|
if (abs(shortLen) > abs(longLen))
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
A = 2*absChangeInY;
|
// Swap the lengths if the line is more vertical
|
||||||
B = A - 2*absChangeInX;
|
int temp = shortLen;
|
||||||
P = A - absChangeInX;
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
startU = startPosX;
|
// Calculate pixel position and draw it
|
||||||
startV = startPosY;
|
ImageDrawPixel(dst, startPosX + (j>>16), startPosY + i, color);
|
||||||
endU = endPosX;
|
|
||||||
//endV = endPosY;
|
|
||||||
}
|
}
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
A = 2*absChangeInX;
|
// If line is more horizontal, iterate over x-axis
|
||||||
B = A - 2*absChangeInY;
|
for (int i = 0, j = 0; i != endVal; i += sgnInc, j += decInc)
|
||||||
P = A - absChangeInY;
|
|
||||||
|
|
||||||
if (changeInY > 0)
|
|
||||||
{
|
{
|
||||||
startU = startPosY;
|
// Calculate pixel position and draw it
|
||||||
startV = startPosX;
|
ImageDrawPixel(dst, startPosX + i, startPosY + (j>>16), color);
|
||||||
endU = endPosY;
|
|
||||||
//endV = endPosX;
|
|
||||||
}
|
}
|
||||||
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)
|
// Draw line within an image (Vector version)
|
||||||
void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color)
|
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
|
// 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
|
// Calculate the 2D bounding box of the triangle
|
||||||
// Determine the minimum and maximum x and y coordinates of the triangle vertices
|
// 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 xMin = (int)((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 yMin = (int)((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 xMax = (int)((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 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
|
// Clamp the bounding box to the image dimensions
|
||||||
if (xMin < 0) xMin = 0;
|
if (xMin < 0) xMin = 0;
|
||||||
|
|
@ -3650,9 +3665,9 @@ void ImageDrawTriangle(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color col
|
||||||
|
|
||||||
// Barycentric interpolation setup
|
// Barycentric interpolation setup
|
||||||
// Calculate the step increments for the barycentric coordinates
|
// Calculate the step increments for the barycentric coordinates
|
||||||
int w1XStep = v3.y - v2.y, w1YStep = v2.x - v3.x;
|
int w1XStep = (int)(v3.y - v2.y), w1YStep = (int)(v2.x - v3.x);
|
||||||
int w2XStep = v1.y - v3.y, w2YStep = v3.x - v1.x;
|
int w2XStep = (int)(v1.y - v3.y), w2YStep = (int)(v3.x - v1.x);
|
||||||
int w3XStep = v2.y - v1.y, w3YStep = v1.x - v2.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 the triangle is a back face, invert the steps
|
||||||
if (isBackFace)
|
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
|
// 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 w1Row = (int)((xMin - v2.x)*w1XStep + w1YStep*(yMin - v2.y));
|
||||||
int w2Row = (xMin - v3.x)*w2XStep + w2YStep*(yMin - v3.y);
|
int w2Row = (int)((xMin - v3.x)*w2XStep + w2YStep*(yMin - v3.y));
|
||||||
int w3Row = (xMin - v1.x)*w3XStep + w3YStep*(yMin - v1.y);
|
int w3Row = (int)((xMin - v1.x)*w3XStep + w3YStep*(yMin - v1.y));
|
||||||
|
|
||||||
// Rasterization loop
|
// Rasterization loop
|
||||||
// Iterate through each pixel in the bounding box
|
// 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
|
// Calculate the 2D bounding box of the triangle
|
||||||
// Determine the minimum and maximum x and y coordinates of the triangle vertices
|
// 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 xMin = (int)((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 yMin = (int)((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 xMax = (int)((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 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
|
// Clamp the bounding box to the image dimensions
|
||||||
if (xMin < 0) xMin = 0;
|
if (xMin < 0) xMin = 0;
|
||||||
|
|
@ -3717,9 +3732,9 @@ void ImageDrawTriangleEx(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c
|
||||||
|
|
||||||
// Barycentric interpolation setup
|
// Barycentric interpolation setup
|
||||||
// Calculate the step increments for the barycentric coordinates
|
// Calculate the step increments for the barycentric coordinates
|
||||||
int w1XStep = v3.y - v2.y, w1YStep = v2.x - v3.x;
|
int w1XStep = (int)(v3.y - v2.y), w1YStep = (int)(v2.x - v3.x);
|
||||||
int w2XStep = v1.y - v3.y, w2YStep = v3.x - v1.x;
|
int w2XStep = (int)(v1.y - v3.y), w2YStep = (int)(v3.x - v1.x);
|
||||||
int w3XStep = v2.y - v1.y, w3YStep = v1.x - v2.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 the triangle is a back face, invert the steps
|
||||||
if (isBackFace)
|
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
|
// 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 w1Row = (int)((xMin - v2.x)*w1XStep + w1YStep*(yMin - v2.y));
|
||||||
int w2Row = (xMin - v3.x)*w2XStep + w2YStep*(yMin - v3.y);
|
int w2Row = (int)((xMin - v3.x)*w2XStep + w2YStep*(yMin - v3.y));
|
||||||
int w3Row = (xMin - v1.x)*w3XStep + w3YStep*(yMin - v1.y);
|
int w3Row = (int)((xMin - v1.x)*w3XStep + w3YStep*(yMin - v1.y));
|
||||||
|
|
||||||
// Calculate the inverse of the sum of the barycentric coordinates for normalization
|
// 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
|
// 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
|
// Draw triangle outline within an image
|
||||||
void ImageDrawTriangleLines(Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color)
|
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, (int)v1.x, (int)v1.y, (int)v2.x, (int)v2.y, color);
|
||||||
ImageDrawLine(dst, v2.x, v2.y, v3.x, v3.y, color);
|
ImageDrawLine(dst, (int)v2.x, (int)v2.y, (int)v3.x, (int)v3.y, color);
|
||||||
ImageDrawLine(dst, v3.x, v3.y, v1.x, v1.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)
|
// Draw a triangle fan defined by points within an image (first vertex is the center)
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,11 @@ jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaB
|
||||||
}
|
}
|
||||||
|
|
||||||
#output {
|
#output {
|
||||||
|
border-left: 0px none;
|
||||||
|
border-right: 0px none;
|
||||||
|
border-bottom: 0px none;
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 140px;
|
height: 140px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user