0

I've been running into a problem with a 3D engine I've been working on. The translation applied by the transformation matrix isn't correct, and frankly, I have no idea why.

The transformation matrix I am using:

{ 1f, 0, 0, 0,
  0, 1f, 0, 1f,
  0, 0, 1f, 0,
  0, 0, 0, 1f }

This transformation matrix is applied to a normal cube consisting of two triangles, which then warps the edges of the cube instead of applying a translation.

Original rectangle:

Original rectangle

Warped rectangle:

Warped rectangle

P.S. Any translations on the z-axes(near/far) works properly, only the x-(left/right), and y-axes(up/down) warp the cube.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Mutt W
  • 17
  • 1
  • 5
  • That translation matrix has the correct format, which leads one to believe your problem might lie somewhere else. Please post more of your code, including how you load the transformation matrix and your rendering routine. – meowgoesthedog Jan 12 '18 at 00:08

1 Answers1

2

Im new to OpenGL, but as far as I know, matrices in OpenGL are represented using column-major matrix ordering: That means you should use the transposed transformation matrix:

{ 1f, 0, 0, 0,
  0, 1f, 0, 0,
  0, 0, 1f, 0,
  0, 1f, 0, 1f }

Source: https://stackoverflow.com/a/13294326/6163527

Gmork
  • 171
  • 1
  • 8
  • I believe you are mixing up the OpenGL convention with the DirectX convention. Source: https://www.gamedev.net/forums/topic/517446-directx-matrices-and-opengl-matrices/ – meowgoesthedog Jan 12 '18 at 00:07
  • Well, regardless... transposing the matrix worked. Thanks a bunch. – Mutt W Jan 12 '18 at 00:11
  • I am not sure about my previous wording. Changed it to the one I found in the linked source. – Gmork Jan 12 '18 at 00:12