summaryrefslogtreecommitdiffstats
path: root/Bindings/GLX.chs
diff options
context:
space:
mode:
Diffstat (limited to 'Bindings/GLX.chs')
-rw-r--r--Bindings/GLX.chs19
1 files changed, 10 insertions, 9 deletions
diff --git a/Bindings/GLX.chs b/Bindings/GLX.chs
index dcf235e..58bc8cf 100644
--- a/Bindings/GLX.chs
+++ b/Bindings/GLX.chs
@@ -7,7 +7,6 @@ module Bindings.GLX ( createColormap
, VisualInfo(..)
, SetWindowAttributes(..)
, nullSetWindowAttributes
- , getVisualFromFBConfig
, renderType
, rgbaBit
, drawableType
@@ -16,7 +15,6 @@ module Bindings.GLX ( createColormap
, doublebuffer
, depthSize
, stencilSize
- , true
, createContext
, makeCurrent
, Context(..)
@@ -27,13 +25,14 @@ import Data.Int
import Data.Word
import Foreign.C.Types
+import Foreign.ForeignPtr
import Foreign.Ptr
import Foreign.Marshal.Alloc (alloca)
import Foreign.Marshal.Array (peekArray, withArray0)
import Foreign.Storable
import Graphics.X11.Types (AttributeMask, Colormap, ColormapAlloc, Cursor, EventMask, Pixmap, Window, WindowClass, VisualID, XID)
-import Graphics.X11.Xlib.Extras (none)
+import Graphics.X11.Xlib.Extras (none, xFree)
import Graphics.X11.Xlib.Types (Dimension, Display, Pixel, Position)
@@ -198,7 +197,10 @@ chooseFBConfig :: Display -> CInt -> [(CInt, CInt)] -> IO [FBConfig]
chooseFBConfig disp sc attr = alloca $ \n -> withArray0 (fromIntegral none) (concatMap (\(a,b) -> [a,b]) attr) $ \attrp -> do
configs <- glXChooseFBConfig disp sc attrp n
nelements <- peek n
- peekArray (fromIntegral nelements) configs
+ configlist <- peekArray (fromIntegral nelements) configs
+ xFree configs
+ return configlist
+
renderType :: CInt
renderType = (#const GLX_RENDER_TYPE)
@@ -224,16 +226,15 @@ depthSize = (#const GLX_DEPTH_SIZE)
stencilSize :: CInt
stencilSize = (#const GLX_STENCIL_SIZE)
-true :: CInt
-true = (#const True)
-
foreign import ccall unsafe "GL/glx.h glXGetVisualFromFBConfig"
glXGetVisualFromFBConfig :: Display -> FBConfig -> IO (Ptr VisualInfo)
getVisualFromFBConfig :: Display -> FBConfig -> IO (VisualInfo)
getVisualFromFBConfig disp config = do
- vi <- glXGetVisualFromFBConfig disp config
- peek vi
+ viptr <- glXGetVisualFromFBConfig disp config
+ vi <- peek viptr
+ xFree viptr
+ return vi
foreign import ccall unsafe "GL/glx.h glXCreateContext"
createContext :: Display -> Ptr VisualInfo -> Context -> Bool -> IO Context