{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.Gdk.Objects.GLContext.GLContext' is an object representing the platform-specific
OpenGL drawing context.

@/GdkGLContexts/@ are created for a 'GI.Gdk.Objects.Window.Window' using
'GI.Gdk.Objects.Window.windowCreateGlContext', and the context will match
the 'GI.Gdk.Objects.Visual.Visual' of the window.

A 'GI.Gdk.Objects.GLContext.GLContext' is not tied to any particular normal framebuffer.
For instance, it cannot draw to the 'GI.Gdk.Objects.Window.Window' back buffer. The GDK
repaint system is in full control of the painting to that. Instead,
you can create render buffers or textures and use 'GI.Gdk.Functions.cairoDrawFromGl'
in the draw function of your widget to draw them. Then GDK will handle
the integration of your rendering with that of other widgets.

Support for 'GI.Gdk.Objects.GLContext.GLContext' is platform-specific, context creation
can fail, returning 'Nothing' context.

A 'GI.Gdk.Objects.GLContext.GLContext' has to be made \"current\" in order to start using
it, otherwise any OpenGL call will be ignored.

== Creating a new OpenGL context 

In order to create a new 'GI.Gdk.Objects.GLContext.GLContext' instance you need a
'GI.Gdk.Objects.Window.Window', which you typically get during the realize call
of a widget.

A 'GI.Gdk.Objects.GLContext.GLContext' is not realized until either 'GI.Gdk.Objects.GLContext.gLContextMakeCurrent',
or until it is realized using 'GI.Gdk.Objects.GLContext.gLContextRealize'. It is possible to
specify details of the GL context like the OpenGL version to be used, or
whether the GL context should have extra state validation enabled after
calling 'GI.Gdk.Objects.Window.windowCreateGlContext' by calling 'GI.Gdk.Objects.GLContext.gLContextRealize'.
If the realization fails you have the option to change the settings of the
'GI.Gdk.Objects.GLContext.GLContext' and try again.

== Using a GdkGLContext 

You will need to make the 'GI.Gdk.Objects.GLContext.GLContext' the current context
before issuing OpenGL calls; the system sends OpenGL commands to
whichever context is current. It is possible to have multiple
contexts, so you always need to ensure that the one which you
want to draw with is the current one before issuing commands:


=== /C code/
>
>  gdk_gl_context_make_current (context);


You can now perform your drawing using OpenGL commands.

You can check which 'GI.Gdk.Objects.GLContext.GLContext' is the current one by using
'GI.Gdk.Objects.GLContext.gLContextGetCurrent'; you can also unset any 'GI.Gdk.Objects.GLContext.GLContext'
that is currently set by calling 'GI.Gdk.Objects.GLContext.gLContextClearCurrent'.
-}

module GI.Gdk.Objects.GLContext
    ( 

-- * Exported types
    GLContext(..)                           ,
    IsGLContext                             ,
    toGLContext                             ,
    noGLContext                             ,


 -- * Methods
-- ** clearCurrent #method:clearCurrent#
    gLContextClearCurrent                   ,


-- ** getCurrent #method:getCurrent#
    gLContextGetCurrent                     ,


-- ** getDebugEnabled #method:getDebugEnabled#
    GLContextGetDebugEnabledMethodInfo      ,
    gLContextGetDebugEnabled                ,


-- ** getDisplay #method:getDisplay#
    GLContextGetDisplayMethodInfo           ,
    gLContextGetDisplay                     ,


-- ** getForwardCompatible #method:getForwardCompatible#
    GLContextGetForwardCompatibleMethodInfo ,
    gLContextGetForwardCompatible           ,


-- ** getRequiredVersion #method:getRequiredVersion#
    GLContextGetRequiredVersionMethodInfo   ,
    gLContextGetRequiredVersion             ,


-- ** getSharedContext #method:getSharedContext#
    GLContextGetSharedContextMethodInfo     ,
    gLContextGetSharedContext               ,


-- ** getUseEs #method:getUseEs#
    GLContextGetUseEsMethodInfo             ,
    gLContextGetUseEs                       ,


-- ** getVersion #method:getVersion#
    GLContextGetVersionMethodInfo           ,
    gLContextGetVersion                     ,


-- ** getWindow #method:getWindow#
    GLContextGetWindowMethodInfo            ,
    gLContextGetWindow                      ,


-- ** isLegacy #method:isLegacy#
    GLContextIsLegacyMethodInfo             ,
    gLContextIsLegacy                       ,


-- ** makeCurrent #method:makeCurrent#
    GLContextMakeCurrentMethodInfo          ,
    gLContextMakeCurrent                    ,


-- ** realize #method:realize#
    GLContextRealizeMethodInfo              ,
    gLContextRealize                        ,


-- ** setDebugEnabled #method:setDebugEnabled#
    GLContextSetDebugEnabledMethodInfo      ,
    gLContextSetDebugEnabled                ,


-- ** setForwardCompatible #method:setForwardCompatible#
    GLContextSetForwardCompatibleMethodInfo ,
    gLContextSetForwardCompatible           ,


-- ** setRequiredVersion #method:setRequiredVersion#
    GLContextSetRequiredVersionMethodInfo   ,
    gLContextSetRequiredVersion             ,


-- ** setUseEs #method:setUseEs#
    GLContextSetUseEsMethodInfo             ,
    gLContextSetUseEs                       ,




 -- * Properties
-- ** display #attr:display#
    GLContextDisplayPropertyInfo            ,
    constructGLContextDisplay               ,
    gLContextDisplay                        ,
    getGLContextDisplay                     ,


-- ** sharedContext #attr:sharedContext#
    GLContextSharedContextPropertyInfo      ,
    constructGLContextSharedContext         ,
    gLContextSharedContext                  ,
    getGLContextSharedContext               ,


-- ** window #attr:window#
    GLContextWindowPropertyInfo             ,
    constructGLContextWindow                ,
    gLContextWindow                         ,
    getGLContextWindow                      ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gdk.Objects.Display as Gdk.Display
import {-# SOURCE #-} qualified GI.Gdk.Objects.Window as Gdk.Window

newtype GLContext = GLContext (ManagedPtr GLContext)
foreign import ccall "gdk_gl_context_get_type"
    c_gdk_gl_context_get_type :: IO GType

instance GObject GLContext where
    gobjectType _ = c_gdk_gl_context_get_type
    

class GObject o => IsGLContext o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError GLContext a) =>
    IsGLContext a
#endif
instance IsGLContext GLContext
instance GObject.Object.IsObject GLContext

toGLContext :: IsGLContext o => o -> IO GLContext
toGLContext = unsafeCastTo GLContext

noGLContext :: Maybe GLContext
noGLContext = Nothing

type family ResolveGLContextMethod (t :: Symbol) (o :: *) :: * where
    ResolveGLContextMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveGLContextMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveGLContextMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveGLContextMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveGLContextMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveGLContextMethod "isLegacy" o = GLContextIsLegacyMethodInfo
    ResolveGLContextMethod "makeCurrent" o = GLContextMakeCurrentMethodInfo
    ResolveGLContextMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveGLContextMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveGLContextMethod "realize" o = GLContextRealizeMethodInfo
    ResolveGLContextMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveGLContextMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveGLContextMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveGLContextMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveGLContextMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveGLContextMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveGLContextMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveGLContextMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveGLContextMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveGLContextMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveGLContextMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveGLContextMethod "getDebugEnabled" o = GLContextGetDebugEnabledMethodInfo
    ResolveGLContextMethod "getDisplay" o = GLContextGetDisplayMethodInfo
    ResolveGLContextMethod "getForwardCompatible" o = GLContextGetForwardCompatibleMethodInfo
    ResolveGLContextMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveGLContextMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveGLContextMethod "getRequiredVersion" o = GLContextGetRequiredVersionMethodInfo
    ResolveGLContextMethod "getSharedContext" o = GLContextGetSharedContextMethodInfo
    ResolveGLContextMethod "getUseEs" o = GLContextGetUseEsMethodInfo
    ResolveGLContextMethod "getVersion" o = GLContextGetVersionMethodInfo
    ResolveGLContextMethod "getWindow" o = GLContextGetWindowMethodInfo
    ResolveGLContextMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveGLContextMethod "setDebugEnabled" o = GLContextSetDebugEnabledMethodInfo
    ResolveGLContextMethod "setForwardCompatible" o = GLContextSetForwardCompatibleMethodInfo
    ResolveGLContextMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveGLContextMethod "setRequiredVersion" o = GLContextSetRequiredVersionMethodInfo
    ResolveGLContextMethod "setUseEs" o = GLContextSetUseEsMethodInfo
    ResolveGLContextMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveGLContextMethod t GLContext, O.MethodInfo info GLContext p) => O.IsLabelProxy t (GLContext -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveGLContextMethod t GLContext, O.MethodInfo info GLContext p) => O.IsLabel t (GLContext -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "display"
   -- Type: TInterface (Name {namespace = "Gdk", name = "Display"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just True,Nothing)

getGLContextDisplay :: (MonadIO m, IsGLContext o) => o -> m (Maybe Gdk.Display.Display)
getGLContextDisplay obj = liftIO $ getObjectPropertyObject obj "display" Gdk.Display.Display

constructGLContextDisplay :: (IsGLContext o, Gdk.Display.IsDisplay a) => a -> IO (GValueConstruct o)
constructGLContextDisplay val = constructObjectPropertyObject "display" (Just val)

data GLContextDisplayPropertyInfo
instance AttrInfo GLContextDisplayPropertyInfo where
    type AttrAllowedOps GLContextDisplayPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint GLContextDisplayPropertyInfo = Gdk.Display.IsDisplay
    type AttrBaseTypeConstraint GLContextDisplayPropertyInfo = IsGLContext
    type AttrGetType GLContextDisplayPropertyInfo = (Maybe Gdk.Display.Display)
    type AttrLabel GLContextDisplayPropertyInfo = "display"
    type AttrOrigin GLContextDisplayPropertyInfo = GLContext
    attrGet _ = getGLContextDisplay
    attrSet _ = undefined
    attrConstruct _ = constructGLContextDisplay
    attrClear _ = undefined

-- VVV Prop "shared-context"
   -- Type: TInterface (Name {namespace = "Gdk", name = "GLContext"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just True,Nothing)

getGLContextSharedContext :: (MonadIO m, IsGLContext o) => o -> m (Maybe GLContext)
getGLContextSharedContext obj = liftIO $ getObjectPropertyObject obj "shared-context" GLContext

constructGLContextSharedContext :: (IsGLContext o, IsGLContext a) => a -> IO (GValueConstruct o)
constructGLContextSharedContext val = constructObjectPropertyObject "shared-context" (Just val)

data GLContextSharedContextPropertyInfo
instance AttrInfo GLContextSharedContextPropertyInfo where
    type AttrAllowedOps GLContextSharedContextPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint GLContextSharedContextPropertyInfo = IsGLContext
    type AttrBaseTypeConstraint GLContextSharedContextPropertyInfo = IsGLContext
    type AttrGetType GLContextSharedContextPropertyInfo = (Maybe GLContext)
    type AttrLabel GLContextSharedContextPropertyInfo = "shared-context"
    type AttrOrigin GLContextSharedContextPropertyInfo = GLContext
    attrGet _ = getGLContextSharedContext
    attrSet _ = undefined
    attrConstruct _ = constructGLContextSharedContext
    attrClear _ = undefined

-- VVV Prop "window"
   -- Type: TInterface (Name {namespace = "Gdk", name = "Window"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just True,Nothing)

getGLContextWindow :: (MonadIO m, IsGLContext o) => o -> m (Maybe Gdk.Window.Window)
getGLContextWindow obj = liftIO $ getObjectPropertyObject obj "window" Gdk.Window.Window

constructGLContextWindow :: (IsGLContext o, Gdk.Window.IsWindow a) => a -> IO (GValueConstruct o)
constructGLContextWindow val = constructObjectPropertyObject "window" (Just val)

data GLContextWindowPropertyInfo
instance AttrInfo GLContextWindowPropertyInfo where
    type AttrAllowedOps GLContextWindowPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint GLContextWindowPropertyInfo = Gdk.Window.IsWindow
    type AttrBaseTypeConstraint GLContextWindowPropertyInfo = IsGLContext
    type AttrGetType GLContextWindowPropertyInfo = (Maybe Gdk.Window.Window)
    type AttrLabel GLContextWindowPropertyInfo = "window"
    type AttrOrigin GLContextWindowPropertyInfo = GLContext
    attrGet _ = getGLContextWindow
    attrSet _ = undefined
    attrConstruct _ = constructGLContextWindow
    attrClear _ = undefined

instance O.HasAttributeList GLContext
type instance O.AttributeList GLContext = GLContextAttributeList
type GLContextAttributeList = ('[ '("display", GLContextDisplayPropertyInfo), '("sharedContext", GLContextSharedContextPropertyInfo), '("window", GLContextWindowPropertyInfo)] :: [(Symbol, *)])

gLContextDisplay :: AttrLabelProxy "display"
gLContextDisplay = AttrLabelProxy

gLContextSharedContext :: AttrLabelProxy "sharedContext"
gLContextSharedContext = AttrLabelProxy

gLContextWindow :: AttrLabelProxy "window"
gLContextWindow = AttrLabelProxy

type instance O.SignalList GLContext = GLContextSignalList
type GLContextSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method GLContext::get_debug_enabled
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_debug_enabled" gdk_gl_context_get_debug_enabled :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    IO CInt

{- |
Retrieves the value set using 'GI.Gdk.Objects.GLContext.gLContextSetDebugEnabled'.

@since 3.16
-}
gLContextGetDebugEnabled ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if debugging is enabled -}
gLContextGetDebugEnabled context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- gdk_gl_context_get_debug_enabled context'
    let result' = (/= 0) result
    touchManagedPtr context
    return result'

data GLContextGetDebugEnabledMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsGLContext a) => O.MethodInfo GLContextGetDebugEnabledMethodInfo a signature where
    overloadedMethod _ = gLContextGetDebugEnabled

-- method GLContext::get_display
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "Display"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_display" gdk_gl_context_get_display :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    IO (Ptr Gdk.Display.Display)

{- |
Retrieves the 'GI.Gdk.Objects.Display.Display' the /@context@/ is created for

@since 3.16
-}
gLContextGetDisplay ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m (Maybe Gdk.Display.Display)
    {- ^ __Returns:__ a 'GI.Gdk.Objects.Display.Display' or 'Nothing' -}
gLContextGetDisplay context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- gdk_gl_context_get_display context'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gdk.Display.Display) result'
        return result''
    touchManagedPtr context
    return maybeResult

data GLContextGetDisplayMethodInfo
instance (signature ~ (m (Maybe Gdk.Display.Display)), MonadIO m, IsGLContext a) => O.MethodInfo GLContextGetDisplayMethodInfo a signature where
    overloadedMethod _ = gLContextGetDisplay

-- method GLContext::get_forward_compatible
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_forward_compatible" gdk_gl_context_get_forward_compatible :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    IO CInt

{- |
Retrieves the value set using 'GI.Gdk.Objects.GLContext.gLContextSetForwardCompatible'.

@since 3.16
-}
gLContextGetForwardCompatible ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the context should be forward compatible -}
gLContextGetForwardCompatible context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- gdk_gl_context_get_forward_compatible context'
    let result' = (/= 0) result
    touchManagedPtr context
    return result'

data GLContextGetForwardCompatibleMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsGLContext a) => O.MethodInfo GLContextGetForwardCompatibleMethodInfo a signature where
    overloadedMethod _ = gLContextGetForwardCompatible

-- method GLContext::get_required_version
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "major", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "return location for the major version to request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "minor", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "return location for the minor version to request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_required_version" gdk_gl_context_get_required_version :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    Ptr Int32 ->                            -- major : TBasicType TInt
    Ptr Int32 ->                            -- minor : TBasicType TInt
    IO ()

{- |
Retrieves the major and minor version requested by calling
'GI.Gdk.Objects.GLContext.gLContextSetRequiredVersion'.

@since 3.16
-}
gLContextGetRequiredVersion ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m (Int32,Int32)
gLContextGetRequiredVersion context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    major <- allocMem :: IO (Ptr Int32)
    minor <- allocMem :: IO (Ptr Int32)
    gdk_gl_context_get_required_version context' major minor
    major' <- peek major
    minor' <- peek minor
    touchManagedPtr context
    freeMem major
    freeMem minor
    return (major', minor')

data GLContextGetRequiredVersionMethodInfo
instance (signature ~ (m (Int32,Int32)), MonadIO m, IsGLContext a) => O.MethodInfo GLContextGetRequiredVersionMethodInfo a signature where
    overloadedMethod _ = gLContextGetRequiredVersion

-- method GLContext::get_shared_context
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "GLContext"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_shared_context" gdk_gl_context_get_shared_context :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    IO (Ptr GLContext)

{- |
Retrieves the 'GI.Gdk.Objects.GLContext.GLContext' that this /@context@/ share data with.

@since 3.16
-}
gLContextGetSharedContext ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m (Maybe GLContext)
    {- ^ __Returns:__ a 'GI.Gdk.Objects.GLContext.GLContext' or 'Nothing' -}
gLContextGetSharedContext context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- gdk_gl_context_get_shared_context context'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject GLContext) result'
        return result''
    touchManagedPtr context
    return maybeResult

data GLContextGetSharedContextMethodInfo
instance (signature ~ (m (Maybe GLContext)), MonadIO m, IsGLContext a) => O.MethodInfo GLContextGetSharedContextMethodInfo a signature where
    overloadedMethod _ = gLContextGetSharedContext

-- method GLContext::get_use_es
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_use_es" gdk_gl_context_get_use_es :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    IO CInt

{- |
Checks whether the /@context@/ is using an OpenGL or OpenGL ES profile.

@since 3.22
-}
gLContextGetUseEs ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the 'GI.Gdk.Objects.GLContext.GLContext' is using an OpenGL ES profile -}
gLContextGetUseEs context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- gdk_gl_context_get_use_es context'
    let result' = (/= 0) result
    touchManagedPtr context
    return result'

data GLContextGetUseEsMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsGLContext a) => O.MethodInfo GLContextGetUseEsMethodInfo a signature where
    overloadedMethod _ = gLContextGetUseEs

-- method GLContext::get_version
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "major", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the major version", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "minor", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the minor version", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_version" gdk_gl_context_get_version :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    Ptr Int32 ->                            -- major : TBasicType TInt
    Ptr Int32 ->                            -- minor : TBasicType TInt
    IO ()

{- |
Retrieves the OpenGL version of the /@context@/.

The /@context@/ must be realized prior to calling this function.

@since 3.16
-}
gLContextGetVersion ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m (Int32,Int32)
gLContextGetVersion context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    major <- allocMem :: IO (Ptr Int32)
    minor <- allocMem :: IO (Ptr Int32)
    gdk_gl_context_get_version context' major minor
    major' <- peek major
    minor' <- peek minor
    touchManagedPtr context
    freeMem major
    freeMem minor
    return (major', minor')

data GLContextGetVersionMethodInfo
instance (signature ~ (m (Int32,Int32)), MonadIO m, IsGLContext a) => O.MethodInfo GLContextGetVersionMethodInfo a signature where
    overloadedMethod _ = gLContextGetVersion

-- method GLContext::get_window
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "Window"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_window" gdk_gl_context_get_window :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    IO (Ptr Gdk.Window.Window)

{- |
Retrieves the 'GI.Gdk.Objects.Window.Window' used by the /@context@/.

@since 3.16
-}
gLContextGetWindow ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m (Maybe Gdk.Window.Window)
    {- ^ __Returns:__ a 'GI.Gdk.Objects.Window.Window' or 'Nothing' -}
gLContextGetWindow context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- gdk_gl_context_get_window context'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gdk.Window.Window) result'
        return result''
    touchManagedPtr context
    return maybeResult

data GLContextGetWindowMethodInfo
instance (signature ~ (m (Maybe Gdk.Window.Window)), MonadIO m, IsGLContext a) => O.MethodInfo GLContextGetWindowMethodInfo a signature where
    overloadedMethod _ = gLContextGetWindow

-- method GLContext::is_legacy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_is_legacy" gdk_gl_context_is_legacy :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    IO CInt

{- |
Whether the 'GI.Gdk.Objects.GLContext.GLContext' is in legacy mode or not.

The 'GI.Gdk.Objects.GLContext.GLContext' must be realized before calling this function.

When realizing a GL context, GDK will try to use the OpenGL 3.2 core
profile; this profile removes all the OpenGL API that was deprecated
prior to the 3.2 version of the specification. If the realization is
successful, this function will return 'False'.

If the underlying OpenGL implementation does not support core profiles,
GDK will fall back to a pre-3.2 compatibility profile, and this function
will return 'True'.

You can use the value returned by this function to decide which kind
of OpenGL API to use, or whether to do extension discovery, or what
kind of shader programs to load.

@since 3.20
-}
gLContextIsLegacy ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the GL context is in legacy mode -}
gLContextIsLegacy context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    result <- gdk_gl_context_is_legacy context'
    let result' = (/= 0) result
    touchManagedPtr context
    return result'

data GLContextIsLegacyMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsGLContext a) => O.MethodInfo GLContextIsLegacyMethodInfo a signature where
    overloadedMethod _ = gLContextIsLegacy

-- method GLContext::make_current
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_make_current" gdk_gl_context_make_current :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    IO ()

{- |
Makes the /@context@/ the current one.

@since 3.16
-}
gLContextMakeCurrent ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m ()
gLContextMakeCurrent context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    gdk_gl_context_make_current context'
    touchManagedPtr context
    return ()

data GLContextMakeCurrentMethodInfo
instance (signature ~ (m ()), MonadIO m, IsGLContext a) => O.MethodInfo GLContextMakeCurrentMethodInfo a signature where
    overloadedMethod _ = gLContextMakeCurrent

-- method GLContext::realize
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "gdk_gl_context_realize" gdk_gl_context_realize :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Realizes the given 'GI.Gdk.Objects.GLContext.GLContext'.

It is safe to call this function on a realized 'GI.Gdk.Objects.GLContext.GLContext'.

@since 3.16
-}
gLContextRealize ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
gLContextRealize context = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    onException (do
        _ <- propagateGError $ gdk_gl_context_realize context'
        touchManagedPtr context
        return ()
     ) (do
        return ()
     )

data GLContextRealizeMethodInfo
instance (signature ~ (m ()), MonadIO m, IsGLContext a) => O.MethodInfo GLContextRealizeMethodInfo a signature where
    overloadedMethod _ = gLContextRealize

-- method GLContext::set_debug_enabled
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "enabled", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to enable debugging in the context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_set_debug_enabled" gdk_gl_context_set_debug_enabled :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    CInt ->                                 -- enabled : TBasicType TBoolean
    IO ()

{- |
Sets whether the 'GI.Gdk.Objects.GLContext.GLContext' should perform extra validations and
run time checking. This is useful during development, but has
additional overhead.

The 'GI.Gdk.Objects.GLContext.GLContext' must not be realized or made current prior to
calling this function.

@since 3.16
-}
gLContextSetDebugEnabled ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> Bool
    {- ^ /@enabled@/: whether to enable debugging in the context -}
    -> m ()
gLContextSetDebugEnabled context enabled = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    let enabled' = (fromIntegral . fromEnum) enabled
    gdk_gl_context_set_debug_enabled context' enabled'
    touchManagedPtr context
    return ()

data GLContextSetDebugEnabledMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsGLContext a) => O.MethodInfo GLContextSetDebugEnabledMethodInfo a signature where
    overloadedMethod _ = gLContextSetDebugEnabled

-- method GLContext::set_forward_compatible
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "compatible", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether the context should be forward compatible", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_set_forward_compatible" gdk_gl_context_set_forward_compatible :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    CInt ->                                 -- compatible : TBasicType TBoolean
    IO ()

{- |
Sets whether the 'GI.Gdk.Objects.GLContext.GLContext' should be forward compatible.

Forward compatibile contexts must not support OpenGL functionality that
has been marked as deprecated in the requested version; non-forward
compatible contexts, on the other hand, must support both deprecated and
non deprecated functionality.

The 'GI.Gdk.Objects.GLContext.GLContext' must not be realized or made current prior to calling
this function.

@since 3.16
-}
gLContextSetForwardCompatible ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> Bool
    {- ^ /@compatible@/: whether the context should be forward compatible -}
    -> m ()
gLContextSetForwardCompatible context compatible = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    let compatible' = (fromIntegral . fromEnum) compatible
    gdk_gl_context_set_forward_compatible context' compatible'
    touchManagedPtr context
    return ()

data GLContextSetForwardCompatibleMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsGLContext a) => O.MethodInfo GLContextSetForwardCompatibleMethodInfo a signature where
    overloadedMethod _ = gLContextSetForwardCompatible

-- method GLContext::set_required_version
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "major", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the major version to request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "minor", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the minor version to request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_set_required_version" gdk_gl_context_set_required_version :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    Int32 ->                                -- major : TBasicType TInt
    Int32 ->                                -- minor : TBasicType TInt
    IO ()

{- |
Sets the major and minor version of OpenGL to request.

Setting /@major@/ and /@minor@/ to zero will use the default values.

The 'GI.Gdk.Objects.GLContext.GLContext' must not be realized or made current prior to calling
this function.

@since 3.16
-}
gLContextSetRequiredVersion ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext' -}
    -> Int32
    {- ^ /@major@/: the major version to request -}
    -> Int32
    {- ^ /@minor@/: the minor version to request -}
    -> m ()
gLContextSetRequiredVersion context major minor = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    gdk_gl_context_set_required_version context' major minor
    touchManagedPtr context
    return ()

data GLContextSetRequiredVersionMethodInfo
instance (signature ~ (Int32 -> Int32 -> m ()), MonadIO m, IsGLContext a) => O.MethodInfo GLContextSetRequiredVersionMethodInfo a signature where
    overloadedMethod _ = gLContextSetRequiredVersion

-- method GLContext::set_use_es
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "context", argType = TInterface (Name {namespace = "Gdk", name = "GLContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GdkGLContext:", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "use_es", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether the context should use OpenGL ES instead of OpenGL,\n  or -1 to allow auto-detection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_set_use_es" gdk_gl_context_set_use_es :: 
    Ptr GLContext ->                        -- context : TInterface (Name {namespace = "Gdk", name = "GLContext"})
    Int32 ->                                -- use_es : TBasicType TInt
    IO ()

{- |
Requests that GDK create a OpenGL ES context instead of an OpenGL one,
if the platform and windowing system allows it.

The /@context@/ must not have been realized.

By default, GDK will attempt to automatically detect whether the
underlying GL implementation is OpenGL or OpenGL ES once the /@context@/
is realized.

You should check the return value of 'GI.Gdk.Objects.GLContext.gLContextGetUseEs' after
calling 'GI.Gdk.Objects.GLContext.gLContextRealize' to decide whether to use the OpenGL or
OpenGL ES API, extensions, or shaders.

@since 3.22
-}
gLContextSetUseEs ::
    (B.CallStack.HasCallStack, MonadIO m, IsGLContext a) =>
    a
    {- ^ /@context@/: a 'GI.Gdk.Objects.GLContext.GLContext': -}
    -> Int32
    {- ^ /@useEs@/: whether the context should use OpenGL ES instead of OpenGL,
  or -1 to allow auto-detection -}
    -> m ()
gLContextSetUseEs context useEs = liftIO $ do
    context' <- unsafeManagedPtrCastPtr context
    gdk_gl_context_set_use_es context' useEs
    touchManagedPtr context
    return ()

data GLContextSetUseEsMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsGLContext a) => O.MethodInfo GLContextSetUseEsMethodInfo a signature where
    overloadedMethod _ = gLContextSetUseEs

-- method GLContext::clear_current
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_clear_current" gdk_gl_context_clear_current :: 
    IO ()

{- |
Clears the current 'GI.Gdk.Objects.GLContext.GLContext'.

Any OpenGL call after this function returns will be ignored
until 'GI.Gdk.Objects.GLContext.gLContextMakeCurrent' is called.

@since 3.16
-}
gLContextClearCurrent ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
gLContextClearCurrent  = liftIO $ do
    gdk_gl_context_clear_current
    return ()

-- method GLContext::get_current
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gdk", name = "GLContext"}))
-- throws : False
-- Skip return : False

foreign import ccall "gdk_gl_context_get_current" gdk_gl_context_get_current :: 
    IO (Ptr GLContext)

{- |
Retrieves the current 'GI.Gdk.Objects.GLContext.GLContext'.

@since 3.16
-}
gLContextGetCurrent ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m (Maybe GLContext)
    {- ^ __Returns:__ the current 'GI.Gdk.Objects.GLContext.GLContext', or 'Nothing' -}
gLContextGetCurrent  = liftIO $ do
    result <- gdk_gl_context_get_current
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject GLContext) result'
        return result''
    return maybeResult