Thread overview
raylib-d Create Light Sources
Dec 01, 2022
jwatson-CO-edu
Dec 01, 2022
jwatson-CO-edu
December 01, 2022

I am attempting to recreate the Raylib flat shading tutorial with raylib-d. I have been able to find most of the necessary wrappers except the one the creates light sources. How do I create light sources in raylib-d?

uint MAX_LIGHTS = 4;
//...
Light[MAX_LIGHTS] lights; // Error: undefined identifier `Light`
lights[0] = CreateLight(
    LIGHT_POINT, Vector3( -2, 1, -2 ), Vector3Zero(), Colors.YELLOW, shader
);
lights[1] = CreateLight(
    LIGHT_POINT, Vector3( 2, 1, 2 ), Vector3Zero(), Colors.RED, shader
);
lights[2] = CreateLight(
    LIGHT_POINT, Vector3( -2, 1, 2 ), Vector3Zero(), Colors.GREEN, shader
);
lights[3] = CreateLight(
    LIGHT_POINT, Vector3( 2, 1, -2 ), Vector3Zero(), Colors.BLUE, shader
);
November 30, 2022

On 11/30/22 7:56 PM, jwatson-CO-edu wrote:

>

uint MAX_LIGHTS = 4;

This needs to be an enum.

>

//...
Light[MAX_LIGHTS] lights; // Error: undefined identifier Light

The rlights header file is not part of the raylib library, but is in the examples directory, you will need to port it. It's not very big, you probably can do it in a half hour.

https://github.com/raysan5/raylib/blob/387c06000618ef0aa3b15c5e46d1c525ba194c50/examples/shaders/rlights.h

-Steve

December 01, 2022

On Thursday, 1 December 2022 at 01:17:16 UTC, Steven Schveighoffer wrote:

>

On 11/30/22 7:56 PM, jwatson-CO-edu wrote:

>

uint MAX_LIGHTS = 4;
The rlights header file is not part of the raylib library, but is in the examples directory, you will need to port it. It's not very big, you probably can do it in a half hour.

https://github.com/raysan5/raylib/blob/387c06000618ef0aa3b15c5e46d1c525ba194c50/examples/shaders/rlights.h

-Steve

This seems to work, in case anyone else wanted to do lighting in this way.