[fpc-pascal] Next language feature for pas2js...

Ryan Joseph ryan at thealchemistguild.com
Tue May 1 11:27:58 CEST 2018



> 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;
> begin
>  // 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);
> end;
> 

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.

verts: array[0..2] of TVec2f; // var arr = [[0,0],[0,0],[0,0]]



Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list