Been using D for a couple years now, however one problem I've had, more so recently since I've been dealing a lot with OpenGL is related to pointers.

I have a matrix object to aid with the matrix math required for working with 3D transforms. However OpenGL (I'm using DerelictGL3 bindings) requires pointers to the data. I am currently doing the following:

Matrix!float ortho(float l, float r, float b, float t, float f, float n = -1)
{
        Matrix!float oMat = identity(); // Get default Identity Matrix
        
        oMat[0,0] =  2 / (r - l);
        oMat[1,1] =  2 / (t - b);
        oMat[2,2] = -2 / (f - n);
        
        oMat[3] = [-(r+l)/(r-l), -(t+b)/(t-b), -(f+n)/(f-n), 1];
        
        return oMat;
}

And then to use with OpenGL (passing as uniform into shader):

glUniformMatrix4fv(transform_uniform, 1, GL_FALSE, matrix.addr );

where addr is a property that returns the address of the first item in the Matrix's internal data. I know I can also use &matrix[0][0]

My question is about overloading, several operators can be overloaded in D, one of the ones that can't apparently is the address of operator (&object). My question is have I simply missed it or does it actually not exist, and if it's not overloadable, is there any reason why this was decided? Because there's been numerous times that it'd be useful to me, just recently with how much I use the operator because of OpenGL I decided to ask.

Reply via email to