[Pas2js] pas2js Webgl unit committed

Ryan Joseph ryan at thealchemistguild.com
Wed May 9 11:34:35 CEST 2018


ok. reposted the question again here.

===================================

Finally got a context open and working. Next things:

1) what’s the best way to handle long strings? in JS they’ll loading text from divs but i’d rather do that from a file since long strings in Pascal aren’t great. How does that work?

2) what’s the deal with arrays? I saw there is array of xxx syntax for dynamic arrays. Can we use static arrays also and do they work with new Float32Array(xxx)? I guess all JS arrays are the same and I can pass them like

3) how does the syntax “new Float32Array()” translate to Pascal? There’s no generic class allocator syntax in Pascal so what do we use?

4) in functions from webgl that return strings the type is “JSValue”. How do those work with “string” in Pascal now? Maybe just typecast to string?

====

uses BrowserConsole, Web, WebGL;

const
	kWidth = 100;
	kHeight = 100;
var
 canvas: TJSHTMLCanvasElement;
 gl: TJSWebGLRenderingContext;
begin

 canvas := TJSHTMLCanvasElement(document.createElement('canvas'));
 canvas.width := kWidth;
 canvas.height := kHeight;
	document.body.appendChild(canvas);

	gl := TJSWebGLRenderingContext(canvas.getContext('webgl'));
	if gl = nil then
		begin
			writeln('failed to load webgl!');
			exit;
		end;
	gl.clearColor(1, 0, 0, 1);
	gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
	gl.clear(gl.COLOR_BUFFER_BIT);
end.
Regards,
	Ryan Joseph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20180509/16fe64e5/attachment.html>


More information about the Pas2js mailing list