Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-16 Thread Joost van der Sluis

Op 09-05-18 om 03:41 schreef Ryan Joseph:

Ok it finally worked. The fpmake.pp file 
athttps://svn.freepascal.org/svn/projects/pas2js/trunk  was totally different 
than the one in the compiler sources.

May I suggest you put these instructions at the top level of the wiki? It’s 
pretty easy but I wasn’t able to build it for literally days and could have 
easily given up.

Something like that would have been really helpful:


It took more time then I thought, but finally got it working.

I've added a fppkg-repository for fpc-version 3.0.4 to fpc.cnoc.nl. And 
added a recent version of utils-pas2js. (Which is the actual 
package-name of pas2js)


In principle this means that you can install pas2js with the following 
command-line:


fppkg install utils-pas2js

Then the pas2js binary will be in ~/.fppkg/bin/pas2js.

There are a few buts, though:
- You need a valid fppkg-configuration
- You need to set in your fppkg.cfg:
RemoteMirrors=http://fpc.cnoc.nl/repo/testing/mirrors.xml
- Fppkg wil not automatically update packages, but you need
  updated versions of fcl-web, fcl-js and fcl-passrc. This means
  you have to update them manually:
fppkg install fcl-js fcl-passrc fcl-web
- Fppkg version 3.0.4 has an irritating bug that it can get into an
  infinite loop. When this happens, kill it (ctrl-c) and run
fppkg fixbroken
  until it does not happen anymore.

I've only tested it on my own system, so there might be issues but just 
ask, see if I can help.


Regards,

Joost

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Michael Van Canneyt



On Wed, 9 May 2018, Ryan Joseph wrote:





On May 9, 2018, at 1:46 PM, Ryan Joseph  wrote:

Ok got it working now finally. Now I need to learn how to do anything at all 
besides writeln. :)


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?


What do you mean by this ? "long strings in pascal aren't great".

What do you want to achieve ?



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


You can use static arrays.



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


var
  a : TJSFloat32Array;

begin
  a:=TJSFloat32Array(TJSFloat32Array.From(something))
end;

I will see about introducing some things to make this easier.



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?


Yes. Note that if they return JSValue, it means that the return type can
also be different from string.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Mattias Gaertner
On Wed, 9 May 2018 15:42:41 +0700
Ryan Joseph  wrote:

>[...] > On May 9, 2018, at 1:46 PM, Ryan Joseph  
>wrote:
> > 
> > Ok got it working now finally. Now I need to learn how to do anything at 
> > all besides writeln. :)  
> 
> Finally got a context open and working. Next things:

These questions are better asked on the pas2js mailing list:
http://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Ryan Joseph


> On May 9, 2018, at 1:46 PM, Ryan Joseph  wrote:
> 
> Ok got it working now finally. Now I need to learn how to do anything at all 
> besides writeln. :)

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

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Michael Van Canneyt



On Wed, 9 May 2018, Ryan Joseph wrote:





On May 9, 2018, at 1:25 PM, Mattias Gaertner  wrote:

The -Ji option searches in the unit search path. In the svn the rtl.js
is only in "compiler/utils/pas2js/dist/rtl.js". So you need to add a
-Fu.
In the release it is in "packages/rtl/rtl.js" as well, so it can be
found without an extra -Fu.


Ok got it working now finally. Now I need to learn how to do anything at all 
besides writeln. :)

1) can the script output the required .html file also? I don’t see the reason 
do this manually each time


No. The IDE does this for you, ij you install the pas2js_dsgn package.

The compiler just compiles. No more, no less.


2) 1200 lines for a 1 line hello world program? Seems a little steep so maybe I 
did something wrong?


See the FAQ section in the WIKI :)

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Ryan Joseph


> On May 9, 2018, at 1:25 PM, Mattias Gaertner  
> wrote:
> 
> The -Ji option searches in the unit search path. In the svn the rtl.js
> is only in "compiler/utils/pas2js/dist/rtl.js". So you need to add a
> -Fu.
> In the release it is in "packages/rtl/rtl.js" as well, so it can be
> found without an extra -Fu.

Ok got it working now finally. Now I need to learn how to do anything at all 
besides writeln. :)

1) can the script output the required .html file also? I don’t see the reason 
do this manually each time
2) 1200 lines for a 1 line hello world program? Seems a little steep so maybe I 
did something wrong?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Michael Van Canneyt



On Wed, 9 May 2018, Ryan Joseph wrote:





On May 9, 2018, at 1:20 PM, Michael Van Canneyt  wrote:

Where is the rtl.js file ? is it in /Developer/pas2js/packages/rtl ? it
should be in one of the directories specified with -Fu.


I misunderstood the wiki I guess. I thought that command was supposed to 
generate the file for you. It’s just a little auxiliary file we need with every 
.html file generated right?


Yes. It contains some basic functionality that the compiler relies on.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Ryan Joseph


> On May 9, 2018, at 1:20 PM, Michael Van Canneyt  
> wrote:
> 
> Where is the rtl.js file ? is it in /Developer/pas2js/packages/rtl ? it
> should be in one of the directories specified with -Fu.

I misunderstood the wiki I guess. I thought that command was supposed to 
generate the file for you. It’s just a little auxiliary file we need with every 
.html file generated right?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Mattias Gaertner
On Wed, 9 May 2018 09:03:29 +0700
Ryan Joseph  wrote:

> > On May 9, 2018, at 8:41 AM, Ryan Joseph  wrote:
> > 
> > Ok it finally worked.  
> 
> Making progress but the wiki is incomplete I think. I figured out how to add 
> the rtl with -Fu but I’m getting an error. What’s wrong with that name? Can 
> you show an example of a working command line?
> 
> ./pas2js -Jc -Jirtl.js -Tbrowser -Fu/Developer/pas2js/packages/rtl 
> /Users/ryanjoseph/Downloads/hello.pas
> Fatal: Compilation aborted
> invalid custom JS file name "rtl.js"

It means file not found. I will change the error message.

The -Ji option searches in the unit search path. In the svn the rtl.js
is only in "compiler/utils/pas2js/dist/rtl.js". So you need to add a
-Fu.
In the release it is in "packages/rtl/rtl.js" as well, so it can be
found without an extra -Fu.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-09 Thread Michael Van Canneyt



On Wed, 9 May 2018, Ryan Joseph wrote:





On May 9, 2018, at 8:41 AM, Ryan Joseph  wrote:

Ok it finally worked.


Making progress but the wiki is incomplete I think. I figured out how to add 
the rtl with -Fu but I’m getting an error. What’s wrong with that name? Can you 
show an example of a working command line?

./pas2js -Jc -Jirtl.js -Tbrowser -Fu/Developer/pas2js/packages/rtl 
/Users/ryanjoseph/Downloads/hello.pas


The above should be fine. It may be easier to use a config file, though.


Fatal: Compilation aborted
invalid custom JS file name "rtl.js"


Where is the rtl.js file ? is it in /Developer/pas2js/packages/rtl ? it
should be in one of the directories specified with -Fu.

my .pas2js.cfg config file contains the following:
-Fu/home/michael/projects/pas2js/packages/rtl
-Fu/home/michael/projects/pas2js/packages/*

And I have symlinked rtl.js (available in compiler/utils/pas2js/dist/)
in directory /home/michael/projects/pas2js/packages/rtl, so the compiler
will always find it.


Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-08 Thread Ryan Joseph


> On May 9, 2018, at 8:41 AM, Ryan Joseph  wrote:
> 
> Ok it finally worked.

Making progress but the wiki is incomplete I think. I figured out how to add 
the rtl with -Fu but I’m getting an error. What’s wrong with that name? Can you 
show an example of a working command line?

./pas2js -Jc -Jirtl.js -Tbrowser -Fu/Developer/pas2js/packages/rtl 
/Users/ryanjoseph/Downloads/hello.pas
Fatal: Compilation aborted
invalid custom JS file name "rtl.js"

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-08 Thread Ryan Joseph


> On May 8, 2018, at 6:47 PM, Michael Van Canneyt  
> wrote:
> 
> Do a checkout of the pas2js repo, and in the toplevel fpmake.pp, remove the
> line with AddLibrary.

Ok it finally worked. The fpmake.pp file at 
https://svn.freepascal.org/svn/projects/pas2js/trunk was totally different than 
the one in the compiler sources.

May I suggest you put these instructions at the top level of the wiki? It’s 
pretty easy but I wasn’t able to build it for literally days and could have 
easily given up.

Something like that would have been really helpful:

1) svn co https://svn.freepascal.org/svn/projects/pas2js/trunk
2) cd trunk (or rename to pas2js)
3) modify fpmake.pp as explained
4) make all

What did I lose removing AddLibrary btw?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-08 Thread Michael Van Canneyt



On Tue, 8 May 2018, Ryan Joseph wrote:


You mean this line: PT:=P.Targets.AddLibrary('pas2jslib.pp’);?


Yes.



I removed that line but if I do a “make all” in the /utils/pas2js directory I 
still get this error. I remember getting this in the past before and doing a 
clean install seem to fix it but not this time. The file system.ppu is the 
culprit but that was built from the original make all on the top directory.



Yes, but do not do this in the utils/pas2js directory.

Do a checkout of the pas2js repo, and in the toplevel fpmake.pp, remove the
line with AddLibrary.


Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-08 Thread Ryan Joseph
You mean this line: PT:=P.Targets.AddLibrary('pas2jslib.pp’);?

I removed that line but if I do a “make all” in the /utils/pas2js directory I 
still get this error. I remember getting this in the past before and doing a 
clean install seem to fix it but not this time. The file system.ppu is the 
culprit but that was built from the original make all on the top directory.

/usr/local/bin/ppc386 fpmake.pp -n -Fu../../rtl/units/i386-darwin 
-Fu../../packages/paszlib/units/i386-darwin 
-Fu../../packages/fcl-process/units/i386-darwin 
-Fu../../packages/hash/units/i386-darwin 
-Fu../../packages/libtar/units/i386-darwin 
-Fu../../packages/fpmkunit/units/i386-darwin  
PPU Loading /Developer/ObjectivePascal/fpc/rtl/units/i386-darwin/system.ppu
PPU Invalid Version 200
Fatal: Can't find unit system used by fpmake
Fatal: Compilation aborted


> On May 8, 2018, at 12:55 PM, Michael Van Canneyt  
> wrote:
> 
> IMO the simplest solution for you is to use the pas2js repo:
> 
> Remove the line in fpMake.pp that adds the library. Run make all.
> 
> You will not have the library version of the compiler, but the rest should
> be compiled: command-line compiler and web compiler.
> 
> Michael.

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-07 Thread Michael Van Canneyt


IMO the simplest solution for you is to use the pas2js repo:

Remove the line in fpMake.pp that adds the library. 
Run make all.


You will not have the library version of the compiler, but the rest should
be compiled: command-line compiler and web compiler.

Michael.

On Tue, 8 May 2018, Ryan Joseph wrote:


Are there any other ideas I could try to get this working? No idea why the PPU 
version is wrong after a totally clean build (i.e. trashed the entire directory 
and recompiled). If another Mac user has a binary they could upload that would 
be nice also.


On May 4, 2018, at 8:41 AM, Ryan Joseph  wrote:

Is this a Mac problem I’m having? I downloaded new sources, did a make all in 
the top level and make all again in pas2js. The last few lines are the make all 
for the compiler which ends without error then I cd to /utils/pas2js and make 
all again. Same error on the invalid PPU.

[100%] Compiled package utils-unicode
/bin/echo Build > build-stamp.i386-darwin
/bin/echo Build > base.build-stamp.i386-darwin
Ryans-MacBook-Pro:fpc ryanjoseph$ cd /Developer/ObjectivePascal/fpc/utils/pas2js 
Ryans-MacBook-Pro:pas2js ryanjoseph$ make all
/usr/local/bin/ppc386 fpmake.pp -n -Fu../../rtl/units/i386-darwin -Fu../../packages/paszlib/units/i386-darwin -Fu../../packages/fcl-process/units/i386-darwin -Fu../../packages/hash/units/i386-darwin -Fu../../packages/libtar/units/i386-darwin -Fu../../packages/fpmkunit/units/i386-darwin 
PPU Loading /Developer/ObjectivePascal/fpc/rtl/units/i386-darwin/system.ppu

PPU Invalid Version 200
Fatal: Can't find unit system used by fpmake
Fatal: Compilation aborted
make: *** [fpmake] Error 1


Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-07 Thread Ryan Joseph
Are there any other ideas I could try to get this working? No idea why the PPU 
version is wrong after a totally clean build (i.e. trashed the entire directory 
and recompiled). If another Mac user has a binary they could upload that would 
be nice also.

> On May 4, 2018, at 8:41 AM, Ryan Joseph  wrote:
> 
> Is this a Mac problem I’m having? I downloaded new sources, did a make all in 
> the top level and make all again in pas2js. The last few lines are the make 
> all for the compiler which ends without error then I cd to /utils/pas2js and 
> make all again. Same error on the invalid PPU.
> 
> [100%] Compiled package utils-unicode
> /bin/echo Build > build-stamp.i386-darwin
> /bin/echo Build > base.build-stamp.i386-darwin
> Ryans-MacBook-Pro:fpc ryanjoseph$ cd 
> /Developer/ObjectivePascal/fpc/utils/pas2js 
> Ryans-MacBook-Pro:pas2js ryanjoseph$ make all
> /usr/local/bin/ppc386 fpmake.pp -n -Fu../../rtl/units/i386-darwin 
> -Fu../../packages/paszlib/units/i386-darwin 
> -Fu../../packages/fcl-process/units/i386-darwin 
> -Fu../../packages/hash/units/i386-darwin 
> -Fu../../packages/libtar/units/i386-darwin 
> -Fu../../packages/fpmkunit/units/i386-darwin  
> PPU Loading /Developer/ObjectivePascal/fpc/rtl/units/i386-darwin/system.ppu
> PPU Invalid Version 200
> Fatal: Can't find unit system used by fpmake
> Fatal: Compilation aborted
> make: *** [fpmake] Error 1

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Ryan Joseph


> On May 3, 2018, at 8:26 PM, Joost van der Sluis  wrote:
> 
> Change the current directory to utils/pas2js, then do 'make all'.

That’s what I tried first but was told to do it on the top level directory.

There’s the error I get. Maybe I need to trash entire directory and start fresh?

Ryans-MacBook-Pro:pas2js ryanjoseph$ make all
/usr/local/bin/ppc386 fpmake.pp -n -Fu../../rtl/units/i386-darwin 
-Fu../../packages/paszlib/units/i386-darwin 
-Fu../../packages/fcl-process/units/i386-darwin 
-Fu../../packages/hash/units/i386-darwin 
-Fu../../packages/libtar/units/i386-darwin 
-Fu../../packages/fpmkunit/units/i386-darwin  
PPU Loading /Developer/ObjectivePascal/fpc/rtl/units/i386-darwin/system.ppu
PPU Invalid Version 200
Fatal: Can't find unit system used by fpmake
Fatal: Compilation aborted
make: *** [fpmake] Error 1

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Michael Van Canneyt



On Thu, 3 May 2018, Ryan Joseph wrote:





On May 3, 2018, at 8:23 PM, Joost van der Sluis  wrote:

Actually this makes no sense at all. Pas2js is a separate product that we 
should be able to distribute separately from the compiler.


But doesn’t it extend the existing compiler to gain access to the parser?


No. It uses the parser from the documentation generator.

That is why it includes the fcl-passrc etc. packages from trunk through
svn:external links.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Michael Van Canneyt



On Thu, 3 May 2018, Joost van der Sluis wrote:


Op 02-05-18 om 11:28 schreef Ryan Joseph:
So I need to build the entire compiler and I get pas2js in the end? I 
didn’t realize it was built on the entire FPC compiler but I guess that makes 
sense.


Actually this makes no sense at all. Pas2js is a separate product that 
we should be able to distribute separately from the compiler.


We do so, Mattias always posts an announcement with a link to the
latest version.



I'm working on a solution. I have it even finished, but only for 
fpc-trunk. I thought it would be better to let it gain momentum before 
porting it to fpc 3.0.4, but now you convinced me that adding it to 
3.0.4 also could help gaining momentum.


You can perfectly build it with 3.0.4, just as you can build fpReport with 
3.0.4 and
quite some other things.

The problem is just 1 call: a missing addLibrary in 3.0.4, which prevents
fpmake.pp from compiling.

Copying fpmkunit from trunk would also have done the job.

That said, making it even more easy to compile/install it is a welcome 
improvement.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Ryan Joseph


> On May 3, 2018, at 8:23 PM, Joost van der Sluis  wrote:
> 
> Actually this makes no sense at all. Pas2js is a separate product that we 
> should be able to distribute separately from the compiler.

But doesn’t it extend the existing compiler to gain access to the parser?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Joost van der Sluis

Op 03-05-18 om 11:00 schreef Ryan Joseph:

A "make all" in the top level directory should suffice (yes, that will build 
all of FPC, but that is at least more or less guaranteed to work). You can then pick the 
pas2js binary from the utils/pas2js/bin directory.


Make all built the compiler but I didn’t get a /bin directory in pas2js for 
some reason. I tried using “make clean” and tried again but still nothing. Any 
ideas?


Seems like it that pas2js is not included in a default build.

Change the current directory to utils/pas2js, then do 'make all'.

Regards,

Joost.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Joost van der Sluis

Op 02-05-18 om 11:28 schreef Ryan Joseph:

So I need to build the entire compiler and I get pas2js in the end? I didn’t 
realize it was built on the entire FPC compiler but I guess that makes sense.


Actually this makes no sense at all. Pas2js is a separate product that 
we should be able to distribute separately from the compiler.


I'm working on a solution. I have it even finished, but only for 
fpc-trunk. I thought it would be better to let it gain momentum before 
porting it to fpc 3.0.4, but now you convinced me that adding it to 
3.0.4 also could help gaining momentum.


I hope I can finish it for fpc 3.0.4 in a few days. Then you can simply 
install the latest pas2js version, without having to update the whole of 
FPC.


Regards,

Joost.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Ryan Joseph


> On May 3, 2018, at 12:53 PM, Sven Barth via fpc-pascal 
>  wrote:
> 
> A "make all" in the top level directory should suffice (yes, that will build 
> all of FPC, but that is at least more or less guaranteed to work). You can 
> then pick the pas2js binary from the utils/pas2js/bin directory. 
> 

Make all built the compiler but I didn’t get a /bin directory in pas2js for 
some reason. I tried using “make clean” and tried again but still nothing. Any 
ideas?

Ryans-MacBook-Pro:pas2js ryanjoseph$ ls 
/Developer/ObjectivePascal/fpc/utils/pas2js
Makefiledocspas2js.pp
Makefile.fpcfpmake.lpi  pas2jslib.lpi
compileserver.lpi   fpmake.pp   pas2jslib.pp
compileserver.pphttpcompiler.pp samples
dirwatch.pp pas2js.cfg
distpas2js.lpi


Start compiling package pastojs for target i386-darwin.
   Compiling pastojs/src/fppas2js.pp
   Compiling pastojs/src/fppjssrcmap.pp
   Compiling pastojs/src/pas2jsfilecache.pp
   Compiling pastojs/src/pas2jslogger.pp
   Compiling pastojs/src/pas2jsfileutils.pp
   Compiling pastojs/src/pas2jsfiler.pp
   Compiling pastojs/src/pas2jspparser.pp
   Compiling pastojs/src/pas2jscompiler.pp
   Compiling pastojs/src/pas2jslibcompiler.pp
[ 96%] Compiled package pastojs


Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Michael Van Canneyt



On Thu, 3 May 2018, Ryan Joseph wrote:





On May 3, 2018, at 12:53 PM, Sven Barth via fpc-pascal 
 wrote:

A "make all" in the top level directory should suffice (yes, that will build all of FPC, but that is at least more or less guaranteed to work). You can then pick the pas2js binary from the utils/pas2js/bin directory. 



where will that output the actual compiler to since I’m building everything 
now? I’d like to not override any existing installations if possible.


Nothing will be overridden as long as you do not run 'make install'

utils/pas2js/bin will contain the binaries.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-03 Thread Ryan Joseph


> On May 3, 2018, at 12:53 PM, Sven Barth via fpc-pascal 
>  wrote:
> 
> A "make all" in the top level directory should suffice (yes, that will build 
> all of FPC, but that is at least more or less guaranteed to work). You can 
> then pick the pas2js binary from the utils/pas2js/bin directory. 
> 

where will that output the actual compiler to since I’m building everything 
now? I’d like to not override any existing installations if possible.

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Sven Barth via fpc-pascal
Ryan Joseph  schrieb am Do., 3. Mai 2018, 04:54:

> Can someone put a simple guide to building on the wiki? I tried to build
> from my existing FPC sources and got this error. I never got UNIX down well
> so I don’t know what else I’m supposed to do besides cd to the directory
> and use the “make” command. Uploading a stable binary would be nice also
> but I’m on Mac so maybe only Ingemar has built this before.
>
> Ryans-MacBook-Pro:pas2js ryanjoseph$ make
> /usr/local/bin/ppc386 fpmake.pp -n -Fu../../rtl/units/i386-darwin
> -Fu../../packages/paszlib -Fu../../packages/fcl-process
> -Fu../../packages/hash -Fu../../packages/libtar
> -Fu../../packages/fpmkunit/units_bs/i386-darwin
> PPU Loading /Developer/ObjectivePascal/fpc/rtl/units/i386-darwin/system.ppu
> PPU Invalid Version 196
> Fatal: Can't find unit system used by fpmake
> Fatal: Compilation aborted
> make: *** [fpmake] Error 1
>

A "make all" in the top level directory should suffice (yes, that will
build all of FPC, but that is at least more or less guaranteed to work).
You can then pick the pas2js binary from the utils/pas2js/bin directory.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Ryan Joseph
Can someone put a simple guide to building on the wiki? I tried to build from 
my existing FPC sources and got this error. I never got UNIX down well so I 
don’t know what else I’m supposed to do besides cd to the directory and use the 
“make” command. Uploading a stable binary would be nice also but I’m on Mac so 
maybe only Ingemar has built this before.

Ryans-MacBook-Pro:pas2js ryanjoseph$ make
/usr/local/bin/ppc386 fpmake.pp -n -Fu../../rtl/units/i386-darwin 
-Fu../../packages/paszlib -Fu../../packages/fcl-process -Fu../../packages/hash 
-Fu../../packages/libtar -Fu../../packages/fpmkunit/units_bs/i386-darwin  
PPU Loading /Developer/ObjectivePascal/fpc/rtl/units/i386-darwin/system.ppu
PPU Invalid Version 196
Fatal: Can't find unit system used by fpmake
Fatal: Compilation aborted
make: *** [fpmake] Error 1

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Ryan Joseph


> On May 2, 2018, at 11:36 PM, Sven Barth via fpc-pascal 
>  wrote:
> 
> It's "Typename = class external name 'foobar' (Basetype)", not "class 
> Typename = external name 'foobar' (Basetype)". We're not in C++ after all :P
> 
>   public
> const READ_BUFFER: nativeint;
> const UNPACK_ROW_LENGTH: nativeint;
> 
> Just in case you aren't aware of it: "const", "type" and "var" start 
> sections, even inside classes/records, so you don't need to repeat the 
> "const". Instead it is common to write "public const" and then write all 
> constant members. 
> 

Not paying attention at all yesterday going from PHP to Pascal. It’s fixed now 
and looks better but the formatting is not standard perhaps.

The .idls still had those lines I wasn’t sure what to do with so I ignored 
them. I think enums should be string types followed by constants (if that’s 
allowed by the parser).

enum WebGLPowerPreference should probably be:

type
  TWebGLPowerPreference = string;
const
  TWebGLPowerPreferenceDefault = ‘default’;
  etc…

Who knows about or’d typedefs though. better to do those by hand or dump them 
as comments.

enum WebGLPowerPreference { "default", "low-power", "high-performance" };

typedef (ImageBitmap or
 ImageData or
 HTMLImageElement or
 HTMLCanvasElement or
 HTMLVideoElement) TexImageSource;

typedef ([AllowShared] Float32Array or sequence) Float32List;
typedef ([AllowShared] Int32Array or sequence) Int32List;

==

unit webgl2;

{$mode objfpc}
{$modeswitch externalclass}

interface
uses
  JS, Web;

  type
GLint64 = nativeint;
GLuint64 = longword;
  type
TJSWebGLQuery = class external name 'WebGLQuery' (TJSWebGLObject);
TJSWebGLSampler = class external name 'WebGLSampler' (TJSWebGLObject);
TJSWebGLSync = class external name 'WebGLSync' (TJSWebGLObject);
TJSWebGLTransformFeedback = class external name 'WebGLTransformFeedback' 
(TJSWebGLObject);
TJSWebGLVertexArrayObject = class external name 'WebGLVertexArrayObject' 
(TJSWebGLObject);
  type  
TJSWebGL2RenderingContextBase = class external name 
'WebGL2RenderingContextBase' (TJSObject)
public
const
  READ_BUFFER: nativeint;
  UNPACK_ROW_LENGTH: nativeint;
  UNPACK_SKIP_ROWS: nativeint;
  UNPACK_SKIP_PIXELS: nativeint;
  PACK_ROW_LENGTH: nativeint;
  PACK_SKIP_ROWS: nativeint;
  PACK_SKIP_PIXELS: nativeint;
  COLOR: nativeint;
  DEPTH: nativeint;
  STENCIL: nativeint;
  RED: nativeint;
  RGB8: nativeint;
  RGBA8: nativeint;
  RGB10_A2: nativeint;
  TEXTURE_BINDING_3D: nativeint;
  UNPACK_SKIP_IMAGES: nativeint;
  UNPACK_IMAGE_HEIGHT: nativeint;
  TEXTURE_3D: nativeint;
  TEXTURE_WRAP_R: nativeint;
  MAX_3D_TEXTURE_SIZE: nativeint;
  UNSIGNED_INT_2_10_10_10_REV: nativeint;
  MAX_ELEMENTS_VERTICES: nativeint;
  MAX_ELEMENTS_INDICES: nativeint;
  TEXTURE_MIN_LOD: nativeint;
  TEXTURE_MAX_LOD: nativeint;
  TEXTURE_BASE_LEVEL: nativeint;
  TEXTURE_MAX_LEVEL: nativeint;
  MIN: nativeint;
  MAX: nativeint;
  DEPTH_COMPONENT24: nativeint;
  MAX_TEXTURE_LOD_BIAS: nativeint;
  TEXTURE_COMPARE_MODE: nativeint;
  TEXTURE_COMPARE_FUNC: nativeint;
  CURRENT_QUERY: nativeint;
  QUERY_RESULT: nativeint;
  QUERY_RESULT_AVAILABLE: nativeint;
  STREAM_READ: nativeint;
  STREAM_COPY: nativeint;
  STATIC_READ: nativeint;
  STATIC_COPY: nativeint;
  DYNAMIC_READ: nativeint;
  DYNAMIC_COPY: nativeint;
  MAX_DRAW_BUFFERS: nativeint;
  DRAW_BUFFER0: nativeint;
  DRAW_BUFFER1: nativeint;
  DRAW_BUFFER2: nativeint;
  DRAW_BUFFER3: nativeint;
  DRAW_BUFFER4: nativeint;
  DRAW_BUFFER5: nativeint;
  DRAW_BUFFER6: nativeint;
  DRAW_BUFFER7: nativeint;
  DRAW_BUFFER8: nativeint;
  DRAW_BUFFER9: nativeint;
  DRAW_BUFFER10: nativeint;
  DRAW_BUFFER11: nativeint;
  DRAW_BUFFER12: nativeint;
  DRAW_BUFFER13: nativeint;
  DRAW_BUFFER14: nativeint;
  DRAW_BUFFER15: nativeint;
  MAX_FRAGMENT_UNIFORM_COMPONENTS: nativeint;
  MAX_VERTEX_UNIFORM_COMPONENTS: nativeint;
  SAMPLER_3D: nativeint;
  SAMPLER_2D_SHADOW: nativeint;
  FRAGMENT_SHADER_DERIVATIVE_HINT: nativeint;
  PIXEL_PACK_BUFFER: nativeint;
  PIXEL_UNPACK_BUFFER: nativeint;
  PIXEL_PACK_BUFFER_BINDING: nativeint;
  PIXEL_UNPACK_BUFFER_BINDING: nativeint;
  FLOAT_MAT2x3: nativeint;
  FLOAT_MAT2x4: nativeint;
  FLOAT_MAT3x2: nativeint;
  FLOAT_MAT3x4: nativeint;
  FLOAT_MAT4x2: nativeint;
  FLOAT_MAT4x3: nativeint;
  SRGB: nativeint;
  SRGB8: nativeint;
  SRGB8_ALPHA8: nativeint;
  COMPARE_REF_TO_TEXTURE: nativeint;
  RGBA32F: nativeint;
  RGB32F: nativeint;
  RGBA16F: nativeint;
  RGB16F: nativeint;
  VERTEX_ATTRIB_ARRAY_INTEGER: nativeint;
  MAX_ARRAY_TEXTURE_LAYERS: nativeint;
  

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Sven Barth via fpc-pascal
Ryan Joseph  schrieb am Mi., 2. Mai 2018, 15:57:

>
>   class TJSWebGL2RenderingContextBase = external name
> 'WebGL2RenderingContextBase' (TJSObject)
>

It's "Typename = class external name 'foobar' (Basetype)", not "class
Typename = external name 'foobar' (Basetype)". We're not in C++ after all :P

  public
> const READ_BUFFER: nativeint;
> const UNPACK_ROW_LENGTH: nativeint;


Just in case you aren't aware of it: "const", "type" and "var" start
sections, even inside classes/records, so you don't need to repeat the
"const". Instead it is common to write "public const" and then write all
constant members.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Ryan Joseph


> On May 2, 2018, at 6:20 PM, Michael Van Canneyt  
> wrote:
> 
> Yes: You posted the link to 1.0.

I think it’s actually an extension to the original so nothing was lost. The 
original didn’t have vertex array objects so it’s best to have both.

https://www.khronos.org/registry/webgl/specs/latest/2.0/webgl2.idl

That’s what my parser dumps out in current state (some bugs I know). I think 
TJSWebGL2RenderingContextBase is supposed to be a subclass of the first context 
base class to make it work.

unit webgl2;

{$mode objfpc}
{$modeswitch externalclass}

interface
uses
  JS, Web;

  type GLint64 = nativeint;
  type GLuint64 = unsigned long long;
  class TJSWebGLQuery = external name 'WebGLQuery' (TJSWebGLObject);
  class TJSWebGLSampler = external name 'WebGLSampler' (TJSWebGLObject);
  class TJSWebGLSync = external name 'WebGLSync' (TJSWebGLObject);
  class TJSWebGLTransformFeedback = external name 'WebGLTransformFeedback' 
(TJSWebGLObject);
  class TJSWebGLVertexArrayObject = external name 'WebGLVertexArrayObject' 
(TJSWebGLObject);
  class TJSWebGL2RenderingContextBase = external name 
'WebGL2RenderingContextBase' (TJSObject)
  public
const READ_BUFFER: nativeint;
const UNPACK_ROW_LENGTH: nativeint;
const UNPACK_SKIP_ROWS: nativeint;
const UNPACK_SKIP_PIXELS: nativeint;
const PACK_ROW_LENGTH: nativeint;
const PACK_SKIP_ROWS: nativeint;
const PACK_SKIP_PIXELS: nativeint;
const COLOR: nativeint;
const DEPTH: nativeint;
const STENCIL: nativeint;
const RED: nativeint;
const RGB8: nativeint;
const RGBA8: nativeint;
const RGB10_A2: nativeint;
const TEXTURE_BINDING_3D: nativeint;
const UNPACK_SKIP_IMAGES: nativeint;
const UNPACK_IMAGE_HEIGHT: nativeint;
const TEXTURE_3D: nativeint;
const TEXTURE_WRAP_R: nativeint;
const MAX_3D_TEXTURE_SIZE: nativeint;
const UNSIGNED_INT_2_10_10_10_REV: nativeint;
const MAX_ELEMENTS_VERTICES: nativeint;
const MAX_ELEMENTS_INDICES: nativeint;
const TEXTURE_MIN_LOD: nativeint;
const TEXTURE_MAX_LOD: nativeint;
const TEXTURE_BASE_LEVEL: nativeint;
const TEXTURE_MAX_LEVEL: nativeint;
const MIN: nativeint;
const MAX: nativeint;
const DEPTH_COMPONENT24: nativeint;
const MAX_TEXTURE_LOD_BIAS: nativeint;
const TEXTURE_COMPARE_MODE: nativeint;
const TEXTURE_COMPARE_FUNC: nativeint;
const CURRENT_QUERY: nativeint;
const QUERY_RESULT: nativeint;
const QUERY_RESULT_AVAILABLE: nativeint;
const STREAM_READ: nativeint;
const STREAM_COPY: nativeint;
const STATIC_READ: nativeint;
const STATIC_COPY: nativeint;
const DYNAMIC_READ: nativeint;
const DYNAMIC_COPY: nativeint;
const MAX_DRAW_BUFFERS: nativeint;
const DRAW_BUFFER0: nativeint;
const DRAW_BUFFER1: nativeint;
const DRAW_BUFFER2: nativeint;
const DRAW_BUFFER3: nativeint;
const DRAW_BUFFER4: nativeint;
const DRAW_BUFFER5: nativeint;
const DRAW_BUFFER6: nativeint;
const DRAW_BUFFER7: nativeint;
const DRAW_BUFFER8: nativeint;
const DRAW_BUFFER9: nativeint;
const DRAW_BUFFER10: nativeint;
const DRAW_BUFFER11: nativeint;
const DRAW_BUFFER12: nativeint;
const DRAW_BUFFER13: nativeint;
const DRAW_BUFFER14: nativeint;
const DRAW_BUFFER15: nativeint;
const MAX_FRAGMENT_UNIFORM_COMPONENTS: nativeint;
const MAX_VERTEX_UNIFORM_COMPONENTS: nativeint;
const SAMPLER_3D: nativeint;
const SAMPLER_2D_SHADOW: nativeint;
const FRAGMENT_SHADER_DERIVATIVE_HINT: nativeint;
const PIXEL_PACK_BUFFER: nativeint;
const PIXEL_UNPACK_BUFFER: nativeint;
const PIXEL_PACK_BUFFER_BINDING: nativeint;
const PIXEL_UNPACK_BUFFER_BINDING: nativeint;
const FLOAT_MAT2x3: nativeint;
const FLOAT_MAT2x4: nativeint;
const FLOAT_MAT3x2: nativeint;
const FLOAT_MAT3x4: nativeint;
const FLOAT_MAT4x2: nativeint;
const FLOAT_MAT4x3: nativeint;
const SRGB: nativeint;
const SRGB8: nativeint;
const SRGB8_ALPHA8: nativeint;
const COMPARE_REF_TO_TEXTURE: nativeint;
const RGBA32F: nativeint;
const RGB32F: nativeint;
const RGBA16F: nativeint;
const RGB16F: nativeint;
const VERTEX_ATTRIB_ARRAY_INTEGER: nativeint;
const MAX_ARRAY_TEXTURE_LAYERS: nativeint;
const MIN_PROGRAM_TEXEL_OFFSET: nativeint;
const MAX_PROGRAM_TEXEL_OFFSET: nativeint;
const MAX_VARYING_COMPONENTS: nativeint;
const TEXTURE_2D_ARRAY: nativeint;
const TEXTURE_BINDING_2D_ARRAY: nativeint;
const R11F_G11F_B10F: nativeint;
const UNSIGNED_INT_10F_11F_11F_REV: nativeint;
const RGB9_E5: nativeint;
const UNSIGNED_INT_5_9_9_9_REV: nativeint;
const TRANSFORM_FEEDBACK_BUFFER_MODE: nativeint;
const MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: nativeint;
const TRANSFORM_FEEDBACK_VARYINGS: nativeint;
const TRANSFORM_FEEDBACK_BUFFER_START: nativeint;
const TRANSFORM_FEEDBACK_BUFFER_SIZE: nativeint;
const 

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Michael Van Canneyt



On Wed, 2 May 2018, Ryan Joseph wrote:





On May 2, 2018, at 5:28 PM, Mattias Gaertner  wrote:

What is the difference to the existing webgl.pas?


It’s missing a couple types and missing comments. :) I can fix that of course 
and works for other .idl’s also I presume (if you have any other examples send 
them and I’ll try). The current file is WebGL 1.0 but I noticed there’s a 2.0 
file also. Any reason we used 1.0?


Yes: You posted the link to 1.0.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Mattias Gaertner
On Wed, 2 May 2018 16:28:10 +0700
Ryan Joseph  wrote:

> > On May 2, 2018, at 2:08 PM, Michael Van Canneyt  
> > wrote:
> > 
> > Yes. the fpmkunit needs to be the latest version, for the AddLibrary call. 
> > I will see if I can work around it.  
> 
> So I need to build the entire compiler and I get pas2js in the end? I didn’t 
> realize it was built on the entire FPC compiler but I guess that makes sense.

pas2js can be built with the released fpc 3.0.4 too.
The problem is the fpmake files as Michael pointed out. They should be
adapted to support fpc 3.0.4.

 
> Just for fun I made a PHP script to parse that .idl file. :) Not sure if it 
> works on other files but it only took a few hours and seems to work ok. 
> Should be easy to hack with.
> 
> https://github.com/genericptr/pas2js-IDL-parser
> 
> php pas2js_idl_parser.php /Users/ryanjoseph/Downloads/webgl.idl 
> 
> 
> 
> unit webgl;

What is the difference to the existing webgl.pas?

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Ryan Joseph


> On May 2, 2018, at 2:08 PM, Michael Van Canneyt  
> wrote:
> 
> Yes. the fpmkunit needs to be the latest version, for the AddLibrary call. I 
> will see if I can work around it.

So I need to build the entire compiler and I get pas2js in the end? I didn’t 
realize it was built on the entire FPC compiler but I guess that makes sense.

Just for fun I made a PHP script to parse that .idl file. :) Not sure if it 
works on other files but it only took a few hours and seems to work ok. Should 
be easy to hack with.

https://github.com/genericptr/pas2js-IDL-parser

php pas2js_idl_parser.php /Users/ryanjoseph/Downloads/webgl.idl 



unit webgl;

{$mode objfpc}
{$modeswitch externalclass}

interface
uses
  JS, Web;

  type GLenum = cardinal;
  type GLboolean = boolean;
  type GLbitfield = cardinal;
  type GLbyte = shortint;
  type GLshort = short;
  type GLint = integer;
  type GLsizei = integer;
  type GLintptr = nativeint;
  type GLsizeiptr = nativeint;
  type GLubyte = byte;
  type GLushort = word;
  type GLuint = cardinal;
  type GLfloat = double;
  type GLclampf = double;
  class TJSWebGLContextAttributes = external name 'WebGLContextAttributes' 
(TJSObject)
  public
alpha: GLboolean;
depth: GLboolean;
stencil: GLboolean;
antialias: GLboolean;
premultipliedAlpha: GLboolean;
preserveDrawingBuffer: GLboolean;
powerPreference: WebGLPowerPreference;
failIfMajorPerformanceCaveat: GLboolean;
  end;

  class TJSWebGLObject = external name 'WebGLObject' (TJSObject);
  class TJSWebGLBuffer = external name 'WebGLBuffer' (TJSWebGLObject);
  class TJSWebGLFramebuffer = external name 'WebGLFramebuffer' (TJSWebGLObject);
  class TJSWebGLProgram = external name 'WebGLProgram' (TJSWebGLObject);
  class TJSWebGLRenderbuffer = external name 'WebGLRenderbuffer' 
(TJSWebGLObject);
  class TJSWebGLShader = external name 'WebGLShader' (TJSWebGLObject);
  class TJSWebGLTexture = external name 'WebGLTexture' (TJSWebGLObject);
  class TJSWebGLUniformLocation = external name 'WebGLUniformLocation' 
(TJSObject);
  class TJSWebGLActiveInfo = external name 'WebGLActiveInfo' (TJSObject)
  private
Fsize: GLint; external name 'size';
Ftype: GLenum; external name 'type';
Fname: DOMString; external name 'name';
  public
property size: GLint read Fsize;
property type: GLenum read Ftype;
property name: DOMString read Fname;
  end;

  class TJSWebGLShaderPrecisionFormat = external name 
'WebGLShaderPrecisionFormat' (TJSObject)
  private
FrangeMin: GLint; external name 'rangeMin';
FrangeMax: GLint; external name 'rangeMax';
Fprecision: GLint; external name 'precision';
  public
property rangeMin: GLint read FrangeMin;
property rangeMax: GLint read FrangeMax;
property precision: GLint read Fprecision;
  end;

  class TJSWebGLRenderingContextBase = external name 
'WebGLRenderingContextBase' (TJSObject)
  private
Fcanvas: HTMLCanvasElement; external name 'canvas';
FdrawingBufferWidth: GLsizei; external name 'drawingBufferWidth';
FdrawingBufferHeight: GLsizei; external name 'drawingBufferHeight';
  public
const DEPTH_BUFFER_BIT: nativeint;
const STENCIL_BUFFER_BIT: nativeint;
const COLOR_BUFFER_BIT: nativeint;
const POINTS: nativeint;
const LINES: nativeint;
const LINE_LOOP: nativeint;
const LINE_STRIP: nativeint;
const TRIANGLES: nativeint;
const TRIANGLE_STRIP: nativeint;
const TRIANGLE_FAN: nativeint;
const ZERO: nativeint;
const ONE: nativeint;
const SRC_COLOR: nativeint;
const ONE_MINUS_SRC_COLOR: nativeint;
const SRC_ALPHA: nativeint;
const ONE_MINUS_SRC_ALPHA: nativeint;
const DST_ALPHA: nativeint;
const ONE_MINUS_DST_ALPHA: nativeint;
const DST_COLOR: nativeint;
const ONE_MINUS_DST_COLOR: nativeint;
const SRC_ALPHA_SATURATE: nativeint;
const FUNC_ADD: nativeint;
const BLEND_EQUATION: nativeint;
const BLEND_EQUATION_RGB: nativeint;
const BLEND_EQUATION_ALPHA: nativeint;
const FUNC_SUBTRACT: nativeint;
const FUNC_REVERSE_SUBTRACT: nativeint;
const BLEND_DST_RGB: nativeint;
const BLEND_SRC_RGB: nativeint;
const BLEND_DST_ALPHA: nativeint;
const BLEND_SRC_ALPHA: nativeint;
const CONSTANT_COLOR: nativeint;
const ONE_MINUS_CONSTANT_COLOR: nativeint;
const CONSTANT_ALPHA: nativeint;
const ONE_MINUS_CONSTANT_ALPHA: nativeint;
const BLEND_COLOR: nativeint;
const ARRAY_BUFFER: nativeint;
const ELEMENT_ARRAY_BUFFER: nativeint;
const ARRAY_BUFFER_BINDING: nativeint;
const ELEMENT_ARRAY_BUFFER_BINDING: nativeint;
const STREAM_DRAW: nativeint;
const STATIC_DRAW: nativeint;
const DYNAMIC_DRAW: nativeint;
const BUFFER_SIZE: nativeint;
const BUFFER_USAGE: nativeint;
const CURRENT_VERTEX_ATTRIB: nativeint;
const FRONT: nativeint;
const BACK: nativeint;
const FRONT_AND_BACK: nativeint;
const CULL_FACE: nativeint;
const BLEND: 

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Michael Van Canneyt



On Wed, 2 May 2018, Ryan Joseph wrote:





On May 2, 2018, at 1:24 PM, Michael Van Canneyt  wrote:

It will only work with trunk.


trunk of what? Do mean the entire fpc sources?


Yes. the fpmkunit needs to be the latest version, for the AddLibrary call. 
I will see if I can work around it.


Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Ryan Joseph


> On May 2, 2018, at 1:24 PM, Michael Van Canneyt  
> wrote:
> 
> It will only work with trunk.

trunk of what? Do mean the entire fpc sources?

cd /Users/ryanjoseph/Downloads/pas2js 
ls
Makefilecompilerfpmake.pp   utils
Makefile.fpcdemopackages

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-02 Thread Michael Van Canneyt



On Wed, 2 May 2018, Ryan Joseph wrote:





On May 2, 2018, at 8:18 AM, Ryan Joseph  wrote:

On Mac cd’ing to the directory and using make gives this error:

/usr/local/bin/ppc386 fpmake.pp -n 
Fatal: Can't find unit system used by fpmake

Fatal: Compilation aborted
make: *** [fpmake] Error 1


Sorry that was the wrong directory. Root directory gives me this:

Ryans-MacBook-Pro:pas2js ryanjoseph$ make
make: pas2js: Command not found
/usr/local/bin/ppc386 fpmake.pp 
Free Pascal Compiler version 3.0.2 [2017/02/12] for i386

Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for i386
Compiling fpmake.pp
fpmake.pp(134,15) Error: identifier idents no member "AddLibrary"
fpmake.pp(197) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
make: *** [fpmake] Error 1


It will only work with trunk.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph


> On May 2, 2018, at 8:18 AM, Ryan Joseph  wrote:
> 
> On Mac cd’ing to the directory and using make gives this error:
> 
> /usr/local/bin/ppc386 fpmake.pp -n   
> Fatal: Can't find unit system used by fpmake
> Fatal: Compilation aborted
> make: *** [fpmake] Error 1

Sorry that was the wrong directory. Root directory gives me this:

Ryans-MacBook-Pro:pas2js ryanjoseph$ make
make: pas2js: Command not found
/usr/local/bin/ppc386 fpmake.pp   
Free Pascal Compiler version 3.0.2 [2017/02/12] for i386
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for i386
Compiling fpmake.pp
fpmake.pp(134,15) Error: identifier idents no member "AddLibrary"
fpmake.pp(197) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
make: *** [fpmake] Error 1

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph
So how do you actually build the parser? I downloaded the source but I don’t 
see a binary.

On Mac cd’ing to the directory and using make gives this error:

/usr/local/bin/ppc386 fpmake.pp -n   
Fatal: Can't find unit system used by fpmake
Fatal: Compilation aborted
make: *** [fpmake] Error 1


Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 9:56 PM, Michael Van Canneyt  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.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michalis Kamburelis
Ryan Joseph  wrote:

>
>
> > On May 1, 2018, at 9:56 PM, Michael Van Canneyt 
> 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.
>
> 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.
>

WebGL supports interleaved data, see e.g.
http://learnwebgl.brown37.net/rendering/interleaved_buffers.html .

In general, WebGL is capable of rendering e.g. glTF 2, which allows to use
interleaved data in various configurations, PBR etc. So it's quite
powerful:)

Many thanks for the WebGL unit! (I will play with it once I catch some
breath at other work :) ).

Regards,
Michalis
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 9:56 PM, Michael Van Canneyt  
> 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.

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.

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 8:28 PM, Michael Van Canneyt  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');


You must do
  gl := TJSWebGLRenderingContext(canvas.getContext('webgl'));

because getContext can return various classes depending on the argument.


 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.


createElement returns guaranteed TJSElement, but normally it will be 
TJSHTMLCanvasElement
for your call.

So
  canvas: TJSHTMLCanvasElement;

begin
  canvas:=TJSHTMLCanvasElement(document.createElement('canvas'));



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.


Yes, you need that too to insert the new element in the DOM tree.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 8:28 PM, Michael Van Canneyt  
> 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

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 15:28:45 +0200 (CEST)
Michael Van Canneyt  wrote:

>[...]
> The "new web project" wizard will make the HTML file for you, if you
> installed the pas2js_dsgn.lpk package in Lazarus. I think it is available
> with the distributed latest lazarus,

No. It was added in 1.9.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 7:49 PM, Michael Van Canneyt  wrote:

I didn't. Some Regexps in an editor did the job handsomely...


By hand. Hardcore. ;)

Because I don’t see it on the wiki can post a minimal example/template of how 
to get a canvas started?


Check the canvas demo (demo/rtl/democanvas2d.pas)



Basically I want that but it references an HTML file, do we need to make that 
in addition to the Pascal?


The "new web project" wizard will make the HTML file for you, if you
installed the pas2js_dsgn.lpk package in Lazarus. I think it is available
with the distributed latest lazarus, but you should be able to use (I think)
the trunk version of the package as well, even in an official lazarus setup.

(Mattias can confirm/deny)

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 7:49 PM, Michael Van Canneyt  
> wrote:
> 
> I didn't. Some Regexps in an editor did the job handsomely...

By hand. Hardcore. ;)

Because I don’t see it on the wiki can post a minimal example/template of how 
to get a canvas started?

Basically I want that but it references an HTML file, do we need to make that 
in addition to the Pascal? 

var canvas = document.getElementById('canvas1');
var gl = canvas.getContext('webgl');
canvas.width = newWidth;
canvas.height = newHeight;
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);


Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 7:40 PM, Michael Van Canneyt  wrote:


Hi,

See subject. Rev 83 in pas2js subversion.

I have no experience with webgl, so if someone could provide several
examples which I can include in the demo folder of pas2js, please post on
the pas2js mailing list or send them to me in private.

They would be highly appreciated.

Obviously, if you spot any errors in the import class, please let me know :)

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


How did you end up parsing it?


I didn't. Some Regexps in an editor did the job handsomely...

If you want to see some examples of parsers: look at the jsonparser (json
parsing), pparser (pascal parsing) and jsparser (Javascript) units. The
associted scanner units are really easily understood and resemble each other
closely.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 7:40 PM, Michael Van Canneyt  
> wrote:
> 
> 
> Hi,
> 
> See subject. Rev 83 in pas2js subversion.
> 
> I have no experience with webgl, so if someone could provide several
> examples which I can include in the demo folder of pas2js, please post on
> the pas2js mailing list or send them to me in private.
> 
> They would be highly appreciated.
> 
> Obviously, if you spot any errors in the import class, please let me know :)
> 
> Michael.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

How did you end up parsing it?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal