Syntax Sugar for Initializing a Fixed float Array as void*?

jwatson-CO-edu real.name at colorado.edu
Thu Dec 1 01:02:19 UTC 2022


On Thursday, 1 December 2022 at 00:47:18 UTC, Adam D Ruppe wrote:
> On Thursday, 1 December 2022 at 00:39:21 UTC, jwatson-CO-edu 
> wrote:
>> Is there a way to write a single statement that creates a void 
>> pointer that points to an initialized float array?

> float[] f = [1,1,1];
>
> some_function_taking_void(f.ptr);
>
> and it just works.

Thank you, that was just the magic I needed!

```d
float[4] arr = [0.1f, 0.1f, 0.1f, 1.0f]; // Init array with values

SetShaderValue(
     shader, ambientLoc, arr.ptr, 
ShaderUniformDataType.SHADER_UNIFORM_VEC4
); //                   ^^^^^^^---void* here
```




More information about the Digitalmars-d-learn mailing list