dwmkerr / glmnet

GlmNet is a .NET version of the excellent OpenGL Mathematics library (GLM).
MIT License
53 stars 20 forks source link

Double instead of Single #15

Closed pepcots closed 9 months ago

pepcots commented 4 years ago

First of all, fucking many thanks for your port! I know the default precision for glm in c++ is single (to be aligned with the old GPUs), but, as we are doing a usable port, I think it is more interesting to use double precision or create the posibility to do thta like creating the classes dvec3, dmat4...

Many thanks!

dwmkerr commented 4 years ago

Yes! I really want to be able to use doubles; at the time I created the library at first there was not a way to template arithmetic types (i.e. create a class Vertex<scalar> with scalar being a double/float etc). Basically the templating doesn't allow you to make assumptions that the type can do arithmetic operations:

class Vector<type Scalar> : where Scalar is artithmatic
{
  private Scalar x,y;
  public Scalar Magnitude() { return x*x +y*y }
}

It is possible the language has improved templating support since I tried this, if not it might be a copy paste or even code generation job to do this - any suggestions?

The gist of the problem is here:

https://stackoverflow.com/questions/10951392/implementing-arithmetic-in-generics

I've even considered using MSIL as a way to write the library if needed, but a lot of work!

Pycorax commented 3 years ago

As C# still has no such templating features, in the mean time would it be sufficient for a manually created version of the existing structs that support doubles instead? I'm currently using this for a project and would need dvecs so I don't mind trying my hand on it but I'd like to see what do you guys think.