Create light with provided data NOTE: It updated the global lightCount and it's limited to MAX_LIGHTS
| 288 | // Create light with provided data |
| 289 | // NOTE: It updated the global lightCount and it's limited to MAX_LIGHTS |
| 290 | static Light CreateLight(size_t index, LightType type, Vector3 position, Vector3 target, Color color, float intensity, Shader shader) |
| 291 | { |
| 292 | Light light; |
| 293 | |
| 294 | light.enabled = 1; |
| 295 | light.type = type; |
| 296 | light.position = position; |
| 297 | light.target = target; |
| 298 | light.color[0] = (float)color.r/255.0f; |
| 299 | light.color[1] = (float)color.g/255.0f; |
| 300 | light.color[2] = (float)color.b/255.0f; |
| 301 | light.color[3] = (float)color.a/255.0f; |
| 302 | light.intensity = intensity; |
| 303 | |
| 304 | // NOTE: Shader parameters names for lights must match the requested ones |
| 305 | light.enabledLoc = GetShaderLocation(shader, TextFormat("lights[%i].enabled", index)); |
| 306 | light.typeLoc = GetShaderLocation(shader, TextFormat("lights[%i].type", index)); |
| 307 | light.positionLoc = GetShaderLocation(shader, TextFormat("lights[%i].position", index)); |
| 308 | light.targetLoc = GetShaderLocation(shader, TextFormat("lights[%i].target", index)); |
| 309 | light.colorLoc = GetShaderLocation(shader, TextFormat("lights[%i].color", index)); |
| 310 | light.intensityLoc = GetShaderLocation(shader, TextFormat("lights[%i].intensity", index)); |
| 311 | |
| 312 | UpdateLight(shader, light); |
| 313 | |
| 314 | return light; |
| 315 | } |
| 316 | |
| 317 | // Send light properties to shader |
| 318 | // NOTE: Light shader locations should be available |