REVIEWED: Potential code issues reported by CodeQL #3476
This commit is contained in:
parent
ba21b8d274
commit
64d64cc181
12 changed files with 98 additions and 92 deletions
|
@ -75,9 +75,9 @@ int main(void)
|
|||
bool eventRecording = false;
|
||||
bool eventPlaying = false;
|
||||
|
||||
int frameCounter = 0;
|
||||
int playFrameCounter = 0;
|
||||
int currentPlayFrame = 0;
|
||||
unsigned int frameCounter = 0;
|
||||
unsigned int playFrameCounter = 0;
|
||||
unsigned int currentPlayFrame = 0;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(void)
|
|||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread");
|
||||
|
||||
pthread_t threadId; // Loading data thread id
|
||||
pthread_t threadId = { 0 }; // Loading data thread id
|
||||
|
||||
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
|
||||
int framesCounter = 0;
|
||||
|
|
|
@ -29,7 +29,7 @@ int main(void)
|
|||
|
||||
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
|
||||
|
||||
int framesCounter = 0; // Variable used to count frames
|
||||
unsigned int framesCounter = 0; // Variable used to count frames
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
|
@ -68,14 +68,12 @@ int main(void)
|
|||
|
||||
char skyboxFileName[256] = { 0 };
|
||||
|
||||
Texture2D panorama;
|
||||
|
||||
if (useHDR)
|
||||
{
|
||||
TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr");
|
||||
|
||||
// Load HDR panorama (sphere) texture
|
||||
panorama = LoadTexture(skyboxFileName);
|
||||
Texture2D panorama = LoadTexture(skyboxFileName);
|
||||
|
||||
// Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
|
||||
// NOTE 1: New texture is generated rendering to texture, shader calculates the sphere->cube coordinates mapping
|
||||
|
@ -83,7 +81,7 @@ int main(void)
|
|||
// despite texture can be successfully created.. so using PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 instead of PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
|
||||
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
||||
|
||||
//UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
||||
UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -113,15 +111,18 @@ int main(void)
|
|||
{
|
||||
if (IsFileExtension(droppedFiles.paths[0], ".png;.jpg;.hdr;.bmp;.tga"))
|
||||
{
|
||||
// Unload current cubemap texture and load new one
|
||||
// Unload current cubemap texture to load new one
|
||||
UnloadTexture(skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture);
|
||||
|
||||
if (useHDR)
|
||||
{
|
||||
// Load HDR panorama (sphere) texture
|
||||
Texture2D panorama = LoadTexture(droppedFiles.paths[0]);
|
||||
|
||||
// Generate cubemap from panorama texture
|
||||
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
|
||||
UnloadTexture(panorama);
|
||||
|
||||
UnloadTexture(panorama); // Texture not required anymore, cubemap already generated
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ int main(void)
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
float startangle;
|
||||
float startangle = 0.0f;
|
||||
|
||||
if (angleMode == 0) startangle = -Vector2LineAngle(v0, v1)*RAD2DEG;
|
||||
if (angleMode == 1) startangle = 0.0f;
|
||||
|
|
|
@ -82,7 +82,8 @@ int main(void)
|
|||
// Check if screen is resized
|
||||
if (IsWindowResized())
|
||||
{
|
||||
float resolution[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() };
|
||||
resolution[0] = (float)GetScreenWidth();
|
||||
resolution[1] = (float)GetScreenHeight();
|
||||
SetShaderValue(shader, resolutionLoc, resolution, SHADER_UNIFORM_VEC2);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -195,7 +195,7 @@ int main(void)
|
|||
}
|
||||
|
||||
Vector2 mouse = GetMousePosition();
|
||||
Vector2 pos = { 28.8f, 10.0f };
|
||||
Vector2 position = { 28.8f, 10.0f };
|
||||
hovered = -1;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
@ -210,21 +210,21 @@ int main(void)
|
|||
for (int i = 0; i < SIZEOF(emoji); ++i)
|
||||
{
|
||||
const char *txt = &emojiCodepoints[emoji[i].index];
|
||||
Rectangle emojiRect = { pos.x, pos.y, (float)fontEmoji.baseSize, (float)fontEmoji.baseSize };
|
||||
Rectangle emojiRect = { position.x, position.y, (float)fontEmoji.baseSize, (float)fontEmoji.baseSize };
|
||||
|
||||
if (!CheckCollisionPointRec(mouse, emojiRect))
|
||||
{
|
||||
DrawTextEx(fontEmoji, txt, pos, (float)fontEmoji.baseSize, 1.0f, selected == i ? emoji[i].color : Fade(LIGHTGRAY, 0.4f));
|
||||
DrawTextEx(fontEmoji, txt, position, (float)fontEmoji.baseSize, 1.0f, selected == i ? emoji[i].color : Fade(LIGHTGRAY, 0.4f));
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTextEx(fontEmoji, txt, pos, (float)fontEmoji.baseSize, 1.0f, emoji[i].color );
|
||||
DrawTextEx(fontEmoji, txt, position, (float)fontEmoji.baseSize, 1.0f, emoji[i].color );
|
||||
hovered = i;
|
||||
hoveredPos = pos;
|
||||
hoveredPos = position;
|
||||
}
|
||||
|
||||
if ((i != 0) && (i%EMOJI_PER_WIDTH == 0)) { pos.y += fontEmoji.baseSize + 24.25f; pos.x = 28.8f; }
|
||||
else pos.x += fontEmoji.baseSize + 28.8f;
|
||||
if ((i != 0) && (i%EMOJI_PER_WIDTH == 0)) { position.y += fontEmoji.baseSize + 24.25f; position.x = 28.8f; }
|
||||
else position.x += fontEmoji.baseSize + 28.8f;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -282,8 +282,8 @@ int main(void)
|
|||
int length = GetCodepointCount(messages[message].text);
|
||||
const char *info = TextFormat("%s %u characters %i bytes", messages[message].language, length, size);
|
||||
sz = MeasureTextEx(GetFontDefault(), info, 10, 1.0f);
|
||||
Vector2 pos = { textRect.x + textRect.width - sz.x, msgRect.y + msgRect.height - sz.y - 2 };
|
||||
DrawText(info, (int)pos.x, (int)pos.y, 10, RAYWHITE);
|
||||
|
||||
DrawText(info, (int)(textRect.x + textRect.width - sz.x), (int)(msgRect.y + msgRect.height - sz.y - 2), 10, RAYWHITE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue