[fpc-pascal] Next language feature for pas2js...
Michael Van Canneyt
michael at freepascal.org
Tue May 1 11:37:25 CEST 2018
On Tue, 1 May 2018, Ryan Joseph wrote:
>> On May 1, 2018, at 4:10 PM, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
>> In pas2js it will probably look similar to this:
>> var vertices: array of glfloat = (-0.5, 0.5, -0.5, -0.5, 0.0, -0.5);
>> var vertex_buffer: TInsertNameHere;
>> // Create a new buffer object
>> vertex_buffer = gl.createBuffer();
>> // Bind an empty array buffer to it
>> gl.bindBuffer(gl.ARRAY_BUFFER, vertex_buffer);
>> // Pass the vertices data to the buffer
>> gl.bufferData(gl.ARRAY_BUFFER, Float32Array.new(vertices), gl.STATIC_DRAW);
>> // Unbind the buffer
>> gl.bindBuffer(gl.ARRAY_BUFFER, nil);
> Strange they renamed glGenBuffers to createBuffer().
> That aside though not having records is a problem I imagine. They don’t exist in JS right, so how do they deal with that? I guess you could pack a record into an array literal if all the types were the same. Arrays of arrays in literals works also.
> can’t we do that? We’re at the mercy of Float32Array.new packing that though or we need another method. What a waste of processing to convert that. That would be a nightmare for real applications to iterate all the verticies like that every time they were copied to the GPU.
What's wrong with the above code ?
It obviously works well enough, otherwise they wouldn't have made the API so.
I assume the webgl creators decided it has the optimal layout for their
More information about the fpc-pascal