Browse Source

Review variables initialization

pull/853/head
Ray 5 years ago
parent
commit
87774a0a21
33 changed files with 52 additions and 56 deletions
  1. +1
    -1
      examples/audio/audio_module_playing.c
  2. +0
    -1
      examples/audio/audio_sound_loading.c
  3. +2
    -3
      examples/core/core_2d_camera.c
  4. +3
    -3
      examples/core/core_3d_camera_first_person.c
  5. +1
    -1
      examples/core/core_3d_camera_free.c
  6. +1
    -1
      examples/core/core_custom_logging.c
  7. +1
    -1
      examples/core/core_vr_simulator.c
  8. +1
    -2
      examples/core/core_world_screen.c
  9. +1
    -1
      examples/models/models_box_collisions.c
  10. +1
    -1
      examples/models/models_cubicmap.c
  11. +1
    -1
      examples/models/models_first_person_maze.c
  12. +1
    -1
      examples/models/models_heightmap.c
  13. +2
    -2
      examples/models/models_mesh_generation.c
  14. +1
    -1
      examples/models/models_obj_viewer.c
  15. +1
    -1
      examples/models/models_orthographic_projection.c
  16. +1
    -1
      examples/models/models_skybox.c
  17. +1
    -1
      examples/others/raudio_standalone.c
  18. +1
    -1
      examples/others/rlgl_standalone.c
  19. +2
    -2
      examples/physac/physics_friction.c
  20. +2
    -2
      examples/shaders/shaders_postprocessing.c
  21. +1
    -1
      examples/shapes/shapes_colors_palette.c
  22. +1
    -1
      examples/shapes/shapes_easings_rectangle_array.c
  23. +1
    -1
      examples/text/text_font_sdf.c
  24. +2
    -2
      examples/text/text_raylib_fonts.c
  25. +6
    -6
      examples/text/text_rectangle_bounds.c
  26. +6
    -8
      examples/text/text_sprite_fonts.c
  27. +1
    -1
      examples/text/text_ttf_loading.c
  28. +3
    -3
      examples/textures/textures_background_scrolling.c
  29. +2
    -1
      examples/textures/textures_image_generation.c
  30. +1
    -1
      examples/textures/textures_image_processing.c
  31. +1
    -1
      examples/textures/textures_particles_blending.c
  32. +1
    -1
      examples/textures/textures_raw_data.c
  33. +1
    -1
      examples/textures/textures_sprite_explosion.c

+ 1
- 1
examples/audio/audio_module_playing.c View File

@ -40,7 +40,7 @@ int main(void)
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
// Creates ome circles for visual effect
CircleWave circles[MAX_CIRCLES];
CircleWave circles[MAX_CIRCLES] = { 0 };
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
{

+ 0
- 1
examples/audio/audio_sound_loading.c View File

@ -46,7 +46,6 @@ int main(void)
ClearBackground(RAYWHITE);
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
EndDrawing();

+ 2
- 3
examples/core/core_2d_camera.c View File

@ -23,8 +23,8 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
Rectangle player = { 400, 280, 40, 40 };
Rectangle buildings[MAX_BUILDINGS];
Color buildColors[MAX_BUILDINGS];
Rectangle buildings[MAX_BUILDINGS] = { 0 };
Color buildColors[MAX_BUILDINGS] = { 0 };
int spacing = 0;
@ -41,7 +41,6 @@ int main(void)
}
Camera2D camera = { 0 };
camera.target = (Vector2){ player.x + 20, player.y + 20 };
camera.offset = (Vector2){ 0, 0 };
camera.rotation = 0.0f;

+ 3
- 3
examples/core/core_3d_camera_first_person.c View File

@ -31,9 +31,9 @@ int main(void)
camera.type = CAMERA_PERSPECTIVE;
// Generates some random columns
float heights[MAX_COLUMNS];
Vector3 positions[MAX_COLUMNS];
Color colors[MAX_COLUMNS];
float heights[MAX_COLUMNS] = { 0.0f };
Vector3 positions[MAX_COLUMNS] = { 0 };
Color colors[MAX_COLUMNS] = { 0 };
for (int i = 0; i < MAX_COLUMNS; i++)
{

+ 1
- 1
examples/core/core_3d_camera_free.c View File

@ -21,7 +21,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
// Define the camera to look into our 3d world
Camera3D camera;
Camera3D camera = { 0 };
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)

+ 1
- 1
examples/core/core_custom_logging.c View File

@ -19,7 +19,7 @@
// Custom logging funtion
void LogCustom(int msgType, const char *text, va_list args)
{
char timeStr[64];
char timeStr[64] = { 0 };
time_t now = time(NULL);
struct tm *tm_info = localtime(&now);

+ 1
- 1
examples/core/core_vr_simulator.c View File

@ -60,7 +60,7 @@ int main(void)
SetVrConfiguration(hmd, distortion); // Set Vr device parameters for stereo rendering
// Define the camera to look into our 3d world
Camera camera;
Camera camera = { 0 };
camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)

+ 1
- 2
examples/core/core_world_screen.c View File

@ -29,8 +29,7 @@ int main(void)
camera.type = CAMERA_PERSPECTIVE;
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
Vector2 cubeScreenPosition;
Vector2 cubeScreenPosition = { 0.0f, 0.0f };
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode

+ 1
- 1
examples/models/models_box_collisions.c View File

@ -21,7 +21,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
// Define the camera to look into our 3d world
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Camera camera = { { 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Vector3 playerPosition = { 0.0f, 1.0f, 2.0f };
Vector3 playerSize = { 1.0f, 2.0f, 1.0f };

+ 1
- 1
examples/models/models_cubicmap.c View File

@ -21,7 +21,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
// Define the camera to look into our 3d world
Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Camera camera = { { 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)

+ 1
- 1
examples/models/models_first_person_maze.c View File

@ -23,7 +23,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");
// Define the camera to look into our 3d world
Camera camera = {{ 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Camera camera = { { 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM)

+ 1
- 1
examples/models/models_heightmap.c View File

@ -21,7 +21,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
// Define our custom camera to look into our 3d world
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Camera camera = { { 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)

+ 2
- 2
examples/models/models_mesh_generation.c View File

@ -27,7 +27,7 @@ int main(void)
Texture2D texture = LoadTextureFromImage(checked);
UnloadImage(checked);
Model models[NUM_MODELS];
Model models[NUM_MODELS] = { 0 };
models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 5, 5));
models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f));
@ -42,7 +42,7 @@ int main(void)
for (int i = 0; i < NUM_MODELS; i++) models[i].materials[0].maps[MAP_DIFFUSE].texture = texture;
// Define the camera to look into our 3d world
Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Camera camera = { { 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
// Model drawing position
Vector3 position = { 0.0f, 0.0f, 0.0f };

+ 1
- 1
examples/models/models_obj_viewer.c View File

@ -23,7 +23,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib example - obj viewer");
// Define the camera to look into our 3d world
Camera camera = {{ 30.0f, 30.0f, 30.0f }, { 0.0f, 10.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Camera camera = { { 30.0f, 30.0f, 30.0f }, { 0.0f, 10.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Model model = LoadModel("resources/models/turret.obj"); // Load default model obj
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load default model texture

+ 1
- 1
examples/models/models_orthographic_projection.c View File

@ -28,7 +28,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
// Define the camera to look into our 3d world
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE };
Camera camera = { { 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

+ 1
- 1
examples/models/models_skybox.c View File

@ -21,7 +21,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
// Define the camera to look into our 3d world
Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 4.0f, 1.0f, 4.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Camera camera = { { 1.0f, 1.0f, 1.0f }, { 4.0f, 1.0f, 4.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
// Load skybox model
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);

+ 1
- 1
examples/others/raudio_standalone.c View File

@ -94,7 +94,7 @@ int main()
{
// Initialization
//--------------------------------------------------------------------------------------
static unsigned char key;
static unsigned char key = 0;
InitAudioDevice();

+ 1
- 1
examples/others/rlgl_standalone.c View File

@ -131,7 +131,7 @@ int main(void)
rlClearColor(245, 245, 245, 255); // Define clear color
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
Camera camera;
Camera camera = { 0 };
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)

+ 2
- 2
examples/physac/physics_friction.c View File

@ -61,8 +61,8 @@ int main(void)
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 35, screenHeight*0.6f }, 40, 40, 10);
bodyB->staticFriction = i">1;
bodyB->dynamicFriction = i">1;
bodyB->staticFriction = f">1.0f;
bodyB->dynamicFriction = f">1.0f;
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second

+ 2
- 2
examples/shaders/shaders_postprocessing.c View File

@ -70,7 +70,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
// Define the camera to look into our 3d world
Camera camera = {{ 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Camera camera = { { 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
@ -81,7 +81,7 @@ int main(void)
// Load all postpro shaders
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
// NOTE 2: We load the correct shader depending on GLSL version
Shader shaders[MAX_POSTPRO_SHADERS];
Shader shaders[MAX_POSTPRO_SHADERS] = { 0 };
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
shaders[FX_GRAYSCALE] = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));

+ 1
- 1
examples/shapes/shapes_colors_palette.c View File

@ -45,7 +45,7 @@ int main(void)
int colorState[MAX_COLORS_COUNT] = { 0 }; // Color state: 0-DEFAULT, 1-MOUSE_HOVER
Vector2 mousePoint;
Vector2 mousePoint = { 0.0f, 0.0f };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

+ 1
- 1
examples/shapes/shapes_easings_rectangle_array.c View File

@ -33,7 +33,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings rectangle array");
Rectangle recs[MAX_RECS_X*MAX_RECS_Y];
Rectangle recs[MAX_RECS_X*MAX_RECS_Y] = { 0 };
for (int y = 0; y < MAX_RECS_Y; y++)
{

+ 1
- 1
examples/text/text_font_sdf.c View File

@ -57,7 +57,7 @@ int main(void)
SetTextureFilter(fontSDF.texture, FILTER_BILINEAR); // Required for SDF font
Vector2 fontPosition = { 40, screenHeight/2 - 50 };
Vector2 textSize = { 0.0f };
Vector2 textSize = { 0.0f, 0.0f };
float fontSize = 16.0f;
int currentFont = 0; // 0 - fontDefault, 1 - fontSDF

+ 2
- 2
examples/text/text_raylib_fonts.c View File

@ -26,7 +26,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Font fonts[MAX_FONTS];
Font fonts[MAX_FONTS] = { 0 };
fonts[0] = LoadFont("resources/fonts/alagard.png");
fonts[1] = LoadFont("resources/fonts/pixelplay.png");
@ -48,7 +48,7 @@ int main(void)
const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 };
Vector2 positions[MAX_FONTS];
Vector2 positions[MAX_FONTS] = { 0 };
for (int i = 0; i < MAX_FONTS; i++)
{

+ 6
- 6
examples/text/text_rectangle_bounds.c View File

@ -22,7 +22,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [text] example - draw text inside a rectangle");
char text[] = "Text cannot escape\tthis container\t...word wrap also works when active so here's\
">const char text[] = "Text cannot escape\tthis container\t...word wrap also works when active so here's\
a long text for testing.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\
tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet risus nullam eget felis eget.";
@ -38,15 +38,15 @@ int main(void)
const int maxWidth = screenWidth - 50;
const int maxHeight = screenHeight - 160;
Vector2 lastMouse = { i">0, 0 }; // Stores last mouse coordinates
Color borderColor = MAROON; // Container border color
Font font = GetFontDefault(); // Get default system font
Vector2 lastMouse = { f">0.0f, 0.0f }; // Stores last mouse coordinates
Color borderColor = MAROON; // Container border color
Font font = GetFontDefault(); // Get default system font
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------

+ 6
- 8
examples/text/text_sprite_fonts.c View File

@ -29,16 +29,14 @@ int main(void)
Font font2 = LoadFont("resources/custom_alagard.png"); // Font loading
Font font3 = LoadFont("resources/custom_jupiter_crash.png"); // Font loading
Vector2 fontPosition1, fontPosition2, fontPosition3;
Vector2 fontPosition1 = { screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2,
screenHeight/2 - font1.baseSize/2 - 80 };
fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2;
fontPosition1.y = screenHeight/2 - font1.baseSize/2 - 80;
Vector2 fontPosition2 = { screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2,
screenHeight/2 - font2.baseSize/2 - 10 };
fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2;
fontPosition2.y = screenHeight/2 - font2.baseSize/2 - 10;
fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2;
fontPosition3.y = screenHeight/2 - font3.baseSize/2 + 50;
Vector2 fontPosition3 = { screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2,
screenHeight/2 - font3.baseSize/2 + 50 };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

+ 1
- 1
examples/text/text_ttf_loading.c View File

@ -33,7 +33,7 @@ int main(void)
float fontSize = font.baseSize;
Vector2 fontPosition = { 40, screenHeight/2 - 80 };
Vector2 textSize;
Vector2 textSize = { 0.0f, 0.0f };
// Setup texture scaling filter
SetTextureFilter(font.texture, FILTER_POINT);

+ 3
- 3
examples/textures/textures_background_scrolling.c View File

@ -26,9 +26,9 @@ int main(void)
Texture2D midground = LoadTexture("resources/cyberpunk_street_midground.png");
Texture2D foreground = LoadTexture("resources/cyberpunk_street_foreground.png");
float scrollingBack = i">0;
float scrollingMid = i">0;
float scrollingFore = i">0;
float scrollingBack = f">0.0f;
float scrollingMid = f">0.0f;
float scrollingFore = f">0.0f;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

+ 2
- 1
examples/textures/textures_image_generation.c View File

@ -30,7 +30,8 @@ int main(void)
Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f);
Image cellular = GenImageCellular(screenWidth, screenHeight, 32);
Texture2D textures[NUM_TEXTURES];
Texture2D textures[NUM_TEXTURES] = { 0 };
textures[0] = LoadTextureFromImage(verticalGradient);
textures[1] = LoadTextureFromImage(horizontalGradient);
textures[2] = LoadTextureFromImage(radialGradient);

+ 1
- 1
examples/textures/textures_image_processing.c View File

@ -57,7 +57,7 @@ int main(void)
int currentProcess = NONE;
bool textureReload = false;
Rectangle selectRecs[NUM_PROCESSES];
Rectangle selectRecs[NUM_PROCESSES] = { 0 };
for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40.0f, (float)(50 + 32*i), 150.0f, 30.0f };

+ 1
- 1
examples/textures/textures_particles_blending.c View File

@ -33,7 +33,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending");
// Particles pool, reuse them!
Particle mouseTail[MAX_PARTICLES];
Particle mouseTail[MAX_PARTICLES] = { 0 };
// Initialize particles
for (int i = 0; i < MAX_PARTICLES; i++)

+ 1
- 1
examples/textures/textures_raw_data.c View File

@ -31,7 +31,7 @@ int main(void)
Texture2D fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM)
UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data
// Generate a checked texture by code (1024x1024 pixels)
// Generate a checked texture by code
int width = 960;
int height = 480;

+ 1
- 1
examples/textures/textures_sprite_explosion.c View File

@ -38,7 +38,7 @@ int main(void)
int currentLine = 0;
Rectangle frameRec = { 0, 0, frameWidth, frameHeight };
Vector2 position = { i">0, 0 };
Vector2 position = { f">0.0f, 0.0f };
bool active = false;
int framesCounter = 0;

Loading…
Cancel
Save