MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / CreateLight

Function CreateLight

examples/shaders/rlights.h:121–146  ·  view source on GitHub ↗

Create a light and get shader locations

Source from the content-addressed store, hash-verified

119
120// Create a light and get shader locations
121Light CreateLight(int type, Vector3 position, Vector3 target, Color color, Shader shader)
122{
123 Light light = { 0 };
124
125 if (lightsCount < MAX_LIGHTS)
126 {
127 light.enabled = true;
128 light.type = type;
129 light.position = position;
130 light.target = target;
131 light.color = color;
132
133 // NOTE: Lighting shader naming must be the provided ones
134 light.enabledLoc = GetShaderLocation(shader, TextFormat("lights[%i].enabled", lightsCount));
135 light.typeLoc = GetShaderLocation(shader, TextFormat("lights[%i].type", lightsCount));
136 light.positionLoc = GetShaderLocation(shader, TextFormat("lights[%i].position", lightsCount));
137 light.targetLoc = GetShaderLocation(shader, TextFormat("lights[%i].target", lightsCount));
138 light.colorLoc = GetShaderLocation(shader, TextFormat("lights[%i].color", lightsCount));
139
140 UpdateLightValues(shader, light);
141
142 lightsCount++;
143 }
144
145 return light;
146}
147
148// Send light properties to shader
149// NOTE: Light shader locations should be available

Callers 1

mainFunction · 0.70

Calls 1

UpdateLightValuesFunction · 0.85

Tested by

no test coverage detected