Haskell SDL2访问GLContext Ptr

时间:2019-07-14 16:25:34

标签: haskell sdl

我正在尝试访问SDL2库提供的Ptr中的GLContext值。这是获取GLContext的函数:http://hackage.haskell.org/package/sdl2-2.5.0.0/docs/SDL-Video-OpenGL.html#v:glCreateContext

我如何访问内部的Ptr

import qualified SDL                as SDL
import qualified SDL.Internal.Types as SDL

main :: IO ()
main = do
  SDL.initializeAll
  window @ (SDL.Window wp) <- SDL.createWindow "My SDL Application" SDL.defaultWindow
  context @ (SDL.GLContext gl) <- SDL.glCreateContext window
  putStrLn $ show wp

但是我得到的错误是:

Not in scope: data constructor ‘SDL.GLContext’
Neither ‘SDL’ nor ‘SDL.Internal.Types’ exports ‘
   |
15 |   context @ (SDL.GLContext gl) <- SDL.glCreateContext window

构造函数似乎已导出。我在做什么错了?

1 个答案:

答案 0 :(得分:0)

我最终弄清楚了。我可以使用Raw.Video模块,该模块具有一个glCreateContext函数,该函数返回所需的类型。