Problems creating WebGl uniform from array

Asked by Johan Axelsson

Hi,
I have a vector that has a std::array as base class and have some problem with cheerp::MakeTypedArray

This code produce an error:
     mpGL->uniform4fv(muColor, cheerp::MakeTypedArray(mClrSrf.data()));

This code works fine:
    mpGL->uniform4f(muColor, mClrSrf[0],mClrSrf[1],mClrSrf[2],mClrSrf[3]);

Regards Johan

Question information

Language:
English Edit question
Status:
Solved
For:
Cheerp Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Alessandro Pignotti (a-pignotti) said :
#1

What error is particular is generated? Is it a compile time or run time error?

Revision history for this message
Johan Axelsson (johan-axelsson) said :
#2

Hi Alessandro,
it generate WebGl error no. 1282, and the vertex shader reverts to white
color for Everything.

Regards Johan

--
JA MarinTech
Johan Axelsson
M.Sc. Naval Architect
http://www.marintech.se

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken

On 2017-03-04 11:52, Alessandro Pignotti wrote:
> Your question #525419 on Cheerp changed:
> https://answers.launchpad.net/cheerp/+question/525419
>
> Alessandro Pignotti posted a new comment:
> What error is particular is generated? Is it a compile time or run time
> error?

Revision history for this message
Alessandro Pignotti (a-pignotti) said :
#3

I would need a minimal example to understand the problem, but first try this

mpGL->uniform4fv(muColor, cheerp::MakeTypedArray(mClrSrf.data(),4*sizeof(float)));

the second parameter is the size in bytes you want to use and avoids passing extra data to the uniform call

Revision history for this message
Johan Axelsson (johan-axelsson) said :
#4

Thanks,
works perfect :/)

Regards Johan

--
JA MarinTech
Johan Axelsson
M.Sc. Naval Architect
http://www.marintech.se

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken

On 2017-03-04 12:43, Alessandro Pignotti wrote:
> Your question #525419 on Cheerp changed:
> https://answers.launchpad.net/cheerp/+question/525419
>
> Alessandro Pignotti posted a new comment:
> I would need a minimal example to understand the problem, but first try
> this
>
> mpGL->uniform4fv(muColor,
> cheerp::MakeTypedArray(mClrSrf.data(),4*sizeof(float)));
>
> the second parameter is the size in bytes you want to use and avoids
> passing extra data to the uniform call

Revision history for this message
Alessandro Pignotti (a-pignotti) said :
#5

Ok, great