module Graphics.UI.Gtk.OpenGL.Types (
module Graphics.UI.GtkInternals,
GLPixmap(GLPixmap), GLPixmapClass,
toGLPixmap,
mkGLPixmap, unGLPixmap,
castToGLPixmap, gTypeGLPixmap,
GLWindow(GLWindow), GLWindowClass,
toGLWindow,
mkGLWindow, unGLWindow,
castToGLWindow, gTypeGLWindow,
GLContext(GLContext), GLContextClass,
toGLContext,
mkGLContext, unGLContext,
castToGLContext, gTypeGLContext,
GLConfig(GLConfig), GLConfigClass,
toGLConfig,
mkGLConfig, unGLConfig,
castToGLConfig, gTypeGLConfig,
GLDrawable(GLDrawable), GLDrawableClass,
toGLDrawable,
mkGLDrawable, unGLDrawable,
castToGLDrawable, gTypeGLDrawable
) where
import Foreign.ForeignPtr (ForeignPtr, castForeignPtr, unsafeForeignPtrToPtr)
import Foreign.C.Types (CULong, CUInt)
import System.Glib.GType (GType, typeInstanceIsA)
import Graphics.UI.GtkInternals
castTo :: (GObjectClass obj, GObjectClass obj') => GType -> String
-> (obj -> obj')
castTo gtype objTypeName obj =
case toGObject obj of
gobj@(GObject objFPtr)
| typeInstanceIsA ((unsafeForeignPtrToPtr.castForeignPtr) objFPtr) gtype
-> unsafeCastGObject gobj
| otherwise -> error $ "Cannot cast object to " ++ objTypeName
newtype GLPixmap = GLPixmap (ForeignPtr (GLPixmap)) deriving (Eq,Ord)
mkGLPixmap = (GLPixmap, objectUnrefFromMainloop)
unGLPixmap (GLPixmap o) = o
class DrawableClass o => GLPixmapClass o
toGLPixmap :: GLPixmapClass o => o -> GLPixmap
toGLPixmap = unsafeCastGObject . toGObject
instance GLPixmapClass GLPixmap
instance DrawableClass GLPixmap
instance GObjectClass GLPixmap where
toGObject = GObject . castForeignPtr . unGLPixmap
unsafeCastGObject = GLPixmap . castForeignPtr . unGObject
castToGLPixmap :: GObjectClass obj => obj -> GLPixmap
castToGLPixmap = castTo gTypeGLPixmap "GLPixmap"
gTypeGLPixmap :: GType
gTypeGLPixmap =
gdk_gl_pixmap_get_type
newtype GLWindow = GLWindow (ForeignPtr (GLWindow)) deriving (Eq,Ord)
mkGLWindow = (GLWindow, objectUnrefFromMainloop)
unGLWindow (GLWindow o) = o
class DrawableClass o => GLWindowClass o
toGLWindow :: GLWindowClass o => o -> GLWindow
toGLWindow = unsafeCastGObject . toGObject
instance GLWindowClass GLWindow
instance DrawableClass GLWindow
instance GObjectClass GLWindow where
toGObject = GObject . castForeignPtr . unGLWindow
unsafeCastGObject = GLWindow . castForeignPtr . unGObject
castToGLWindow :: GObjectClass obj => obj -> GLWindow
castToGLWindow = castTo gTypeGLWindow "GLWindow"
gTypeGLWindow :: GType
gTypeGLWindow =
gdk_gl_window_get_type
newtype GLContext = GLContext (ForeignPtr (GLContext)) deriving (Eq,Ord)
mkGLContext = (GLContext, objectUnrefFromMainloop)
unGLContext (GLContext o) = o
class GObjectClass o => GLContextClass o
toGLContext :: GLContextClass o => o -> GLContext
toGLContext = unsafeCastGObject . toGObject
instance GLContextClass GLContext
instance GObjectClass GLContext where
toGObject = GObject . castForeignPtr . unGLContext
unsafeCastGObject = GLContext . castForeignPtr . unGObject
castToGLContext :: GObjectClass obj => obj -> GLContext
castToGLContext = castTo gTypeGLContext "GLContext"
gTypeGLContext :: GType
gTypeGLContext =
gdk_gl_context_get_type
newtype GLConfig = GLConfig (ForeignPtr (GLConfig)) deriving (Eq,Ord)
mkGLConfig = (GLConfig, objectUnrefFromMainloop)
unGLConfig (GLConfig o) = o
class GObjectClass o => GLConfigClass o
toGLConfig :: GLConfigClass o => o -> GLConfig
toGLConfig = unsafeCastGObject . toGObject
instance GLConfigClass GLConfig
instance GObjectClass GLConfig where
toGObject = GObject . castForeignPtr . unGLConfig
unsafeCastGObject = GLConfig . castForeignPtr . unGObject
castToGLConfig :: GObjectClass obj => obj -> GLConfig
castToGLConfig = castTo gTypeGLConfig "GLConfig"
gTypeGLConfig :: GType
gTypeGLConfig =
gdk_gl_config_get_type
newtype GLDrawable = GLDrawable (ForeignPtr (GLDrawable)) deriving (Eq,Ord)
mkGLDrawable = (GLDrawable, objectUnrefFromMainloop)
unGLDrawable (GLDrawable o) = o
class GObjectClass o => GLDrawableClass o
toGLDrawable :: GLDrawableClass o => o -> GLDrawable
toGLDrawable = unsafeCastGObject . toGObject
instance GLDrawableClass GLDrawable
instance GObjectClass GLDrawable where
toGObject = GObject . castForeignPtr . unGLDrawable
unsafeCastGObject = GLDrawable . castForeignPtr . unGObject
castToGLDrawable :: GObjectClass obj => obj -> GLDrawable
castToGLDrawable = castTo gTypeGLDrawable "GLDrawable"
gTypeGLDrawable :: GType
gTypeGLDrawable =
gdk_gl_drawable_get_type
foreign import ccall unsafe "gdk_gl_pixmap_get_type"
gdk_gl_pixmap_get_type :: CUInt
foreign import ccall unsafe "gdk_gl_window_get_type"
gdk_gl_window_get_type :: CUInt
foreign import ccall unsafe "gdk_gl_context_get_type"
gdk_gl_context_get_type :: CUInt
foreign import ccall unsafe "gdk_gl_config_get_type"
gdk_gl_config_get_type :: CUInt
foreign import ccall unsafe "gdk_gl_drawable_get_type"
gdk_gl_drawable_get_type :: CUInt