Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: matrices in c

  1. #1
    Intern Contributor
    Join Date
    Jun 2013
    Posts
    69

    matrices in c

    hi, i am trying to modify the position of an object using matrices. i define a matrix like this:
    GLfloat matrix[] = {1, 0, 0, .25, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};

    i then set the uniform matrix value using glUniformMatrix4fv(matrixloc, 1, GL_FALSE, matrix);

    when i multiply the matrix by the vector in the vertex shader (gl_Position = Matrix * Vector) (my vector has a 1 in the w value) it doesnt draw the triangle. whats going on?

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by sandbucket View Post
    hi, i am trying to modify the position of an object using matrices. i define a matrix like this:
    GLfloat matrix[] = {1, 0, 0, .25, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};

    i then set the uniform matrix value using glUniformMatrix4fv(matrixloc, 1, GL_FALSE, matrix);
    If that's supposed to be equivalent to glTranslatef(0.25, 0, 0), then you need to pass GL_TRUE as the transpose parameter (or transpose the matrix itself).

    By default, OpenGL assumes that matrices are in column-major order, so the 0.25 will be on the bottom row of the left-most column. For a translation, the X component should be in the top row of the right-most column.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •