Results 1 to 4 of 4

Thread: Chrome uniform3fv

  1. #1
    Member
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    90

    Chrome uniform3fv

    I've just noticed that the Windows dev channel for Chrome now supports WebGL, which is great news!

    Less good news is that its support for uniform3fv differs from that in Firefox, and it's not obvious which is correct. It appears to only accept proper WebGL buffer objects, not JavaScript lists (which is fair enough) but it also takes an extra size parameter.

    In more detail: in Firefox I was doing something like:

    Code :
    gl.uniform3fv(gl.getUniformLocation(shaderProgram, "uAmbientColor"), [0.5, 0.5, 0.5]);

    Now, changing it to

    Code :
    gl.uniform3fv(gl.getUniformLocation(shaderProgram, "uAmbientColor"), new WebGLFloatArray([0.5, 0.5, 0.5]));

    ...is probably an improvement anyway, so I'll update my code accordingly. However, the above still won't work on Chrome; to get it to work I need to do this:

    Code :
    gl.uniform3fv(gl.getUniformLocation(shaderProgram, "uAmbientColor"), new WebGLFloatArray([0.5, 0.5, 0.5]), 3);

    ...the last parameter being a size (as per http://www.google.com/search?ie=UTF-...form3fv+chrome). That last line works in Chrome, but unfortunately doesn't work in Firefox.

    Does anyone know which one is correct according to the latest version of the spec?


    Cheers,

    Giles

  2. #2
    Member
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    90

    Re: Chrome uniform3fv

    Thinking about it, the function's name already includes the number of items it expects in the array passed to it: uniform3fv means "set a uniform from this array of 3 floats". So I suspect Chrome's wrong. It'd be nice to know for sure, though...

  3. #3
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: Chrome uniform3fv

    As you already wrote, there is no size parameter. At least the parameter it is redundant, especially because the array does know its length. I'm sure that's a bug in Chrome.

    However, you might want to use
    Code :
    gl.uniform3f(index, x, y, z)
    instead. That should be faster, in cases where you don't an array yet.

  4. #4
    Member
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    90

    Re: Chrome uniform3fv

    Good point that the non-v version is going to be faster. It's not quite so simple in the actual code, but only one case will be made significantly messier by changing to uniform3f -- so that's what I'll do.

Similar Threads

  1. Chrome 9 to Chrome 10 Problems
    By p0pes in forum WebGL - General
    Replies: 8
    Last Post: 03-14-2011, 10:00 AM
  2. Chrome rendering
    By lordghost in forum WebGL - General
    Replies: 5
    Last Post: 01-06-2010, 03:56 AM
  3. Chrome crashing...
    By Coolcat in forum OS & Browser specific questions
    Replies: 7
    Last Post: 11-30-2009, 07:29 AM

Posting Permissions

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