js_of_ocaml
js_of_ocaml copied to clipboard
Addition of web GL2 [FEATURE REQUEST]
webGL2 is now pretty standard and js_of_ocaml only supports webGL1 and a few extension.
I actually started working on that... But there are a lot of valid combinations of internal format / format / type in function like texImage2D.
This raises two questions:
- Do` we want to accept only valid combination at compile time (probably no as webGL is not type safe in many places)
- How to manage the numerous values that are common ? The current situation with type/pixelType and format/pixelFormat is more of less broken by webGL2 with the current type of function.
I'm not very familiar with the Webgl api and the difference between GL1 and Gl2. Would you be able to provide more information and maybe concrete examples covering your two points above.
Just in case you want something right now® I'd just mention that brr
has bindings to webgl2 here (hello triangle here) . Regarding the larger question of whether you want to type the GL APIs I'd say it's more trouble than benefits.
On 22-01-18 06:07:03, hhugo wrote:
I'm not very familiar with the Webgl api and the difference between GL1 and Gl2. Would you be able to provide more information and maybe concrete examples covering your two points above.
The main differences are:
- creation by passing "webgl2" to getContext
- a few more functions
- many many more options for existing functions.
Look for instance at
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D
The number of possible values for internalformat and format exploses.
Some of these values are very usefull for shadow mapping, fine tunning of performance and other modern techniques in GL.
Moreover, webGL1, is more or less deprecated in practice.
I have a version of js_of_ocaml working with webGL2 and only the extension I need currently. To finish the port I need to take a decision regarding the webGL type
dataType / pixelType / pixelFormat.
with webGL2, type and pixelType have many more common values in webGL there was only method _UNSIGNED_BYTE_DT : dataType readonly_prop method UNSIGNED_BYTE : pixelType readonly_prop
in webGL there was no distinction between format and internalFormat (both represented as pixelFormat).
I think these should be moved to parametric types
'a dataType and 'a pixelFormat
using a phantom type to distinguish the various usages.
for instance this would give:
method texImage2D_new :
texTarget
-> int
-> [`TexImageInternal] pixelFormat
-> sizei
-> sizei
-> int
-> [`TexImage] pixelFormat
-> [`TexImage] dataType
-> void opt
-> unit meth
An option to go further would be to add more parameter to the types to handle the coherence between the 3 arguments with something like:
method texImage2D_new :
texTarget
-> int
-> ([`TexImageInternal],'a,'b) pixelFormat
-> sizei
-> sizei
-> int
-> ([`TexImage],'a) pixelFormat
-> ([`TexImage],'b) dataType
-> void opt
-> unit meth
But this requires a lot of investigations ... and probably auto generation.
Cheers, Christophe
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: <ocsigen/ @.**>
-- Christophe Raffalli tél: +689 87 23 11 48 web: http://raffalli.eu