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] Next language feature for pas2js...

2018-05-01 Thread wkitty42

On 05/01/2018 07:09 AM, Ryan Joseph wrote:

In PHP I always just load the file into string and loop over it line by line
using regex to cut out the parts I need. I like it because it’s so easy to
write and gets the job done. What ever I would make it Pascal would be 10x
larger probably.


FWIW: you can do this (line parsing) in any language that supports regex...

the size thing you speak of is the difference between scripted languages and 
compiled binary languages...


kinda makes one wonder if pascal script might be able to handle the task...


--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list unless*
   *a signed and pre-paid contract is in effect with us.*
___
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

[fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt


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

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

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 5:55 PM, Marco van de Voort  wrote:
> 
> I already stumbled on regex :_)

Anyone feel free to make a good example of a token parser in Pascal so I can 
see how it looks. I never an actual good parser that understands syntax so I 
don’t have any good examples to go by.

In PHP I always just load the file into string and loop over it line by line 
using regex to cut out the parts I need. I like it because it’s so easy to 
write and gets the job done. What ever I would make it Pascal would be 10x 
larger probably.

Regards,
Ryan Joseph

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

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

2018-05-01 Thread Marco van de Voort
In our previous episode, Michael Van Canneyt said:
> >> If you have access to the underlying API spec in the form of an IDL, then 
> >> we
> >> could make a tool that parses the IDL and dumps the API in the form of
> >> "external" declarations.
> >
> > There it is. A parser needs to be made I guess. You could chop that us 
> > pretty easily with a regex based PHP script.
> 
> You were doing great just up to the letters PHP ;-)

I already stumbled on regex :_)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 4:37 PM, Michael Van Canneyt  wrote:

What's wrong with the above code ?

It obviously works well enough, otherwise they wouldn't have made the API so.

The float32 array is a Javascript type that encapsulates a memory buffer.
I assu


It’s difficult to work with. With OpenGL what you have is a record with all the 
fields that are the data for vertex (positions, colors, normals etc…) and you 
tell OpenGL at what offset and stride the data starts. If you use to just array 
literals like that it would be very messy.

   void vertexAttribPointer(GLuint index, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, GLintptr 
offset);

That’s what I would expect not using WebGL before. Getting that down to typed 
arrays using wrapper functions would be a mess though. Ouch. No idea how that’s 
supposed to look in WebGL.

// array of TVertex 
[

 // vertex 1
 [
 [0, 0], // position (vec2f)
 [255, 255, 255], // color (vec4b)
 [0, 1], // texture coord (vec2f)
 ],

 // vertex 2
 [
 [0, 0], // position (vec2f)
 [255, 255, 255], // color (vec4b)
 [0, 1], // texture coord (vec2f)
 ],

 // vertex 3
 [
 [0, 0], // position (vec2f)
 [255, 255, 255], // color (vec4b)
 [0, 1], // texture coord (vec2f)
 ]
]

type
 TVertex = record
   pos: TVec2f;
   color: TVec4b;
   texCoord: TVec2f;
 end;

verts: array[0..2] of TVertex;

The parser could break down records into those arrays but it would be 
complicated I suspect.


I don't think we'll introduce language tricks for such things.

The WebGL people made do with what Javascript offers. 
Likewise, we make do with what pascal and Javascript offer...


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

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

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 10:52:32 +0200 (CEST)
Michael Van Canneyt  wrote:

>[...]
> > Note that the 'var' is a workaround till eventually pas2js supports
> > external 'const' without expression.  
> 
> Well, I specially did not mention this, because I consider it a dirty hack.
> a var doesn't protect you from assigning to it (it's a variable, after all).

Trunk now supports external const. :)

 
> One preferably shouldn't teach people bad habits. :)

Good point.

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

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

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 4:37 PM, Michael Van Canneyt  
> wrote:
> 
> What's wrong with the above code ?
> 
> It obviously works well enough, otherwise they wouldn't have made the API so.
> 
> The float32 array is a Javascript type that encapsulates a memory buffer.
> I assu

It’s difficult to work with. With OpenGL what you have is a record with all the 
fields that are the data for vertex (positions, colors, normals etc…) and you 
tell OpenGL at what offset and stride the data starts. If you use to just array 
literals like that it would be very messy.

void vertexAttribPointer(GLuint index, GLint size, GLenum type,
 GLboolean normalized, GLsizei stride, GLintptr 
offset);

That’s what I would expect not using WebGL before. Getting that down to typed 
arrays using wrapper functions would be a mess though. Ouch. No idea how that’s 
supposed to look in WebGL.

// array of TVertex 
[
  // vertex 1
  [
  [0, 0], // position (vec2f)
  [255, 255, 255], // color (vec4b)
  [0, 1], // texture coord (vec2f)
  ],
  
  // vertex 2
  [
  [0, 0], // position (vec2f)
  [255, 255, 255], // color (vec4b)
  [0, 1], // texture coord (vec2f)
  ],

  // vertex 3
  [
  [0, 0], // position (vec2f)
  [255, 255, 255], // color (vec4b)
  [0, 1], // texture coord (vec2f)
  ]
]

type
  TVertex = record
pos: TVec2f;
color: TVec4b;
texCoord: TVec2f;
  end;

verts: array[0..2] of TVertex;

The parser could break down records into those arrays but it would be 
complicated I suspect.

Regards,
Ryan Joseph

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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ingemar Ragnemalm wrote:



Den 2018-05-01 kl. 09:50, Ryan Joseph  wrote:
On Apr 25, 2018, at 9:43 PM, Michael Van Canneyt 
wrote:


Ah, webgl...

I had a look at this some time ago, and got depressed. Quickly closed the 
browser and didn't look back. Same for webaudio:(
I’m actually a little curious about this myself because I’ve been using 
OpenGL often recently. I’ve seen the Ingemar’s demos but I only slightly 
grasp how it’s working.


The wiki says you’re actually parsing the Pascal (not compiling it) and 
outputting JavaScript. If that’s the case then how does porting libraries 
work in practice? For examples lets say I want to translate a single OpenGL 
function, how does that look?


I found it surprisingly easy to import undefined JavaScript functions working 
from examples in the interfaces. I believe web.pas was particularly useful. I 
also made some changes in web.pas. Well, why not say what: I made 
localStorage public instead of private.


It is public ?


And I think "strokeStyle" was spelled  "strokeStye". Also added


Fixed, rev 82.



    procedure ellipse(x, y, radiusX, radiusY: TCanvasCoordType; rotation, 
startAngle, endAngle: Real; anticlockwise: Boolean);


into TJSCanvasRenderingContext2D.


I did not add that on purpose, because it is marked experimental in the 
documentation.

I only add 'stable' calls.



Not that much though.

WebGL is interesting for me, and being an OpenGL expert (teaching it for many 
years, written two course books on the subject and tons of code), I am happy 
to contribute any way I can. If nothing else, I can promise some decent 
demos, and testing of course.


I will see if today I can come up with a basic translation based on the IDL that
Ryan posted. I had webgl for version 1.0 on my wishlist.

I'll get back on that later today, and examples would be *hugely* appreciated.

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

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

2018-05-01 Thread Ingemar Ragnemalm


Den 2018-05-01 kl. 09:50, Ryan Joseph  wrote:

On Apr 25, 2018, at 9:43 PM, Michael Van Canneyt  wrote:

Ah, webgl...

I had a look at this some time ago, and got depressed. Quickly closed the 
browser and didn't look back. Same for webaudio:(

I’m actually a little curious about this myself because I’ve been using OpenGL 
often recently. I’ve seen the Ingemar’s demos but I only slightly grasp how 
it’s working.

The wiki says you’re actually parsing the Pascal (not compiling it) and 
outputting JavaScript. If that’s the case then how does porting libraries work 
in practice? For examples lets say I want to translate a single OpenGL 
function, how does that look?


I found it surprisingly easy to import undefined JavaScript functions 
working from examples in the interfaces. I believe web.pas was 
particularly useful. I also made some changes in web.pas. Well, why not 
say what: I made localStorage public instead of private. And I think 
"strokeStyle" was spelled "strokeStye". Also added


    procedure ellipse(x, y, radiusX, radiusY: TCanvasCoordType; 
rotation, startAngle, endAngle: Real; anticlockwise: Boolean);


into TJSCanvasRenderingContext2D.

Not that much though.

WebGL is interesting for me, and being an OpenGL expert (teaching it for 
many years, written two course books on the subject and tons of code), I 
am happy to contribute any way I can. If nothing else, I can promise 
some decent demos, and testing of course.


/Ingemar

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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 4:10 PM, Mattias Gaertner  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.


What's wrong with the above code ?

It obviously works well enough, otherwise they wouldn't have made the API so.

The float32 array is a Javascript type that encapsulates a memory buffer.
I assume the webgl creators decided it has the optimal layout for their
needs.

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

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

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 4:10 PM, Mattias Gaertner  
> 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

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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 4:12 PM, Michael Van Canneyt  wrote:

If you have access to the underlying API spec in the form of an IDL, then we
could make a tool that parses the IDL and dumps the API in the form of
"external" declarations.


There it is. A parser needs to be made I guess. You could chop that us pretty 
easily with a regex based PHP script.


You were doing great just up to the letters PHP ;-)

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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Mattias Gaertner wrote:


On Tue, 1 May 2018 15:23:25 +0700
Ryan Joseph  wrote:


[...]
what do we do for records then? We often need to pass arrays of specific types 
for functions such as glBufferData.

type
  TVec2f = record
x, y: GLfloat;
  end;

type
  TVec2b = record
x, y: GLubyte;
  end;

var
  verts: array[0..2] of TVec2f;
begin
  glBufferData(GL_ARRAY_BUFFER, sizeof(TVec2f) * 3, @verts, GL_STATIC_DRAW); // 
pass an array of TVec2 but how does JS know this?


Here is an JS example:

---JS-START---
var vertices = [-0.5, 0.5, -0.5, -0.5, 0.0, -0.5,];

// Create a new buffer object
var 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, new Float32Array(vertices), gl.STATIC_DRAW);


So it does exist :)
Nice, I should have typed gl.bufferData instead of glbufferdata when
searching :-)

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

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

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 3:50 PM, Michael Van Canneyt  
> wrote:
> 
> 
> As far as I know, all consts in Javascript are scoped ?
> 
> If this is not the case, then of course we should allow it.

I think they added const. In the past I’ve seen using “let” but I don’t think 
that’s a real const if that matters or not.

> 
> You must define the type to something the compiler knows, so the compiler 
> knows what operations it can do.
> 
> If you really do not know the type, use JSValue. But there is little you can
> do with a JSValue except assign or typecast it.

I see. So the type is really for the parser but it gets passed on as the real 
name to JS.

> 
> You are mistaken where that is concerned.
> 
> See above: Most APIs _do_ specify a type. You must look it up. Have a look
> at the web.pas or js.pas or even libjquery.pas units. Most identifiers have
> a type, the use of JSValue is quite limited.
> 
> Read-only Attributes can be translated to read-only properties.
> 
> The above would be
> 
> Type
>   WebGLActiveInfo = class external name 'WebGLActiveInfo'
>   Private
>fSize : GLint; external name 'size';
>ftype: GLEnum; external name 'type';
>fName : DOMString ; external name 'name';
>  Public
>Property size : GLInt Read FSize;
>Property  : GLEnum Read fType;
>Propert Name : DomString read FName;
>  end;

Interface is just a class? That makes sense but “dictionary” is a real type I 
assume because I know JS has “associative arrays” or hash maps. How do those 
work in Pascal?

Shouldn’t there be some automatic tool to parse JS api's to Pascal then? Makes 
sense so API’s like this can be dumped out easily.



Regards,
Ryan Joseph

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

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

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 15:36:59 +0700
Ryan Joseph  wrote:

>[...]
> > Constants without expression can only exist in an external class.  
> 
> Just curious but why can’t you declare a const anywhere for any reasons?

You can.


> >> Also I mistyped, GLfloat is a type so how do this map to JS, or do I even 
> >> need to since the names are the same?  
> > 
> > You need to define types.
> > 
> > type
> >  GLfloat = double;  
> 
> Why do we need to redefine the type if it’s already defined in the JS 
> library? 

JS has (almost) no types. WebGL has some intrinsic types. The unit
webgl will be defining the corresponding Pascal types.

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

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

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 3:17 PM, Mattias Gaertner  
> wrote:
> 
> JS only knows double for numbers.
> 
> At compile time you can use almost all the normal types: byte,
> word, longint, etc.
> pas2js has an alias single, but because internally it is a double this
> gives warnings.

what do we do for records then? We often need to pass arrays of specific types 
for functions such as glBufferData.

type
  TVec2f = record
x, y: GLfloat;
  end;

type
  TVec2b = record
x, y: GLubyte;
  end;

var
  verts: array[0..2] of TVec2f;
begin
  glBufferData(GL_ARRAY_BUFFER, sizeof(TVec2f) * 3, @verts, GL_STATIC_DRAW); // 
pass an array of TVec2 but how does JS know this?

Regards,
Ryan Joseph

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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Mattias Gaertner wrote:


On Tue, 1 May 2018 14:20:12 +0700
Ryan Joseph  wrote:


> On May 1, 2018, at 2:03 PM, Michael Van Canneyt  
wrote:
> 
> Of sorts.

>  MyClass = Class external name 'my'
>  const
>MyConst : integer
>  end;
> 
> Will emit MyClass.MyConst. The compiler needs to know the type. 


I’m confused now.


I think you confused Michael. ;)

At the moment you can define external const like this:
var
 NaN: Double; external name 'NaN';
 Infinity: Double; external name 'Infinity';
 NegInfinity: Double; external name '-Infinity';

Note that the 'var' is a workaround till eventually pas2js supports
external 'const' without expression.


Well, I specially did not mention this, because I consider it a dirty hack.
a var doesn't protect you from assigning to it (it's a variable, after all).

One preferably shouldn't teach people bad habits. :)

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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 3:17 PM, Michael Van Canneyt  wrote:


So constants must be part of the class? In the example below 
gl.COLOR_BUFFER_BIT is scoped to WebGLRenderingContext so I guess that’s the 
reason.


Yes.

Constants without expression can only exist in an external class.


Just curious but why can’t you declare a const anywhere for any reasons?


As far as I know, all consts in Javascript are scoped ?

If this is not the case, then of course we should allow it.







Also I mistyped, GLfloat is a type so how do this map to JS, or do I even need 
to since the names are the same?


You need to define types.

type
 GLfloat = double;


Why do we need to redefine the type if it’s already defined in the JS library? 
GLfloat isn’t a double also but see my other reply.


You must define the type to something the compiler knows, so the compiler knows 
what operations it can do.

Imagine:

Type
  MyOpaqueType external;

Var
  I : MyOpaqueType;

begin
  // What can I do with I ?  Can I add it ? Can I multiply it ?...
end.

If you really do not know the type, use JSValue. But there is little you can
do with a JSValue except assign or typecast it.



From the link you posted there are these types. Is that even JavaScript? I 
don’t remember there being typedefs in it or void functions.


The link is a spec. All javascript constructs have such a spec, and they are
a form of IDL, which does specifie types.



interface WebGLActiveInfo
{
   readonly attribute GLint size;
   readonly attribute GLenum type;
   readonly attribute DOMString name;
};




How does this JS translate to Pascal then? drawingBufferWidth are read only 
properties but no type is specified so how does Pascal handle all the untyped 
variables we see in JS?


You are mistaken where that is concerned.

See above: Most APIs _do_ specify a type. You must look it up. Have a look
at the web.pas or js.pas or even libjquery.pas units. Most identifiers have
a type, the use of JSValue is quite limited.

Read-only Attributes can be translated to read-only properties.

The above would be

Type
   WebGLActiveInfo = class external name 'WebGLActiveInfo'
   Private
fSize : GLint; external name 'size';
ftype: GLEnum; external name 'type';
fName : DOMString ; external name 'name';
  Public
Property size : GLInt Read FSize;
Property  : GLEnum Read fType;
Propert Name : DomString read FName;
  end;

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

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

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 3:17 PM, Michael Van Canneyt  
> wrote:
> 
>> So constants must be part of the class? In the example below 
>> gl.COLOR_BUFFER_BIT is scoped to WebGLRenderingContext so I guess that’s the 
>> reason.
> 
> Yes.
> 
> Constants without expression can only exist in an external class.

Just curious but why can’t you declare a const anywhere for any reasons?

> 
>> 
>> Also I mistyped, GLfloat is a type so how do this map to JS, or do I even 
>> need to since the names are the same?
> 
> You need to define types.
> 
> type
>  GLfloat = double;

Why do we need to redefine the type if it’s already defined in the JS library? 
GLfloat isn’t a double also but see my other reply.

From the link you posted there are these types. Is that even JavaScript? I 
don’t remember there being typedefs in it or void functions.

typedef unsigned long  GLenum;
typedef booleanGLboolean;
typedef unsigned long  GLbitfield;
typedef byte   GLbyte; /* 'byte' should be a signed 8 bit type. 
*/
typedef short  GLshort;
typedef long   GLint;
typedef long   GLsizei;
typedef long long  GLintptr;
typedef long long  GLsizeiptr;
// Ideally the typedef below would use 'unsigned byte', but that doesn't 
currently exist in Web IDL.
typedef octet  GLubyte;/* 'octet' should be an unsigned 8 bit 
type. */
typedef unsigned short GLushort;
typedef unsigned long  GLuint;
typedef unrestricted float GLfloat;
typedef unrestricted float GLclampf;

There’s other types also like dictionaries and interface. How do those work? I 
don’t remember those being in JS either….

dictionary WebGLContextAttributes
 {
GLboolean alpha = true;
GLboolean depth = true;
GLboolean stencil = false;
GLboolean antialias = true;
GLboolean premultipliedAlpha = true;
GLboolean preserveDrawingBuffer = false;
WebGLPowerPreference powerPreference = "default";
GLboolean failIfMajorPerformanceCaveat = false;
};

interface WebGLActiveInfo
 {
readonly attribute GLint size;
readonly attribute GLenum type;
readonly attribute DOMString name;
};
> 
>> 
>> How does this JS translate to Pascal then? drawingBufferWidth are read only 
>> properties but no type is specified so how does Pascal handle all the 
>> untyped variables we see in JS?
> 
> This is pascal. You need a type.
> 
> https://www.khronos.org/registry/webgl/specs/latest/1.0/
> 
> shows that drawingBufferWidth has type GLsizei, which is a long.
> 
> If you don't know the type, use JSValue. It's the 'unknown type'. It has
> limited possibilities, in essence you'll need to typecast a JSValue before
> using it. You can assign JSValues of course.

I see, that reference I used wasn’t complete.



Regards,
Ryan Joseph

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

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

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 14:20:12 +0700
Ryan Joseph  wrote:

> > On May 1, 2018, at 2:03 PM, Michael Van Canneyt  
> > wrote:
> > 
> > Of sorts.
> >  MyClass = Class external name 'my'
> >  const
> >MyConst : integer
> >  end;
> > 
> > Will emit MyClass.MyConst. The compiler needs to know the type.  
> 
> I’m confused now.

I think you confused Michael. ;)

At the moment you can define external const like this:
var
  NaN: Double; external name 'NaN';
  Infinity: Double; external name 'Infinity';
  NegInfinity: Double; external name '-Infinity';

Note that the 'var' is a workaround till eventually pas2js supports
external 'const' without expression.

A const inside an external class already works:

type
  TMyExt = class external name 'Bla'
const LoVersion: GLFloat;
const HiVersion: GLFloat; external name 'hiversion';
  end;


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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





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

Of sorts.
 MyClass = Class external name 'my'
 const
   MyConst : integer
 end;

Will emit MyClass.MyConst. The compiler needs to know the type.


I’m confused now.  The class is named WebGLRenderingContext in JS (I think
that’s what it’s called by JS doesn’t really have classes does it?) so how
does it look?



See below.



// no external name because the names are the same


That is only so for methods and fields. I corrected the class below:

type
  WebGLRenderingContext = class external name 'WebGLRenderingContext'
procedure clearColor (red, green, blue, alpha: GLfloat);
  end;



So constants must be part of the class? In the example below 
gl.COLOR_BUFFER_BIT is scoped to WebGLRenderingContext so I guess that’s the 
reason.


Yes.

Constants without expression can only exist in an external class.



Also I mistyped, GLfloat is a type so how do this map to JS, or do I even need 
to since the names are the same?


You need to define types.

type
  GLfloat = double;



How does this JS translate to Pascal then? drawingBufferWidth are read only 
properties but no type is specified so how does Pascal handle all the untyped 
variables we see in JS?


This is pascal. You need a type.

https://www.khronos.org/registry/webgl/specs/latest/1.0/

shows that drawingBufferWidth has type GLsizei, which is a long.

If you don't know the type, use JSValue. It's the 'unknown type'. It has
limited possibilities, in essence you'll need to typecast a JSValue before
using it. You can assign JSValues of course.

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

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

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 15:03:30 +0700
Ryan Joseph  wrote:

> > On May 1, 2018, at 2:55 PM, Mattias Gaertner  
> > wrote:
> > 
> > GLFloat is a type, not a const.
> > 
> > type GLFloat = double;  
> 
> Yeah I mistyped. We shouldn’t be redefining GLfloat though (I doubt it’s a 
> double in OpenGLES/WebGL either) so how does this (or other types) translate 
> for the parser? 

JS only knows double for numbers.

At compile time you can use almost all the normal types: byte,
word, longint, etc.
pas2js has an alias single, but because internally it is a double this
gives warnings.

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

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

2018-05-01 Thread Ryan Joseph

> On May 1, 2018, at 2:55 PM, Mattias Gaertner  
> wrote:
> 
> GLFloat is a type, not a const.
> 
> type GLFloat = double;

Yeah I mistyped. We shouldn’t be redefining GLfloat though (I doubt it’s a 
double in OpenGLES/WebGL either) so how does this (or other types) translate 
for 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] Next language feature for pas2js...

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 12:11:37 +0700
Ryan Joseph  wrote:

>[...]
> const
>   GLfloat = MAP_TO_SOMETHING; // do we have external consts?

GLFloat is a type, not a const.

type GLFloat = double;

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

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

2018-05-01 Thread Ryan Joseph


> On May 1, 2018, at 2:03 PM, Michael Van Canneyt  
> wrote:
> 
> Of sorts.
>  MyClass = Class external name 'my'
>  const
>MyConst : integer
>  end;
> 
> Will emit MyClass.MyConst. The compiler needs to know the type.

I’m confused now. The class is named WebGLRenderingContext in JS (I think 
that’s what it’s called by JS doesn’t really have classes does it?) so how does 
it look? 

// no external name because the names are the same
type
  WebGLRenderingContext = class
procedure clearColor (red, green, blue, alpha: GLfloat);
  end;

So constants must be part of the class? In the example below 
gl.COLOR_BUFFER_BIT is scoped to WebGLRenderingContext so I guess that’s the 
reason.

Also I mistyped, GLfloat is a type so how do this map to JS, or do I even need 
to since the names are the same?

How does this JS translate to Pascal then? drawingBufferWidth are read only 
properties but no type is specified so how does Pascal handle all the untyped 
variables we see in JS?

var canvas = document.createElement("canvas");
var gl = canvas.getContext("webgl")
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);


Regards,
Ryan Joseph

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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Ryan Joseph wrote:





On May 1, 2018, at 11:27 AM, Michalis Kamburelis  
wrote:

I suspect that we will have a unit like WebGL in pas2js that exposes
the necessary JS functions for Pascal applications.


Sure but how does the porting process look? I’m reading the wiki and it looks 
like it wraps JavaScript classes by doing stuff like:

TJSFunction = class external name 'Function'(TJSObject)

where “Function” is the JavaScript class name.


This is actually a less good example, it's a little tricky.



Looking at https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API I see 
WebGLRenderingContext has the entire OpenGL API (I think). Does that mean we 
just do something like:

const
 GLfloat = MAP_TO_SOMETHING; // do we have external consts?


Of sorts.
  MyClass = Class external name 'my'
  const
MyConst : integer
  end;

Will emit MyClass.MyConst. The compiler needs to know the type.



type
 TWebGLRenderingContext = class external name 'WebGLRenderingContext' 
(TJSObject)
   procedure clearColor (red, green, blue, alpha: GLfloat); external name 
'clearColor';
 end;

var
 context :
begin
 context := GetCurrentContext; // document.getElementById(‘canvas’).getContext()
 context.clearColor(0, 0, 0, 0);


That seems about correct. 
You don't need the "external name 'n'" if the name is typed correctly.


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

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

2018-05-01 Thread Michael Van Canneyt



On Tue, 1 May 2018, Michalis Kamburelis wrote:



I had a look at this some time ago, and got depressed. Quickly closed the 
browser and didn't look back. Same for webaudio :(


The API of WebGL is actually mostly a subset of OpenGLES which is a
subset of OpenGL. WebGL is quite small, if you compare it to other
graphic APIs :) OpenGL(ES), Direct3D, Vulkan, Metal are way more
complicated and larger.


Somehow this doesn't really lift my spirits. :)


I’m actually a little curious about this myself because I’ve been using OpenGL 
often recently. I’ve seen the Ingemar’s demos but I only slightly grasp how 
it’s working.

The wiki says you’re actually parsing the Pascal (not compiling it) and 
outputting JavaScript. If that’s the case then how does porting libraries work 
in practice? For examples lets say I want to translate a single OpenGL 
function, how does that look?



I suspect that we will have a unit like WebGL in pas2js that exposes
the necessary JS functions for Pascal applications.


Correct.


Engine like Castle
Game Engine will used this unit when compiled with pas2js (instead of
GL when compiled with FPC for desktop, or GLES20 when compiled with
FPC for mobile). And then CGE can expose an API that looks the same
(both in pas2js and FPC).

(Yes, I want to port Castle Game Engine one day to pas2js :) )


Good to hear it :)

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

[fpc-pascal] Locale question

2018-05-01 Thread Richard Kimber via fpc-pascal
I have a text file, containing '£' characters, that file -bi reports as
text/plain; charset=utf-8
When I try to write a simple pascal program to edit this file using
nothing more than copy, insert, and stringreplace, the output file is
reported as:
text/html; charset=iso-8859-1
and I get '£' instead of '£'.

Is there a way of forcing the output to be UTF8, so that the pound
character appears unchanged?

I'm using fpc ver 3.0.2+dfsg-5ubuntu1 on Ubuntu 17.10, and am not an
expert.
-- 
Richard Kimber

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