[HOpenGL] Shader API changes

Sven Panne svenpanne at gmail.com
Mon Aug 12 19:32:32 CEST 2013


To make my previous thoughts on ObjectNames a little bit more
concrete, here one possible solution: We could split the ObjectName
class into 2 parts like this:

   class NameSpace a where  -- Do we need a better name? Not sure...
      deleteObjectNames:: [a] -> IO ()
      isObjectName :: a -> IO Bool

   class NameSpace a => ObjectName a where
      genObjectNames :: Int -> IO [a]

All object kinds in OpenGL can be instances of NameSpace, and almost
all kinds can be instances of ObjectName, too. Shader objects and sync
objects would only be instances of NameSpace, not of ObjectName. They
would have creation functions taking additional arguments like:

   createShader :: ShaderType -> IO Shader
   fenceSync :: Condition -> [Flags] -> IO Sync

It is debatable if Program should be an instance of ObjectName or not:
glCreateProgram doesn't need parameters, but it immediately creates a
program + a name, not only the name. A separate createProgram function
would make this clearer, but I don't have a strong opinion regarding
that.

One could perhaps make some tricks with MPTC and functional
dependencies to unify these creation functions a bit, but I would like
to avoid type system extensions.

Hints/proposals/rants appreciated, as usual. :-)




More information about the HOpenGL mailing list