{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} module GI.Gdk.Objects.GLContext ( -- * Exported types GLContext(..) , GLContextK , toGLContext , noGLContext , -- * Methods -- ** gLContextClearCurrent gLContextClearCurrent , -- ** gLContextGetCurrent gLContextGetCurrent , -- ** gLContextGetDebugEnabled gLContextGetDebugEnabled , -- ** gLContextGetDisplay gLContextGetDisplay , -- ** gLContextGetForwardCompatible gLContextGetForwardCompatible , -- ** gLContextGetSharedContext gLContextGetSharedContext , -- ** gLContextGetVersion gLContextGetVersion , -- ** gLContextGetWindow gLContextGetWindow , -- ** gLContextMakeCurrent gLContextMakeCurrent , -- ** gLContextRealize gLContextRealize , -- ** gLContextSetDebugEnabled gLContextSetDebugEnabled , -- ** gLContextSetForwardCompatible gLContextSetForwardCompatible , -- ** gLContextSetRequiredVersion gLContextSetRequiredVersion , -- * Properties -- ** Display GLContextDisplayPropertyInfo , constructGLContextDisplay , getGLContextDisplay , -- ** SharedContext GLContextSharedContextPropertyInfo , constructGLContextSharedContext , getGLContextSharedContext , -- ** Window GLContextWindowPropertyInfo , constructGLContextWindow , getGLContextWindow , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.Gdk.Types import GI.Gdk.Callbacks import qualified GI.GObject as GObject newtype GLContext = GLContext (ForeignPtr GLContext) foreign import ccall "gdk_gl_context_get_type" c_gdk_gl_context_get_type :: IO GType type instance ParentTypes GLContext = GLContextParentTypes type GLContextParentTypes = '[GObject.Object] instance GObject GLContext where gobjectIsInitiallyUnowned _ = False gobjectType _ = c_gdk_gl_context_get_type class GObject o => GLContextK o instance (GObject o, IsDescendantOf GLContext o) => GLContextK o toGLContext :: GLContextK o => o -> IO GLContext toGLContext = unsafeCastTo GLContext noGLContext :: Maybe GLContext noGLContext = Nothing -- VVV Prop "display" -- Type: TInterface "Gdk" "Display" -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly] getGLContextDisplay :: (MonadIO m, GLContextK o) => o -> m Display getGLContextDisplay obj = liftIO $ getObjectPropertyObject obj "display" Display constructGLContextDisplay :: (DisplayK a) => a -> IO ([Char], GValue) constructGLContextDisplay val = constructObjectPropertyObject "display" val data GLContextDisplayPropertyInfo instance AttrInfo GLContextDisplayPropertyInfo where type AttrAllowedOps GLContextDisplayPropertyInfo = '[ 'AttrConstruct, 'AttrGet] type AttrSetTypeConstraint GLContextDisplayPropertyInfo = DisplayK type AttrBaseTypeConstraint GLContextDisplayPropertyInfo = GLContextK type AttrGetType GLContextDisplayPropertyInfo = Display type AttrLabel GLContextDisplayPropertyInfo = "GLContext::display" attrGet _ = getGLContextDisplay attrSet _ = undefined attrConstruct _ = constructGLContextDisplay -- VVV Prop "shared-context" -- Type: TInterface "Gdk" "GLContext" -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly] getGLContextSharedContext :: (MonadIO m, GLContextK o) => o -> m GLContext getGLContextSharedContext obj = liftIO $ getObjectPropertyObject obj "shared-context" GLContext constructGLContextSharedContext :: (GLContextK a) => a -> IO ([Char], GValue) constructGLContextSharedContext val = constructObjectPropertyObject "shared-context" val data GLContextSharedContextPropertyInfo instance AttrInfo GLContextSharedContextPropertyInfo where type AttrAllowedOps GLContextSharedContextPropertyInfo = '[ 'AttrConstruct, 'AttrGet] type AttrSetTypeConstraint GLContextSharedContextPropertyInfo = GLContextK type AttrBaseTypeConstraint GLContextSharedContextPropertyInfo = GLContextK type AttrGetType GLContextSharedContextPropertyInfo = GLContext type AttrLabel GLContextSharedContextPropertyInfo = "GLContext::shared-context" attrGet _ = getGLContextSharedContext attrSet _ = undefined attrConstruct _ = constructGLContextSharedContext -- VVV Prop "window" -- Type: TInterface "Gdk" "Window" -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly] getGLContextWindow :: (MonadIO m, GLContextK o) => o -> m Window getGLContextWindow obj = liftIO $ getObjectPropertyObject obj "window" Window constructGLContextWindow :: (WindowK a) => a -> IO ([Char], GValue) constructGLContextWindow val = constructObjectPropertyObject "window" val data GLContextWindowPropertyInfo instance AttrInfo GLContextWindowPropertyInfo where type AttrAllowedOps GLContextWindowPropertyInfo = '[ 'AttrConstruct, 'AttrGet] type AttrSetTypeConstraint GLContextWindowPropertyInfo = WindowK type AttrBaseTypeConstraint GLContextWindowPropertyInfo = GLContextK type AttrGetType GLContextWindowPropertyInfo = Window type AttrLabel GLContextWindowPropertyInfo = "GLContext::window" attrGet _ = getGLContextWindow attrSet _ = undefined attrConstruct _ = constructGLContextWindow type instance AttributeList GLContext = GLContextAttributeList type GLContextAttributeList = ('[ '("display", GLContextDisplayPropertyInfo), '("shared-context", GLContextSharedContextPropertyInfo), '("window", GLContextWindowPropertyInfo)] :: [(Symbol, *)]) type instance SignalList GLContext = GLContextSignalList type GLContextSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)]) -- method GLContext::get_debug_enabled -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_get_debug_enabled" gdk_gl_context_get_debug_enabled :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" IO CInt gLContextGetDebugEnabled :: (MonadIO m, GLContextK a) => a -> -- _obj m Bool gLContextGetDebugEnabled _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_gl_context_get_debug_enabled _obj' let result' = (/= 0) result touchManagedPtr _obj return result' -- method GLContext::get_display -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Display" -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_get_display" gdk_gl_context_get_display :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" IO (Ptr Display) gLContextGetDisplay :: (MonadIO m, GLContextK a) => a -> -- _obj m Display gLContextGetDisplay _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_gl_context_get_display _obj' checkUnexpectedReturnNULL "gdk_gl_context_get_display" result result' <- (newObject Display) result touchManagedPtr _obj return result' -- method GLContext::get_forward_compatible -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_get_forward_compatible" gdk_gl_context_get_forward_compatible :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" IO CInt gLContextGetForwardCompatible :: (MonadIO m, GLContextK a) => a -> -- _obj m Bool gLContextGetForwardCompatible _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_gl_context_get_forward_compatible _obj' let result' = (/= 0) result touchManagedPtr _obj return result' -- XXX Could not generate method GLContext::get_required_version -- Error was : Bad introspection data: "argument \"major\" is not of nullable type (TBasicType TInt32), but it is marked as such." -- method GLContext::get_shared_context -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "GLContext" -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_get_shared_context" gdk_gl_context_get_shared_context :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" IO (Ptr GLContext) gLContextGetSharedContext :: (MonadIO m, GLContextK a) => a -> -- _obj m GLContext gLContextGetSharedContext _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_gl_context_get_shared_context _obj' checkUnexpectedReturnNULL "gdk_gl_context_get_shared_context" result result' <- (newObject GLContext) result touchManagedPtr _obj return result' -- method GLContext::get_version -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "major", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "minor", argType = TBasicType TInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_get_version" gdk_gl_context_get_version :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" Ptr Int32 -> -- major : TBasicType TInt32 Ptr Int32 -> -- minor : TBasicType TInt32 IO () gLContextGetVersion :: (MonadIO m, GLContextK a) => a -> -- _obj m (Int32,Int32) gLContextGetVersion _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj major <- allocMem :: IO (Ptr Int32) minor <- allocMem :: IO (Ptr Int32) gdk_gl_context_get_version _obj' major minor major' <- peek major minor' <- peek minor touchManagedPtr _obj freeMem major freeMem minor return (major', minor') -- method GLContext::get_window -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gdk" "Window" -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_get_window" gdk_gl_context_get_window :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" IO (Ptr Window) gLContextGetWindow :: (MonadIO m, GLContextK a) => a -> -- _obj m Window gLContextGetWindow _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- gdk_gl_context_get_window _obj' checkUnexpectedReturnNULL "gdk_gl_context_get_window" result result' <- (newObject Window) result touchManagedPtr _obj return result' -- method GLContext::make_current -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_make_current" gdk_gl_context_make_current :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" IO () gLContextMakeCurrent :: (MonadIO m, GLContextK a) => a -> -- _obj m () gLContextMakeCurrent _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj gdk_gl_context_make_current _obj' touchManagedPtr _obj return () -- method GLContext::realize -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : True -- Skip return : False foreign import ccall "gdk_gl_context_realize" gdk_gl_context_realize :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" Ptr (Ptr GError) -> -- error IO CInt gLContextRealize :: (MonadIO m, GLContextK a) => a -> -- _obj m () gLContextRealize _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj onException (do _ <- propagateGError $ gdk_gl_context_realize _obj' touchManagedPtr _obj return () ) (do return () ) -- method GLContext::set_debug_enabled -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "enabled", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "enabled", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_set_debug_enabled" gdk_gl_context_set_debug_enabled :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" CInt -> -- enabled : TBasicType TBoolean IO () gLContextSetDebugEnabled :: (MonadIO m, GLContextK a) => a -> -- _obj Bool -> -- enabled m () gLContextSetDebugEnabled _obj enabled = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let enabled' = (fromIntegral . fromEnum) enabled gdk_gl_context_set_debug_enabled _obj' enabled' touchManagedPtr _obj return () -- method GLContext::set_forward_compatible -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "compatible", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "compatible", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_set_forward_compatible" gdk_gl_context_set_forward_compatible :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" CInt -> -- compatible : TBasicType TBoolean IO () gLContextSetForwardCompatible :: (MonadIO m, GLContextK a) => a -> -- _obj Bool -> -- compatible m () gLContextSetForwardCompatible _obj compatible = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let compatible' = (fromIntegral . fromEnum) compatible gdk_gl_context_set_forward_compatible _obj' compatible' touchManagedPtr _obj return () -- method GLContext::set_required_version -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "major", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "minor", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "GLContext", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "major", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "minor", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_set_required_version" gdk_gl_context_set_required_version :: Ptr GLContext -> -- _obj : TInterface "Gdk" "GLContext" Int32 -> -- major : TBasicType TInt32 Int32 -> -- minor : TBasicType TInt32 IO () gLContextSetRequiredVersion :: (MonadIO m, GLContextK a) => a -> -- _obj Int32 -> -- major Int32 -> -- minor m () gLContextSetRequiredVersion _obj major minor = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj gdk_gl_context_set_required_version _obj' major minor touchManagedPtr _obj return () -- method GLContext::clear_current -- method type : MemberFunction -- Args : [] -- Lengths : [] -- hInArgs : [] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_clear_current" gdk_gl_context_clear_current :: IO () gLContextClearCurrent :: (MonadIO m) => m () gLContextClearCurrent = liftIO $ do gdk_gl_context_clear_current return () -- method GLContext::get_current -- method type : MemberFunction -- Args : [] -- Lengths : [] -- hInArgs : [] -- returnType : TInterface "Gdk" "GLContext" -- throws : False -- Skip return : False foreign import ccall "gdk_gl_context_get_current" gdk_gl_context_get_current :: IO (Ptr GLContext) gLContextGetCurrent :: (MonadIO m) => m GLContext gLContextGetCurrent = liftIO $ do result <- gdk_gl_context_get_current checkUnexpectedReturnNULL "gdk_gl_context_get_current" result result' <- (newObject GLContext) result return result'