haskell-opengl / OpenGL

Haskell bindings to OpenGL
http://www.haskell.org/haskellwiki/OpenGL
BSD 3-Clause "New" or "Revised" License
147 stars 26 forks source link

Missing OpenGL 3.x style extension string queries #56

Open blitzcode opened 9 years ago

blitzcode commented 9 years ago

The existing extension string functionality is deprecated in modern OpenGL, would be nice if something along the lines of this could be added to the wrapper:

getNumExtensions :: IO Int
getNumExtensions =
    alloca $ \(ptr :: Ptr GLR.GLint) ->
        GLR.glGetIntegerv GLR.gl_NUM_EXTENSIONS ptr >> fromIntegral <$> peek ptr

getExtensionStr :: Int -> IO String
getExtensionStr i =
    peekCString =<< castPtr <$> GLR.glGetStringi GLR.gl_EXTENSIONS (fromIntegral i)

getGLExtensionList :: IO [String]
getGLExtensionList =
  getNumExtensions >>= \numExt -> forM [0..numExt - 1] $ \i -> getExtensionStr i