Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Translation matrix

This topic is 2807 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am developing on android and I have encountered one problem. In opengl documentation it says, that matrices are in column-major order and translation matrix looks like this:
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
But in my program I use method like this:
[source] public static final float[] translation(float x, float y, float z) {
// 4x4 translation matrix.
return new float[] {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
x, y, z, 1.0f,
And it works until I try to change x, y, z position to last column.
Does this have to do with the fact that I use 1D array and not 2D? Does each row in this array represents a column when passed to opengl methods?

Thank you,

Share this post

Link to post
Share on other sites
You can use row major in your own code if you want - absolutely nothing to stop you. What's important is that you're consistent (otherwise you'll risk confusing yourself) and that you transpose the matrix to column-major before sending it to OpenGL. Yes, that's a few extra operation, but it's something you should be doing relatively few times per frame, so any performance impact will be down in the noise.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!