[fpc-pascal] pas2js Webgl unit committed

Ryan Joseph ryan at thealchemistguild.com
Tue May 1 16:52:34 CEST 2018



> On May 1, 2018, at 8:28 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
> 
> Check the canvas demo (demo/rtl/democanvas2d.pas)

something like this?

var
  canvas: TJSElement; // What type should this be?
  gl: TJSWebGLRenderingContext;
begin
  canvas := document.createElement('canvas');
  document.body.appendChild(canvas);
  gl := canvas.getContext('webgl');
  canvas.width := newWidth;
  canvas.height := newHeight;
  gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);

Not sure about the type which createElement returns that has the getContext method. Do you need document.body.appendChild also? Sorry it’s been a long time since I used JS to do even simple things. Never knew it well.


Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list