Up to date WebGL bindings

Hello pures!

A bit of background to get the context going. I’m a freelance game dev. tutorial creator under the GDQuest umbrella and since I’m interested in games, I was bummed out a bit that the WebGL bindings aren’t up to date.

I have experience with “simple” languages like Python, JavaScript to some extent and somewhat acquainted with C/C++. But I am almost a complete stranger when it comes to Haskell/Purescript even though I’ve been doings tests here and there for about 2-3 years now. I never made anything “in production” with these languages.

To test out and learn Purescript, which I actually prefer over Haskell, even as a desktop/CLI/generic language I decided to work on the WebGL bidings myself: https://github.com/razcore-art/purescript-webgl-generator.

Since I’m out of my depth here, I hoped to get some feedback early in the road so I don’t make huge blunders later.

The idea is to make a generator that creates the “raw” webgl bidings first, similar to https://github.com/mgmeier/purescript-webgl-generator, except I want to write it in Purescript and use the original KhronosGroup WebGL IDL spec files.

In any case, any feedback is much appreciated.

I haven’t added a readme file just yet, cause at this stage I’m just exploring/testing out stuff.

I’m especially interested how or even if it’s required to try and match the typedefs in the WebGL spec. For example, does it even make sense to enforce a byte type? Or is it enough that this is an Int in Purescript?

And what about the WGLAST construction:

data WGLType
  = WGLInt
  | WGLFloat
  | WGLBoolean
  | WGLNumber

type WGLIdentifier
  = String

  = WGLTypeDef WGLIdentifier WGLType
  | WGLEnum WGLIdentifier (List String)

I’m thinking that the parser will return List WGLAST which then I’ll try to print out to Purescript & JavaScript. If there are better ideas please let me know.


1 Like

Regarding PS and JS codegen you may be interested in some stuff from purescript-codegen org (work in progress but not an early stage) like purescript-ps-cst, purescript-js-ast, purescript-past.
It is a shameless plug as I’m a member of purescript-codegen :wink:

Also you may want to use some strange encodings for parts of the FFI to minimize overhead or be closer to the original API. For example you can consider usage of purescript-oneof or purescript-literal if there is a good fit for them in your case.

Good luck!


@razcore-rad you might be interested in looking into what David Lettier has been doing in building Lambda Lantern: https://medium.com/@lettier/how-to-create-3d-games-with-purescript-and-cpp-faabf8f27fe6