> On May 1, 2018, at 3:17 PM, Michael Van Canneyt <mich...@freepascal.org> > 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 boolean GLboolean; 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