Colors in Raylib

Steven Schveighoffer schveiguy at gmail.com
Tue Mar 1 02:42:52 UTC 2022


On 2/28/22 6:48 AM, Salih Dincer wrote:
> Hi All,
> 
> Is there a namespace I should implement in Raylib? For example, I cannot 
> compile without writing Colors at the beginning of the colors: 
> ```Colors.GRAY```
> 
> SDB at 79

If you refer to raylib-d, that's how it was since I've ever used it.

The original C code uses #defines for all the colors. It's an 
interesting incompatibility issue:

1. C doesn't support enums of anything but ints
2. D doesn't support #define constants

I think this is the only reason the colors are not an enum in the C code 
in the first place.

One way to fix this would be to just use individual enums to the 
raylib-d binding. I think it might have been this way originally.

I'm hesitant to change it, but I might define both at some point.

In general, the raylib enumerations are overly verbose for D, e.g. 
`KeyboardKey.KEY_X`, instead of just `KeyboardKey.X`. I'd love to 
provide "better enums".

-Steve


More information about the Digitalmars-d-learn mailing list