In our previous episode, Ryan Joseph said: > > On May 28, 2017, at 10:33 PM, Ryan Joseph <r...@thealchemistguild.com> > > wrote: > > > > projTransform := TMatrix4x4.CreatePerspective(60.0, 500 / 500, 0.1, > > 10.0); > > modelTransform := TMatrix4x4.CreateTranslation(0, 0, -3.0) * > > TMat4.CreateRotateX(54); > > I found out the problem. I was expecting the multiply to work like with GLM > where you could do: > > translation * rotation > > but with the operator overloads I need to do protation * translation. > Anthony?s multiply matrix 4 operators did this in the order I expected and > how I figured it out. Not sure why and it?s probably not safe to swap the > parameters because it would likely break other parts of the unit.
For the 2Ders, in old GL I used glortho2d a lot. In newer ones I missed that, but I found an equivalent on stackoverflow: // http://stackoverflow.com/questions/21323743/modern-equivalent-of-gluortho2d procedure MyOrtho2D(var mat : TGLMatrixf4;left,right,bottom,top:single); var inv_y,inv_x : single; begin inv_y := 1.0 / (top - bottom); inv_x := 1.0 / (right - left); // this is basically from // http://en.wikipedia.org/wiki/Orthographic_projection_(geometry) //first column mat[0][0] := (2.0*inv_x); mat[0][1] := (0.0); mat[0][2] := (0.0); mat[0][3] := (0.0); //second mat[1][0] := (0.0); mat[1][1] := (2.0*inv_y); mat[1][2] := (0.0); mat[1][3] := (0.0); //third mat[2][0] := (0.0); mat[2][1] := (0.0); mat[2][2] := (-2.0*inv_z); mat[2][3] := (0.0); //fourth mat[3][0] := (-(right + left)*inv_x); mat[3][1] := (-(top + bottom)*inv_y); mat[3][2] := (-(zFar + zNear)*inv_z); mat[3][3] := (1.0); end; I have a TGLvector for zoom (X/Y) and one for pan (offset, also in X and Y direction). // calcs a matrix for the shader. pass the matrix as an uniform and multiply in vertex or geometry shader procedure myorthohelp(var mat : TGLMatrixf4;const aoffs,azoom:TGLVectorf2;topdown:boolean=false); begin myOrtho2D(mat,aoffs[0], 1.0 / (aZoom[0]) + (aoffs[0]), 1.0 / (aZoom[1]) + (aoffs[1]), aoffs[1]) end; _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal