-1

I am trying to build a modelview matrix for a project using OpenTK's Matrix4 class. I am trying to build a translation matrix, but the matrix keeps setting random values. Here is a screenshot of the console: Console dump

And here is the code im using to build it:

private static Matrix4 CreateModelview(Rectangle dst)
        {
            var scale = Matrix4.CreateScale(dst.Size.X, dst.Size.Y, 1.0f);
            var translation = new Matrix4();

            translation[0, 0] = 1f;
            translation[1, 1] = 1f;
            translation[2, 2] = 1f;
            translation[3, 3] = 1f;
            translation[3, 0] = dst.Position.X;
            translation[3, 1] = dst.Position.Y;
            translation[0, 3] = 0f;
            translation[1, 3] = 0f;

            Console.WriteLine("Translation:");
            Console.WriteLine(translation);
            Console.WriteLine();
            Console.WriteLine("Scale:");
            Console.WriteLine(scale);
            Console.WriteLine();
            var modelview = scale * translation;

            return modelview;
        }

I tried the build in static function Matrix4f.CreateTranslation with the same result.

B0nde
  • 143
  • 1
  • 10

1 Answers1

0

I just solved it myself, it was a combination of me flipping rows and columns and uploading it wrong to my uniform buffer.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
B0nde
  • 143
  • 1
  • 10