[fpc-pascal] pas2js Webgl unit committed

Michael Van Canneyt michael at freepascal.org
Tue May 1 18:04:53 CEST 2018



On Tue, 1 May 2018, Ryan Joseph wrote:

>
>
>> On May 1, 2018, at 9:56 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>> 
>> You must do
>>  gl := TJSWebGLRenderingContext(canvas.getContext('webgl'));
>> 
>> because getContext can return various classes depending on the argument.
>
> Ok so getContext is method of TJSElement I guess.

Only of the canvas element, I think. Hence my typecast for the canvas
element as well.

>
> Btw I’ve been reading and I don’t see WebGL examples using interlaced
> vertex data like I suggested in my record question.  Rather they all seem
> to be using different buffer objects for each type of vertex attribute
> (position, color, texture coord etc…).
>
> Can anyone confirm WebGL just doesn’t support this?  OpenGL heavily relies
> on the idea of pointers with byte offsets but perhaps JavaScript just
> can’t support that so they opted for 0-offset single type arrays in all
> cases.  That would be too bad though since it makes laying out data more
> difficult.

Javascript does not have concepts like offsets, memory buffers and whatnot.
These are very low-level concepts, and they do not apply in Javascript.
I suspect the WebGL api tries to hide such things from the user.

It's a limited browser environment, running on wildly different platforms, 
so you cannot expect it to support everything the native environment
supports...

Michael.


More information about the fpc-pascal mailing list