mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-20 05:15:37 +00:00
REVIEWED: Make sure all variables are initialized on definition, prioritize one line per variable definitions
This commit is contained in:
8
src/external/rlsw.h
vendored
8
src/external/rlsw.h
vendored
@@ -2217,7 +2217,7 @@ static inline bool sw_triangle_face_culling(void)
|
||||
const float *h2 = RLSW.vertexBuffer[2].homogeneous;
|
||||
|
||||
// Compute a value proportional to the signed area in the projected 2D plane,
|
||||
// calculated directly using homogeneous coordinates BEFORE division by w.
|
||||
// calculated directly using homogeneous coordinates BEFORE division by w
|
||||
// This is the determinant of the matrix formed by the (x, y, w) components
|
||||
// of the vertices, which correctly captures the winding order in homogeneous
|
||||
// space and its relationship to the projected 2D winding order, even with
|
||||
@@ -2235,13 +2235,13 @@ static inline bool sw_triangle_face_culling(void)
|
||||
// Discard the triangle if its winding order (determined by the sign
|
||||
// of the homogeneous area/determinant) matches the culled direction
|
||||
// A positive hSgnArea typically corresponds to a counter-clockwise
|
||||
// winding in the projected space when all w > 0.
|
||||
// winding in the projected space when all w > 0
|
||||
// This test is robust for points with w > 0 or w < 0, correctly
|
||||
// capturing the change in orientation when crossing the w=0 plane
|
||||
|
||||
// The culling logic remains the same based on the signed area/determinant
|
||||
// A value of 0 for hSgnArea means the points are collinear in (x, y, w)
|
||||
// space, which corresponds to a degenerate triangle projection.
|
||||
// space, which corresponds to a degenerate triangle projection
|
||||
// Such triangles are typically not culled by this test (0 < 0 is false, 0 > 0 is false)
|
||||
// and should be handled by the clipper if necessary
|
||||
return (RLSW.cullFace == SW_FRONT)? (hSgnArea < 0) : (hSgnArea > 0); // Cull if winding is "clockwise" : "counter-clockwise"
|
||||
@@ -2602,7 +2602,7 @@ static inline bool sw_quad_face_culling(void)
|
||||
// space, which corresponds to a degenerate triangle projection
|
||||
// Such quads might also be degenerate or non-planar. They are typically
|
||||
// not culled by this test (0 < 0 is false, 0 > 0 is false)
|
||||
// and should be handled by the clipper if necessary.
|
||||
// and should be handled by the clipper if necessary
|
||||
|
||||
return (RLSW.cullFace == SW_FRONT)? (hSgnArea < 0.0f) : (hSgnArea > 0.0f); // Cull if winding is "clockwise" : "counter-clockwise"
|
||||
}
|
||||
|
||||
@@ -894,7 +894,8 @@ Vector2 GetMonitorPosition(int monitor)
|
||||
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
{
|
||||
int x, y;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
glfwGetMonitorPos(monitors[monitor], &x, &y);
|
||||
|
||||
return (Vector2){ (float)x, (float)y };
|
||||
|
||||
@@ -428,7 +428,7 @@ void SetMouseCursor(int cursor)
|
||||
TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform");
|
||||
}
|
||||
|
||||
// Get physical key name.
|
||||
// Get physical key name
|
||||
const char *GetKeyName(int key)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform");
|
||||
|
||||
@@ -3655,7 +3655,7 @@ void GenMeshTangents(Mesh *mesh)
|
||||
for (int t = 0; t < mesh->triangleCount; t++)
|
||||
{
|
||||
// Get triangle vertex indices
|
||||
int i0, i1, i2;
|
||||
int i0 = 0, i1 = 0, i2 = 0;
|
||||
|
||||
if (mesh->indices != NULL)
|
||||
{
|
||||
@@ -4150,7 +4150,7 @@ RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform)
|
||||
// Test against all triangles in mesh
|
||||
for (int i = 0; i < triangleCount; i++)
|
||||
{
|
||||
Vector3 a, b, c;
|
||||
Vector3 a = 0, b = 0, c = 0;
|
||||
Vector3 *vertdata = (Vector3 *)mesh.vertices;
|
||||
|
||||
if (mesh.indices)
|
||||
@@ -4193,8 +4193,8 @@ RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3
|
||||
RayCollision collision = { 0 };
|
||||
Vector3 edge1 = { 0 };
|
||||
Vector3 edge2 = { 0 };
|
||||
Vector3 p, q, tv;
|
||||
float det, invDet, u, v, t;
|
||||
Vector3 p = 0, q = 0, tv = 0;
|
||||
float det = 0.0f, invDet = 0.0f, u = 0.0f, v = 0.0f, t = 0.0f;
|
||||
|
||||
// Find vectors for two edges sharing V1
|
||||
edge1 = Vector3Subtract(p2, p1);
|
||||
|
||||
14
src/rtext.c
14
src/rtext.c
@@ -649,7 +649,9 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz
|
||||
|
||||
// Calculate font basic metrics
|
||||
// NOTE: ascent is equivalent to font baseline
|
||||
int ascent, descent, lineGap;
|
||||
int ascent = 0;
|
||||
int descent = 0;
|
||||
int lineGap = 0;
|
||||
stbtt_GetFontVMetrics(&fontInfo, &ascent, &descent, &lineGap);
|
||||
|
||||
// In case no chars count provided, default to 95
|
||||
@@ -2483,7 +2485,15 @@ static Font LoadBMFont(const char *fileName)
|
||||
font.glyphs = (GlyphInfo *)RL_MALLOC(glyphCount*sizeof(GlyphInfo));
|
||||
font.recs = (Rectangle *)RL_MALLOC(glyphCount*sizeof(Rectangle));
|
||||
|
||||
int charId, charX, charY, charWidth, charHeight, charOffsetX, charOffsetY, charAdvanceX, pageID;
|
||||
int charId = 0;
|
||||
int charX = 0;
|
||||
int charY = 0;
|
||||
int charWidth = 0;
|
||||
int charHeight = 0;
|
||||
int charOffsetX = 0;
|
||||
int charOffsetY = 0;
|
||||
int charAdvanceX = 0;
|
||||
int pageID = 0;
|
||||
|
||||
for (int i = 0; i < glyphCount; i++)
|
||||
{
|
||||
|
||||
@@ -1727,7 +1727,8 @@ void ImageResizeNN(Image *image, int newWidth, int newHeight)
|
||||
int xRatio = (int)((image->width << 16)/newWidth) + 1;
|
||||
int yRatio = (int)((image->height << 16)/newHeight) + 1;
|
||||
|
||||
int x2, y2;
|
||||
int x2 = 0;
|
||||
int y2 = 0;
|
||||
for (int y = 0; y < newHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < newWidth; x++)
|
||||
@@ -2488,8 +2489,13 @@ void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
|
||||
Color oldPixel = WHITE;
|
||||
Color newPixel = WHITE;
|
||||
|
||||
int rError, gError, bError;
|
||||
unsigned short rPixel, gPixel, bPixel, aPixel; // Used for 16bit pixel composition
|
||||
int rError = 0;
|
||||
int gError = 0;
|
||||
int bError = 0;
|
||||
unsigned short rPixel = 0; // Used for 16bit pixel composition
|
||||
unsigned short gPixel = 0;
|
||||
unsigned short bPixel = 0;
|
||||
unsigned short aPixel = 0;
|
||||
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
|
||||
@@ -4006,7 +4012,9 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
|
||||
// [-] GetPixelColor(): Get Vector4 instead of Color, easier for ColorAlphaBlend()
|
||||
// [ ] TODO: Support 16bit and 32bit (float) channels drawing
|
||||
|
||||
Color colSrc, colDst, blend;
|
||||
Color colSrc = { 0 };
|
||||
Color colDst = { 0 };
|
||||
Color blend = { 0 };
|
||||
bool blendRequired = true;
|
||||
|
||||
// Fast path: Avoid blend if source has no alpha to blend
|
||||
@@ -4681,17 +4689,23 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
|
||||
bottomBorder = patchHeight - topBorder;
|
||||
}
|
||||
|
||||
Vector2 vertA, vertB, vertC, vertD;
|
||||
vertA.x = 0.0f; // outer left
|
||||
vertA.y = 0.0f; // outer top
|
||||
vertB.x = leftBorder; // inner left
|
||||
vertB.y = topBorder; // inner top
|
||||
vertC.x = patchWidth - rightBorder; // inner right
|
||||
vertC.y = patchHeight - bottomBorder; // inner bottom
|
||||
vertD.x = patchWidth; // outer right
|
||||
vertD.y = patchHeight; // outer bottom
|
||||
Vector2 vertA = { 0 };
|
||||
Vector2 vertB = { 0 };
|
||||
Vector2 vertC = { 0 };
|
||||
Vector2 vertD = { 0 };
|
||||
vertA.x = 0.0f; // Outer left
|
||||
vertA.y = 0.0f; // Outer top
|
||||
vertB.x = leftBorder; // Inner left
|
||||
vertB.y = topBorder; // Inner top
|
||||
vertC.x = patchWidth - rightBorder; // Inner right
|
||||
vertC.y = patchHeight - bottomBorder; // Inner bottom
|
||||
vertD.x = patchWidth; // Outer right
|
||||
vertD.y = patchHeight; // Outer bottom
|
||||
|
||||
Vector2 coordA, coordB, coordC, coordD;
|
||||
Vector2 coordA = { 0 };
|
||||
Vector2 coordB = { 0 };
|
||||
Vector2 coordC = { 0 };
|
||||
Vector2 coordD = { 0 };
|
||||
coordA.x = nPatchInfo.source.x/width;
|
||||
coordA.y = nPatchInfo.source.y/height;
|
||||
coordB.x = (nPatchInfo.source.x + leftBorder)/width;
|
||||
@@ -4907,7 +4921,9 @@ Vector3 ColorToHSV(Color color)
|
||||
{
|
||||
Vector3 hsv = { 0 };
|
||||
Vector3 rgb = { (float)color.r/255.0f, (float)color.g/255.0f, (float)color.b/255.0f };
|
||||
float min, max, delta;
|
||||
float min = 0.0f;
|
||||
float max = 0.0f;
|
||||
float delta = 0.0f;
|
||||
|
||||
min = rgb.x < rgb.y? rgb.x : rgb.y;
|
||||
min = min < rgb.z? min : rgb.z;
|
||||
|
||||
Reference in New Issue
Block a user