[Pas2js] Random bugs and observations

Michael Van Canneyt michael at freepascal.org
Fri May 11 11:01:44 CEST 2018



On Fri, 11 May 2018, Ryan Joseph wrote:

>
>
>> On May 11, 2018, at 3:23 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>> 
>> Yes, but as said, this is probably wrong.
>> 
>>> gl.bufferData wants TJSBufferSource so shouldn’t Float32Array work? I had this problem other times with other classes. Unless polymorphism doesn’t work the same in JS...
>> 
>> Do you get a compiler error or a run-time error ?
>> 
>
> Compile time.
>
>  gl.bufferData(gl.ARRAY_BUFFER, bytes, gl.STATIC_DRAW);
>
> Incompatible type arg no. 2: Got "TJSFloat32Array", expected “TJSBufferSource"
>
>  gl.bufferData(gl.ARRAY_BUFFER, TJSBufferSource(bytes), gl.STATIC_DRAW);
>
> Incompatible type arg no. 2: Got "TJSBufferSource", expected “TJSBufferSource"
>
> My hack just so I could move on is adding a method to the class manually.
>
>    procedure bufferData_ANY(target : GLenum;  data : JSValue ; usage : GLenum); external name 'bufferData’;
>
>  gl.bufferData_ANY(gl.ARRAY_BUFFER, bytes, gl.STATIC_DRAW);

OK.

The problem was that TJSBuffersource and TJSTypedArray were defined in web.pas as well as js.pas;
So you were probably - unbeknownst to you - using 2 different types, thinking they were the same.

I have fixed this, I removed the duplicate definitions in web.pas, please
see if this fixes your problem.


Michael.


More information about the Pas2js mailing list