How to I translate this C++ structure/array

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 2 19:31:49 PDT 2015


On Saturday, 2 May 2015 at 22:36:29 UTC, anonymous wrote:
> On Saturday, 2 May 2015 at 22:01:10 UTC, WhatMeWorry wrote:
>>    struct Vertex
>>    {
>>        vec3 position;
>>        vec3 color;
>>    }
>>
>>    Vertex triangle[6] =
>>    [
>>        vec3(0.0,  1.0, 0.0),
>>        vec3(1.0,  0.0, 0.0),   // red
>>
>>       // code removed for brevity.
>>    ];
>>
>> I keep getting the following:
>>
>> MeGlWindow.d(171): Error: cannot implicitly convert expression 
>> (Vector([0.000000F, 1.00000F, 0.000000F])) of type 
>> Vector!(float, 3) to Vertex
>
> You have to be explicit:
>
>     Vertex[6] triangle = /* [1] */
>     [
>         Vertex(
>             vec3(0.0,  1.0, 0.0),
>             vec3(1.0,  0.0, 0.0),   // red
>         ),
>         ...
>     ];
>
> [1] `Vertex triangle[6]` works, but please don't do that.

Thanks. I assume you would prefer I use triangle[] but with 
OpenGL calls the dynamic arrays don't work.  But maybe that is 
another question for another time.


More information about the Digitalmars-d-learn mailing list