Results 1 to 9 of 9

Thread: glMatrix - Stupidly fast WebGL matricies

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    7

    glMatrix - Stupidly fast WebGL matricies

    I've just released a new javascript matrix library for use with WebGL called glMatrix. Though it wasn't an initial goal of the library, when all was said and done it appears to be the fastest matrix library available. (Though I would love for someone to prove me wrong on that!)

    As a first release I fully expect a random bug or two to crop up, but I'm committed to squashing them as quickly as possible. Outside of that, though, I would love any feedback on ways that this library could be improved! Please take a moment and check it out!

    Links:
    glMatrix on Google Code
    Introductory blog post
    Live Benchmark (It takes a moment to run, be patient...)

  2. #2

    Re: glMatrix - Stupidly fast WebGL matricies

    Thank you for sharing - implemented + works nice

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    4

    Re: glMatrix - Stupidly fast WebGL matricies

    hi, looks promising!
    is there some docs, because the code is hard to read?

    the tojicode blog does not work at the moment..

  4. #4

    Re: glMatrix - Stupidly fast WebGL matricies

    Quote Originally Posted by m.sirin
    is there some docs, because the code is hard to read?
    Hi, I think you are looking for this one (glmatrix project page - google code)

  5. #5
    Junior Member
    Join Date
    Jul 2010
    Posts
    4

    Re: glMatrix - Stupidly fast WebGL matricies

    yes , thank you!

  6. #6
    Junior Member
    Join Date
    Jun 2010
    Posts
    7

    Re: glMatrix - Stupidly fast WebGL matricies

    Quote Originally Posted by m.sirin
    the tojicode blog does not work at the moment..
    Yeah, I'm switching hosts (again) and having some DNS problems. May take a bit to get working, sorry!

  7. #7
    Junior Member
    Join Date
    Oct 2010
    Posts
    3

    Re: glMatrix - Stupidly fast WebGL matricies

    good work thanks for that!

    i will try the ortho function !

  8. #8
    Junior Member
    Join Date
    Nov 2010
    Posts
    4

    Re: glMatrix - Stupidly fast WebGL matricies

    You are doing something in your functions which is very unsafe. You are using

    Code :
    if(!dest) { dest = mat; }

    This is very bad because users won't expect that input matrix to be changed inside the function. For example:

    Code :
    var m1 = mat4.create(...);
    var m2 = mat4.create(...);
    var m3 = mat4.multiply(m1, m2);
    var m4 = mat4.multiply(m1, m3); // will not work as expected since m1 is changed

    Users will expect m1 to still have the value it had before the previous line, however m1 and m3 now point to the same object. This should not be the default behavior, and no parameters other than dest should be modified inside the function.

    If the user wanted to explicitly use m1 to store the final value he could simply have done:

    Code :
    mat4.multiply(m1, m2, m1);

    This way it's much clearer what he meant to do. It also makes the objects themselves behave as if they were immutable in some sense, since they are never modified inside the functions unless explicitly told to. No functionality or performance is lost, and it should make for a much safer coding practice. The solution is simple, instead of setting "dest = mat;" (or equivalent) it should set it to "mat4.create();" (or equivalent)

    The affected functions include (but may not be limited to): vec3.negate(), vec3.normalize(), vec3.cross(), vec3.direction(), mat4.inverse(), mat4.multiply(), mat4.multiplyVec3(), mat4.multiplyVec4(), mat4.rotate(), mat4.rotateX(), mat4.rotateY(), mat4.rotateZ(), quat4.normalize(), quat4.multiply(), quat4.multiplyVec3().

  9. #9
    Junior Member
    Join Date
    Dec 2009
    Posts
    8

    Re: glMatrix - Stupidly fast WebGL matricies

    For all functions following this format the operation will be applied to the values in srcMatrix and the result will be written into destMatrix, which will also be returned. If destMatrix is not specified the result will be written into srcMatrix, if destMatrix is specified srcMatrix will not be altered.
    This is out of the wiki of glmatrix

Similar Threads

  1. WebGl Extension ImagKHR for fast video texture mapping
    By WilliamGL in forum WebGL - General
    Replies: 0
    Last Post: 03-20-2012, 04:15 AM
  2. Fast array initialization
    By nachovall in forum OpenCL
    Replies: 4
    Last Post: 03-16-2011, 12:15 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
  •