Khronos.org Message Boards

Public discussions about the Khronos Dynamic Media APIs
It is currently Thu Sep 02, 2010 7:35 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Chrome uniform3fv
PostPosted: Tue Nov 17, 2009 7:03 am 
Offline

Joined: Thu Oct 22, 2009 12:04 pm
Posts: 86
Location: London, UK
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-8&oe=UTF-8&sourceid=navclient&gfns=1&q=uniform3fv+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

_________________
http://learningwebgl.com/


Top
 Profile E-mail  
 
 Post subject: Re: Chrome uniform3fv
PostPosted: Tue Nov 17, 2009 8:50 am 
Offline

Joined: Thu Oct 22, 2009 12:04 pm
Posts: 86
Location: London, UK
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...

_________________
http://learningwebgl.com/


Top
 Profile E-mail  
 
 Post subject: Re: Chrome uniform3fv
PostPosted: Tue Nov 17, 2009 9:47 am 
Offline
User avatar

Joined: Mon Oct 26, 2009 9:42 am
Posts: 75
Location: NRW, Germany
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.


Top
 Profile E-mail  
 
 Post subject: Re: Chrome uniform3fv
PostPosted: Tue Nov 17, 2009 12:15 pm 
Offline

Joined: Thu Oct 22, 2009 12:04 pm
Posts: 86
Location: London, UK
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.

_________________
http://learningwebgl.com/


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group