pas2js Webgl unit committed

classic Classic list List threaded Threaded
50 messages Options
123
Reply | Threaded
Open this post in threaded view
|

pas2js Webgl unit committed

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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Ryan Joseph


> On May 1, 2018, at 7:40 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

How did you end up parsing it?

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Michael Van Canneyt


On Tue, 1 May 2018, Ryan Joseph wrote:

>
>
>> On May 1, 2018, at 7:40 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
>> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Ryan Joseph


> On May 1, 2018, at 7:49 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Michael Van Canneyt


On Tue, 1 May 2018, Ryan Joseph wrote:

>
>
>> On May 1, 2018, at 7:49 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Mattias Gaertner
On Tue, 1 May 2018 15:28:45 +0200 (CEST)
Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Ryan Joseph
In reply to this post by Michael Van Canneyt


> On May 1, 2018, at 8:28 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Michael Van Canneyt


On Tue, 1 May 2018, Ryan Joseph wrote:

>
>
>> On May 1, 2018, at 8:28 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Ryan Joseph


> On May 1, 2018, at 9:56 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Michalis Kamburelis-3
Ryan Joseph <[hidden email]> wrote:


> On May 1, 2018, at 9:56 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Michael Van Canneyt
In reply to this post by Ryan Joseph


On Tue, 1 May 2018, Ryan Joseph wrote:

>
>
>> On May 1, 2018, at 9:56 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Ryan Joseph


> On May 2, 2018, at 8:18 AM, Ryan Joseph <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Michael Van Canneyt


On Wed, 2 May 2018, Ryan Joseph wrote:

>
>
>> On May 2, 2018, at 8:18 AM, Ryan Joseph <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Ryan Joseph


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

trunk of what? Do mean the entire fpc sources?

cd /Users/ryanjoseph/Downloads/pas2js
ls
Makefile compiler fpmake.pp utils
Makefile.fpc demo packages

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Michael Van Canneyt


On Wed, 2 May 2018, Ryan Joseph wrote:

>
>
>> On May 2, 2018, at 1:24 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Ryan Joseph


> On May 2, 2018, at 2:08 PM, Michael Van Canneyt <[hidden email]> 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: nativeint;
    const DITHER: nativeint;
    const STENCIL_TEST: nativeint;
    const DEPTH_TEST: nativeint;
    const SCISSOR_TEST: nativeint;
    const POLYGON_OFFSET_FILL: nativeint;
    const SAMPLE_ALPHA_TO_COVERAGE: nativeint;
    const SAMPLE_COVERAGE: nativeint;
    const NO_ERROR: nativeint;
    const INVALID_ENUM: nativeint;
    const INVALID_VALUE: nativeint;
    const INVALID_OPERATION: nativeint;
    const OUT_OF_MEMORY: nativeint;
    const CW: nativeint;
    const CCW: nativeint;
    const LINE_WIDTH: nativeint;
    const ALIASED_POINT_SIZE_RANGE: nativeint;
    const ALIASED_LINE_WIDTH_RANGE: nativeint;
    const CULL_FACE_MODE: nativeint;
    const FRONT_FACE: nativeint;
    const DEPTH_RANGE: nativeint;
    const DEPTH_WRITEMASK: nativeint;
    const DEPTH_CLEAR_VALUE: nativeint;
    const DEPTH_FUNC: nativeint;
    const STENCIL_CLEAR_VALUE: nativeint;
    const STENCIL_FUNC: nativeint;
    const STENCIL_FAIL: nativeint;
    const STENCIL_PASS_DEPTH_FAIL: nativeint;
    const STENCIL_PASS_DEPTH_PASS: nativeint;
    const STENCIL_REF: nativeint;
    const STENCIL_VALUE_MASK: nativeint;
    const STENCIL_WRITEMASK: nativeint;
    const STENCIL_BACK_FUNC: nativeint;
    const STENCIL_BACK_FAIL: nativeint;
    const STENCIL_BACK_PASS_DEPTH_FAIL: nativeint;
    const STENCIL_BACK_PASS_DEPTH_PASS: nativeint;
    const STENCIL_BACK_REF: nativeint;
    const STENCIL_BACK_VALUE_MASK: nativeint;
    const STENCIL_BACK_WRITEMASK: nativeint;
    const VIEWPORT: nativeint;
    const SCISSOR_BOX: nativeint;
    const COLOR_CLEAR_VALUE: nativeint;
    const COLOR_WRITEMASK: nativeint;
    const UNPACK_ALIGNMENT: nativeint;
    const PACK_ALIGNMENT: nativeint;
    const MAX_TEXTURE_SIZE: nativeint;
    const MAX_VIEWPORT_DIMS: nativeint;
    const SUBPIXEL_BITS: nativeint;
    const RED_BITS: nativeint;
    const GREEN_BITS: nativeint;
    const BLUE_BITS: nativeint;
    const ALPHA_BITS: nativeint;
    const DEPTH_BITS: nativeint;
    const STENCIL_BITS: nativeint;
    const POLYGON_OFFSET_UNITS: nativeint;
    const POLYGON_OFFSET_FACTOR: nativeint;
    const TEXTURE_BINDING_2D: nativeint;
    const SAMPLE_BUFFERS: nativeint;
    const SAMPLES: nativeint;
    const SAMPLE_COVERAGE_VALUE: nativeint;
    const SAMPLE_COVERAGE_INVERT: nativeint;
    const COMPRESSED_TEXTURE_FORMATS: nativeint;
    const DONT_CARE: nativeint;
    const FASTEST: nativeint;
    const NICEST: nativeint;
    const GENERATE_MIPMAP_HINT: nativeint;
    const BYTE: nativeint;
    const UNSIGNED_BYTE: nativeint;
    const SHORT: nativeint;
    const UNSIGNED_SHORT: nativeint;
    const INT: nativeint;
    const UNSIGNED_INT: nativeint;
    const FLOAT: nativeint;
    const DEPTH_COMPONENT: nativeint;
    const ALPHA: nativeint;
    const RGB: nativeint;
    const RGBA: nativeint;
    const LUMINANCE: nativeint;
    const LUMINANCE_ALPHA: nativeint;
    const UNSIGNED_SHORT_4_4_4_4: nativeint;
    const UNSIGNED_SHORT_5_5_5_1: nativeint;
    const UNSIGNED_SHORT_5_6_5: nativeint;
    const FRAGMENT_SHADER: nativeint;
    const VERTEX_SHADER: nativeint;
    const MAX_VERTEX_ATTRIBS: nativeint;
    const MAX_VERTEX_UNIFORM_VECTORS: nativeint;
    const MAX_VARYING_VECTORS: nativeint;
    const MAX_COMBINED_TEXTURE_IMAGE_UNITS: nativeint;
    const MAX_VERTEX_TEXTURE_IMAGE_UNITS: nativeint;
    const MAX_TEXTURE_IMAGE_UNITS: nativeint;
    const MAX_FRAGMENT_UNIFORM_VECTORS: nativeint;
    const SHADER_TYPE: nativeint;
    const DELETE_STATUS: nativeint;
    const LINK_STATUS: nativeint;
    const VALIDATE_STATUS: nativeint;
    const ATTACHED_SHADERS: nativeint;
    const ACTIVE_UNIFORMS: nativeint;
    const ACTIVE_ATTRIBUTES: nativeint;
    const SHADING_LANGUAGE_VERSION: nativeint;
    const CURRENT_PROGRAM: nativeint;
    const NEVER: nativeint;
    const LESS: nativeint;
    const EQUAL: nativeint;
    const LEQUAL: nativeint;
    const GREATER: nativeint;
    const NOTEQUAL: nativeint;
    const GEQUAL: nativeint;
    const ALWAYS: nativeint;
    const KEEP: nativeint;
    const REPLACE: nativeint;
    const INCR: nativeint;
    const DECR: nativeint;
    const INVERT: nativeint;
    const INCR_WRAP: nativeint;
    const DECR_WRAP: nativeint;
    const VENDOR: nativeint;
    const RENDERER: nativeint;
    const VERSION: nativeint;
    const NEAREST: nativeint;
    const LINEAR: nativeint;
    const NEAREST_MIPMAP_NEAREST: nativeint;
    const LINEAR_MIPMAP_NEAREST: nativeint;
    const NEAREST_MIPMAP_LINEAR: nativeint;
    const LINEAR_MIPMAP_LINEAR: nativeint;
    const TEXTURE_MAG_FILTER: nativeint;
    const TEXTURE_MIN_FILTER: nativeint;
    const TEXTURE_WRAP_S: nativeint;
    const TEXTURE_WRAP_T: nativeint;
    const TEXTURE_2D: nativeint;
    const TEXTURE: nativeint;
    const TEXTURE_CUBE_MAP: nativeint;
    const TEXTURE_BINDING_CUBE_MAP: nativeint;
    const TEXTURE_CUBE_MAP_POSITIVE_X: nativeint;
    const TEXTURE_CUBE_MAP_NEGATIVE_X: nativeint;
    const TEXTURE_CUBE_MAP_POSITIVE_Y: nativeint;
    const TEXTURE_CUBE_MAP_NEGATIVE_Y: nativeint;
    const TEXTURE_CUBE_MAP_POSITIVE_Z: nativeint;
    const TEXTURE_CUBE_MAP_NEGATIVE_Z: nativeint;
    const MAX_CUBE_MAP_TEXTURE_SIZE: nativeint;
    const TEXTURE0: nativeint;
    const TEXTURE1: nativeint;
    const TEXTURE2: nativeint;
    const TEXTURE3: nativeint;
    const TEXTURE4: nativeint;
    const TEXTURE5: nativeint;
    const TEXTURE6: nativeint;
    const TEXTURE7: nativeint;
    const TEXTURE8: nativeint;
    const TEXTURE9: nativeint;
    const TEXTURE10: nativeint;
    const TEXTURE11: nativeint;
    const TEXTURE12: nativeint;
    const TEXTURE13: nativeint;
    const TEXTURE14: nativeint;
    const TEXTURE15: nativeint;
    const TEXTURE16: nativeint;
    const TEXTURE17: nativeint;
    const TEXTURE18: nativeint;
    const TEXTURE19: nativeint;
    const TEXTURE20: nativeint;
    const TEXTURE21: nativeint;
    const TEXTURE22: nativeint;
    const TEXTURE23: nativeint;
    const TEXTURE24: nativeint;
    const TEXTURE25: nativeint;
    const TEXTURE26: nativeint;
    const TEXTURE27: nativeint;
    const TEXTURE28: nativeint;
    const TEXTURE29: nativeint;
    const TEXTURE30: nativeint;
    const TEXTURE31: nativeint;
    const ACTIVE_TEXTURE: nativeint;
    const REPEAT: nativeint;
    const CLAMP_TO_EDGE: nativeint;
    const MIRRORED_REPEAT: nativeint;
    const FLOAT_VEC2: nativeint;
    const FLOAT_VEC3: nativeint;
    const FLOAT_VEC4: nativeint;
    const INT_VEC2: nativeint;
    const INT_VEC3: nativeint;
    const INT_VEC4: nativeint;
    const BOOL: nativeint;
    const BOOL_VEC2: nativeint;
    const BOOL_VEC3: nativeint;
    const BOOL_VEC4: nativeint;
    const FLOAT_MAT2: nativeint;
    const FLOAT_MAT3: nativeint;
    const FLOAT_MAT4: nativeint;
    const SAMPLER_2D: nativeint;
    const SAMPLER_CUBE: nativeint;
    const VERTEX_ATTRIB_ARRAY_ENABLED: nativeint;
    const VERTEX_ATTRIB_ARRAY_SIZE: nativeint;
    const VERTEX_ATTRIB_ARRAY_STRIDE: nativeint;
    const VERTEX_ATTRIB_ARRAY_TYPE: nativeint;
    const VERTEX_ATTRIB_ARRAY_NORMALIZED: nativeint;
    const VERTEX_ATTRIB_ARRAY_POINTER: nativeint;
    const VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: nativeint;
    const IMPLEMENTATION_COLOR_READ_TYPE: nativeint;
    const IMPLEMENTATION_COLOR_READ_FORMAT: nativeint;
    const COMPILE_STATUS: nativeint;
    const LOW_FLOAT: nativeint;
    const MEDIUM_FLOAT: nativeint;
    const HIGH_FLOAT: nativeint;
    const LOW_INT: nativeint;
    const MEDIUM_INT: nativeint;
    const HIGH_INT: nativeint;
    const FRAMEBUFFER: nativeint;
    const RENDERBUFFER: nativeint;
    const RGBA4: nativeint;
    const RGB5_A1: nativeint;
    const RGB565: nativeint;
    const DEPTH_COMPONENT16: nativeint;
    const STENCIL_INDEX8: nativeint;
    const DEPTH_STENCIL: nativeint;
    const RENDERBUFFER_WIDTH: nativeint;
    const RENDERBUFFER_HEIGHT: nativeint;
    const RENDERBUFFER_INTERNAL_FORMAT: nativeint;
    const RENDERBUFFER_RED_SIZE: nativeint;
    const RENDERBUFFER_GREEN_SIZE: nativeint;
    const RENDERBUFFER_BLUE_SIZE: nativeint;
    const RENDERBUFFER_ALPHA_SIZE: nativeint;
    const RENDERBUFFER_DEPTH_SIZE: nativeint;
    const RENDERBUFFER_STENCIL_SIZE: nativeint;
    const FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: nativeint;
    const FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: nativeint;
    const FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: nativeint;
    const FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: nativeint;
    const COLOR_ATTACHMENT0: nativeint;
    const DEPTH_ATTACHMENT: nativeint;
    const STENCIL_ATTACHMENT: nativeint;
    const DEPTH_STENCIL_ATTACHMENT: nativeint;
    const NONE: nativeint;
    const FRAMEBUFFER_COMPLETE: nativeint;
    const FRAMEBUFFER_INCOMPLETE_ATTACHMENT: nativeint;
    const FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: nativeint;
    const FRAMEBUFFER_INCOMPLETE_DIMENSIONS: nativeint;
    const FRAMEBUFFER_UNSUPPORTED: nativeint;
    const FRAMEBUFFER_BINDING: nativeint;
    const RENDERBUFFER_BINDING: nativeint;
    const MAX_RENDERBUFFER_SIZE: nativeint;
    const INVALID_FRAMEBUFFER_OPERATION: nativeint;
    const UNPACK_FLIP_Y_WEBGL: nativeint;
    const UNPACK_PREMULTIPLY_ALPHA_WEBGL: nativeint;
    const CONTEXT_LOST_WEBGL: nativeint;
    const UNPACK_COLORSPACE_CONVERSION_WEBGL: nativeint;
    const BROWSER_DEFAULT_WEBGL: nativeint;
    property canvas: HTMLCanvasElement read Fcanvas;
    property drawingBufferWidth: GLsizei read FdrawingBufferWidth;
    property drawingBufferHeight: GLsizei read FdrawingBufferHeight;
    function getContextAttributes: TJSWebGLContextAttributes;
    function isContextLost: boolean;
    function getSupportedExtensions: DOMStringDynArray;
    function getExtension (name: DOMString): TJSobject;
    procedure activeTexture (texture: GLenum);
    procedure attachShader (program: WebGLProgram; shader: WebGLShader);
    procedure bindAttribLocation (program: WebGLProgram; index: GLuint; name: DOMString);
    procedure bindBuffer (target: GLenum; buffer: TJSWebGLBuffer);
    procedure bindFramebuffer (target: GLenum; framebuffer: TJSWebGLFramebuffer);
    procedure bindRenderbuffer (target: GLenum; renderbuffer: TJSWebGLRenderbuffer);
    procedure bindTexture (target: GLenum; texture: TJSWebGLTexture);
    procedure blendColor (red: GLclampf; green: GLclampf; blue: GLclampf; alpha: GLclampf);
    procedure blendEquation (mode: GLenum);
    procedure blendEquationSeparate (modeRGB: GLenum; modeAlpha: GLenum);
    procedure blendFunc (sfactor: GLenum; dfactor: GLenum);
    procedure bufferData (target: GLenum; size: GLsizeiptr; usage: GLenum);
    procedure bufferData (target: GLenum; data: BufferSource; usage: GLenum);
    procedure bufferSubData (target: GLenum; offset: GLintptr; data: BufferSource);
    function checkFramebufferStatus (target: GLenum): GLenum;
    procedure clear (mask: GLbitfield);
    procedure clearColor (red: GLclampf; green: GLclampf; blue: GLclampf; alpha: GLclampf);
    procedure clearDepth (depth: GLclampf);
    procedure clearStencil (s: GLint);
    procedure colorMask (red: GLboolean; green: GLboolean; blue: GLboolean; alpha: GLboolean);
    procedure compileShader (shader: WebGLShader);
    function createBuffer: TJSWebGLBuffer;
    function createFramebuffer: TJSWebGLFramebuffer;
    function createProgram: TJSWebGLProgram;
    function createRenderbuffer: TJSWebGLRenderbuffer;
    function createShader (type: GLenum): TJSWebGLShader;
    function createTexture: TJSWebGLTexture;
    procedure cullFace (mode: GLenum);
    procedure deleteBuffer (buffer: TJSWebGLBuffer);
    procedure deleteFramebuffer (framebuffer: TJSWebGLFramebuffer);
    procedure deleteProgram (program: TJSWebGLProgram);
    procedure deleteRenderbuffer (renderbuffer: TJSWebGLRenderbuffer);
    procedure deleteShader (shader: TJSWebGLShader);
    procedure deleteTexture (texture: TJSWebGLTexture);
    procedure depthFunc (func: GLenum);
    procedure depthMask (flag: GLboolean);
    procedure depthRange (zNear: GLclampf; zFar: GLclampf);
    procedure detachShader (program: WebGLProgram; shader: WebGLShader);
    procedure disable (cap: GLenum);
    procedure disableVertexAttribArray (index: GLuint);
    procedure drawArrays (mode: GLenum; first: GLint; count: GLsizei);
    procedure drawElements (mode: GLenum; count: GLsizei; type: GLenum; offset: GLintptr);
    procedure enable (cap: GLenum);
    procedure enableVertexAttribArray (index: GLuint);
    procedure finish;
    procedure flush;
    procedure frontFace (mode: GLenum);
    procedure generateMipmap (target: GLenum);
    function getActiveAttrib (program: WebGLProgram; index: GLuint): TJSWebGLActiveInfo;
    function getActiveUniform (program: WebGLProgram; index: GLuint): TJSWebGLActiveInfo;
    function getAttachedShaders (program: WebGLProgram): WebGLShaderDynArray;
    function getAttribLocation (program: WebGLProgram; name: DOMString): GLint;
    function getBufferParameter (target: GLenum; pname: GLenum): JSValue;
    function getParameter (pname: GLenum): JSValue;
    function getError: GLenum;
    function getProgramParameter (program: WebGLProgram; pname: GLenum): JSValue;
    function getProgramInfoLog (program: WebGLProgram): TJSDOMString;
    function getRenderbufferParameter (target: GLenum; pname: GLenum): JSValue;
    function getShaderParameter (shader: WebGLShader; pname: GLenum): JSValue;
    function getShaderPrecisionFormat (shadertype: GLenum; precisiontype: GLenum): TJSWebGLShaderPrecisionFormat;
    function getShaderInfoLog (shader: WebGLShader): TJSDOMString;
    function getShaderSource (shader: WebGLShader): TJSDOMString;
    function getTexParameter (target: GLenum; pname: GLenum): JSValue;
    function getUniform (program: WebGLProgram; location: WebGLUniformLocation): JSValue;
    function getUniformLocation (program: WebGLProgram; name: DOMString): TJSWebGLUniformLocation;
    function getVertexAttrib (index: GLuint; pname: GLenum): JSValue;
    function getVertexAttribOffset (index: GLuint; pname: GLenum): GLintptr;
    procedure hint (target: GLenum; mode: GLenum);
    function isBuffer (buffer: TJSWebGLBuffer): GLboolean;
    function isEnabled (cap: GLenum): GLboolean;
    function isFramebuffer (framebuffer: TJSWebGLFramebuffer): GLboolean;
    function isProgram (program: TJSWebGLProgram): GLboolean;
    function isRenderbuffer (renderbuffer: TJSWebGLRenderbuffer): GLboolean;
    function isShader (shader: TJSWebGLShader): GLboolean;
    function isTexture (texture: TJSWebGLTexture): GLboolean;
    procedure lineWidth (width: GLfloat);
    procedure linkProgram (program: WebGLProgram);
    procedure pixelStorei (pname: GLenum; param: GLint);
    procedure polygonOffset (factor: GLfloat; units: GLfloat);
    procedure sampleCoverage (value: GLclampf; invert: GLboolean);
    procedure scissor (x: GLint; y: GLint; width: GLsizei; height: GLsizei);
    procedure shaderSource (shader: WebGLShader; source: DOMString);
    procedure stencilFunc (func: GLenum; ref: GLint; mask: GLuint);
    procedure stencilFuncSeparate (face: GLenum; func: GLenum; ref: GLint; mask: GLuint);
    procedure stencilMask (mask: GLuint);
    procedure stencilMaskSeparate (face: GLenum; mask: GLuint);
    procedure stencilOp (fail: GLenum; zfail: GLenum; zpass: GLenum);
    procedure stencilOpSeparate (face: GLenum; fail: GLenum; zfail: GLenum; zpass: GLenum);
    procedure texParameterf (target: GLenum; pname: GLenum; param: GLfloat);
    procedure texParameteri (target: GLenum; pname: GLenum; param: GLint);
    procedure uniform1f (location: TJSWebGLUniformLocation; x: GLfloat);
    procedure uniform2f (location: TJSWebGLUniformLocation; x: GLfloat; y: GLfloat);
    procedure uniform3f (location: TJSWebGLUniformLocation; x: GLfloat; y: GLfloat; z: GLfloat);
    procedure uniform4f (location: TJSWebGLUniformLocation; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat);
    procedure uniform1i (location: TJSWebGLUniformLocation; x: GLint);
    procedure uniform2i (location: TJSWebGLUniformLocation; x: GLint; y: GLint);
    procedure uniform3i (location: TJSWebGLUniformLocation; x: GLint; y: GLint; z: GLint);
    procedure uniform4i (location: TJSWebGLUniformLocation; x: GLint; y: GLint; z: GLint; w: GLint);
    procedure uniform1fv (location: TJSWebGLUniformLocation; v: Float32List);
    procedure uniform2fv (location: TJSWebGLUniformLocation; v: Float32List);
    procedure uniform3fv (location: TJSWebGLUniformLocation; v: Float32List);
    procedure uniform4fv (location: TJSWebGLUniformLocation; v: Float32List);
    procedure uniform1iv (location: TJSWebGLUniformLocation; v: Int32List);
    procedure uniform2iv (location: TJSWebGLUniformLocation; v: Int32List);
    procedure uniform3iv (location: TJSWebGLUniformLocation; v: Int32List);
    procedure uniform4iv (location: TJSWebGLUniformLocation; v: Int32List);
    procedure uniformMatrix2fv (location: TJSWebGLUniformLocation; transpose: GLboolean; value: Float32List);
    procedure uniformMatrix3fv (location: TJSWebGLUniformLocation; transpose: GLboolean; value: Float32List);
    procedure uniformMatrix4fv (location: TJSWebGLUniformLocation; transpose: GLboolean; value: Float32List);
    procedure useProgram (program: TJSWebGLProgram);
    procedure validateProgram (program: WebGLProgram);
    procedure vertexAttrib1f (index: GLuint; x: GLfloat);
    procedure vertexAttrib2f (index: GLuint; x: GLfloat; y: GLfloat);
    procedure vertexAttrib3f (index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat);
    procedure vertexAttrib4f (index: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat);
    procedure vertexAttrib1fv (index: GLuint; values: Float32List);
    procedure vertexAttrib2fv (index: GLuint; values: Float32List);
    procedure vertexAttrib3fv (index: GLuint; values: Float32List);
    procedure vertexAttrib4fv (index: GLuint; values: Float32List);
    procedure viewport (x: GLint; y: GLint; width: GLsizei; height: GLsizei);
  end;

  class TJSWebGLRenderingContext = external name 'WebGLRenderingContext' (TJSWebGLRenderingContextBase);
  class TJSWebGLContextEvent = external name 'WebGLContextEvent' (TJSEvent)
  private
    FstatusMessage: DOMString; external name 'statusMessage';
  public
    property statusMessage: DOMString read FstatusMessage;
  end;

  class TJSWebGLContextEventInit = external name 'WebGLContextEventInit' (TJSEventInit)
  public
    statusMessage: DOMString;
  end;


implementation
end;


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Mattias Gaertner
On Wed, 2 May 2018 16:28:10 +0700
Ryan Joseph <[hidden email]> wrote:

> > On May 2, 2018, at 2:08 PM, Michael Van Canneyt <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Ryan Joseph


> On May 2, 2018, at 5:28 PM, Mattias Gaertner <[hidden email]> 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?

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pas2js Webgl unit committed

Michael Van Canneyt


On Wed, 2 May 2018, Ryan Joseph wrote:

>
>
>> On May 2, 2018, at 5:28 PM, Mattias Gaertner <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
123