Re: [HOpenGL] [Haskell-cafe] Merging the OpenGLRaw and gl packages

2015-10-01 11:01 GMT+02:00 Oliver Charles
[...] However, it's a lot more significant if you want to do something like:
foo x = doSomething (case x of ...)
Without pattern synonyms, you either have
foo x = doSomething x' where x' | x == ... = ...
or
{-# LANGUAGE MultiWayIf #-}
foo x = doSomething (if | x == ... -> ...)
Or simply in plain old Haskell (basically the desugaring of the multi-way-if): foo x = doSomething (case () of _ | x == gl_BAR -> expr1 | x == gl_BAZ -> expr2 | otherwise -> expr3) Compared to: foo x = doSomething (case x of GL_BAR -> expr1 GL_BAZ -> expr2 _ .> expr3) it doesn't really look *that* much different IMHO, given the high price one has to pay for a tiny improvement in readability. But that's my personal, more conservative view of things, and I'm here to see what other people prefer.Alas, up to now, this is not very conclusive... :-/

FYI: I've released a new OpenGLRaw version 3.0.0.0 which is now quite close to the gl package. The changes: * Use pattern synonyms for OpenGL enums. * Changed module name prefix from Graphics.Rendering.OpenGL.Raw to Graphics.GL. * Use slightly different type synonyms for GL type (introducing Fixed on the way): * CDouble => Double (for GLclampd, GLdouble) * CFloat => Float (for GLclampf, GLfloat) * CInt => Fixed (for GLclampx, GLfixed) * CInt => Int32 (for GLint, GLsizei) * CSChar => Int8 (for GLbyte) * CShort => Int16 (for GLshort) * CUChar => Word8 (for GLboolean, GLubyte) * CUInt => Word32 (for GLbitfield, GLenum, GLhandleARB, GLuint) * CUShort => Word16 (for GLushort) There are still a few minor differences between OpenGLRaw and gl (see https://github.com/haskell-opengl/OpenGLRaw/wiki/Merging-OpenGLRaw-and-gl), but nothing serious: As a test, I modified the luminance package to make it compatible with the new OpenGLRaw, and the diff is really small (see https://github.com/phaazon/luminance/pull/39). So I think that the gl package can be retired, but that's of course totally up to Edward and Gabríel. A few remarks: * Using pattern synonyms means losing support for GHC < 7.8, which I consider OK now that 8.0 is coming soon. But to be sure, there is a branch ("classic") for the previous OpenGLRaw API if the need for minor changes/bug fixes arises. * To stay consistent, GLURaw has been changed in a similar way. * The OpenGL package has been adapted to use the new APIs internally, but its external API is still the same. Cheers, S.

After some discussions and looking at the diffs needed to make the `luminance` package and Oliver Charles' SSAO-example use OpenGLRaw instead of gl, I decided to change the types of GL_TRUE and GL_FALSE from GLenum to GLboolean. When these enums are used as parameters, their type is almost always GLboolean, with glClampColor being the only exception. Some general retrieval functions like glProgramiv return boolean values as GLint, but that seems to be the rarer use case. OpenGL is very loosely typed, so you will have to use some fromIntegral calls, even if the enum patterns were more polymorphic. After several decades of computer science and having seen tons of bugs caused by them, I have a strong aversion to implicit conversions, so I'm still convinced that the monomorphic enums are the right thing. :-) I made a new release of OpenGLRaw ( https://github.com/haskell-opengl/OpenGLRaw/releases/tag/v3.1.0.0), which in addition to this typing change contains some "mkFoo" synonyms for the "makeFoo" functions, too, a difference between OpenGLRaw and gl I didn't notice earlier. Cheers, S.
participants (1)
-
Sven Panne