Results 1 to 4 of 4

Thread: Simple question

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2015
    Posts
    17

    Question Simple question

    Why in GLSL language doing this:

    // position = vec2;
    // trans = mat4;


    gl_Position = trans * vec4(position, 0.0, 1.0);

    is different from:

    gl_Position = vec4(position, 0.0, 1.0) * trans;

  2. #2
    Junior Member Newbie IonutCava's Avatar
    Join Date
    May 2012
    Location
    Bristol, U.K.
    Posts
    27
    Because maths get in the way

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2015
    Posts
    296
    Quote Originally Posted by JohnnyKPL View Post
    Why in GLSL language doing this:

    // position = vec2;
    // trans = mat4;


    gl_Position = trans * vec4(position, 0.0, 1.0);

    is different from:

    gl_Position = vec4(position, 0.0, 1.0) * trans;
    This is quit basic math algorithm. the first is correct.
    vec4 needs 4 elments, but position has only two, thus, you have to add two, 0 and 1. you can also make them 3,6; 2,9 etc. generally the last one makes one.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Sep 2013
    Posts
    186
    Because multiplication with matrices is not commutative. Do internet research on commutativity and matrices and you may learn more.

Similar Threads

  1. simple question
    By technologist in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-04-2017, 11:57 AM
  2. hello! A simple question
    By yxyybbs in forum OpenSL ES
    Replies: 1
    Last Post: 07-19-2011, 09:03 AM
  3. new to GL simple question
    By idunno in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-10-2005, 02:18 AM
  4. A simple question
    By thunder2001 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-16-2004, 11:52 PM
  5. one more simple question
    By newmannium in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-22-2001, 06:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean