check_textures - 1Fr3aK2/Cub3d GitHub Wiki

📝 check_textures

This function verifies that all wall textures and color values (floor and ceiling) in the map are valid before the game proceeds.


⚙️ Parameters

Parameter Type Description
floor char * String containing the RGB values or path for the floor color.
ceiling char * String containing the RGB values or path for the ceiling color.
map t_map * Pointer to the map structure containing all wall textures (east, north, south, west).

🔁 Returns

Return value Description
bool Returns true if all wall textures and color values are valid; otherwise returns false.

📖 Description

The check_textures function ensures that all wall textures and color values in the provided map are correctly set and valid:

  • Calls verify_texture to validate the existence and accessibility of each wall texture (east, north, south, and west).
  • Uses check_rgb to verify that both floor and ceiling contain valid RGB values or color data.
  • If any texture or color check fails, the function immediately returns false.
  • If all verifications succeed, it returns true, confirming that all graphical resources are ready for use.

This validation step prevents rendering errors or crashes by ensuring the game only uses verified and properly formatted texture and color data.


💡 Example Usage

t_map map = {0};

// Assume map textures and color data have been initialized elsewhere

if (check_textures(map.floor, map.ceiling, &map)) {
    printf("✅ All textures and colors are valid.\n");
} else {
    printf("❌ Some textures or colors are invalid.\n");
}