digitalmars.D.learn - An annoying compile issue
- WhatMeWorry (20/20) Oct 25 2015 I'm porting over some C++/glm/openGL code. I've used gl3n for a
- Rikki Cattermole (3/15) Oct 25 2015 It is not a tuple.
- Adam D. Ruppe (16/20) Oct 25 2015 I'm not familiar with the gl3n library so I'm not sure what their
- WhatMeWorry (3/24) Oct 26 2015 Ok. If it's good enough for ADR, it's good enough for me. Thanks
I'm porting over some C++/glm/openGL code. I've used gl3n for a while now (successfully) to port over glm code, but I've got this pebble in my shoe: glm::mat4 model; model = glm::scale(model, glm::vec3(size, 1.0f)); // size is a vec2 So my D code consists of: mat4 model; model = model.scale(vec3(size, 1.0f)); // size is a vec2 Error: function gl3n.linalg.Matrix!(float, 4, 4).Matrix.scale (float x, float y, float z) is not callable using argument types (Vector!(float, 3)) First, isn't Vector!(float,3) a template which creates a tuple consisting of float, float, float; so aren't the argument types identical? I can workaround the issue by simply model = model.scale(size.x, size.y, 1.0f); but that seems like cheating :) Is there an elegant D fix. Not to imply that there is any other kind.
Oct 25 2015
On 26/10/15 4:44 PM, WhatMeWorry wrote:I'm porting over some C++/glm/openGL code. I've used gl3n for a while now (successfully) to port over glm code, but I've got this pebble in my shoe: glm::mat4 model; model = glm::scale(model, glm::vec3(size, 1.0f)); // size is a vec2 So my D code consists of: mat4 model; model = model.scale(vec3(size, 1.0f)); // size is a vec2 Error: function gl3n.linalg.Matrix!(float, 4, 4).Matrix.scale (float x, float y, float z) is not callable using argument types (Vector!(float, 3)) First, isn't Vector!(float,3) a template which creates a tuple consisting of float, float, float; so aren't the argument types identical?It is not a tuple. vec2 != vec3. They are different types altogether.
Oct 25 2015
On Monday, 26 October 2015 at 03:44:31 UTC, WhatMeWorry wrote:First, isn't Vector!(float,3) a template which creates a tuple consisting of float, float, float; so aren't the argument types identical?I'm not familiar with the gl3n library so I'm not sure what their Vector is, but most D templates are not created from tuples and don't work that way. Looking at the source, it indeed seems to be based on a static array rather than a tuple: https://github.com/Dav1dde/gl3n/blob/master/gl3n/linalg.d#L49 --- vt[dimension] vector; /// Holds all coordinates, length conforms dimension. --- Which means there's no simple, built-in way to getting a tuple out of that. You could write one though, and recently there was a post about maybe putting that in Phobos, but it isn't there now.model = model.scale(size.x, size.y, 1.0f);meh that's prolly what I'd do... unless you wanted to modify the library and add some expansion code to that vector type.
Oct 25 2015
On Monday, 26 October 2015 at 03:53:21 UTC, Adam D. Ruppe wrote:On Monday, 26 October 2015 at 03:44:31 UTC, WhatMeWorry wrote:Ok. If it's good enough for ADR, it's good enough for me. Thanks all.First, isn't Vector!(float,3) a template which creates a tuple consisting of float, float, float; so aren't the argument types identical?I'm not familiar with the gl3n library so I'm not sure what their Vector is, but most D templates are not created from tuples and don't work that way. Looking at the source, it indeed seems to be based on a static array rather than a tuple: https://github.com/Dav1dde/gl3n/blob/master/gl3n/linalg.d#L49 --- vt[dimension] vector; /// Holds all coordinates, length conforms dimension. --- Which means there's no simple, built-in way to getting a tuple out of that. You could write one though, and recently there was a post about maybe putting that in Phobos, but it isn't there now.model = model.scale(size.x, size.y, 1.0f);meh that's prolly what I'd do... unless you wanted to modify the library and add some expansion code to that vector type.
Oct 26 2015