// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gdk import ( "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) var xGlErrorQuark func() glib.Quark // Registers an error quark for [class@Gdk.GLContext] errors. func GlErrorQuark() glib.Quark { cret := xGlErrorQuark() return cret } // Represents a platform-specific OpenGL draw context. // // `GdkGLContext`s are created for a surface using // [method@Gdk.Surface.create_gl_context], and the context will match // the characteristics of the surface. // // A `GdkGLContext` is not tied to any particular normal framebuffer. // For instance, it cannot draw to the surface 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 [func@cairo_draw_from_gl] // 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 `GdkGLContext` is platform-specific and context creation // can fail, returning %NULL context. // // A `GdkGLContext` 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 `GdkGLContext` instance you need a `GdkSurface`, // which you typically get during the realize call of a widget. // // A `GdkGLContext` is not realized until either [method@Gdk.GLContext.make_current] // or [method@Gdk.GLContext.realize] is called. 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 // [method@Gdk.Surface.create_gl_context] by calling [method@Gdk.GLContext.realize]. // If the realization fails you have the option to change the settings of // the `GdkGLContext` and try again. // // ## Using a GdkGLContext // // You will need to make the `GdkGLContext` 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 // gdk_gl_context_make_current (context); // ``` // // You can now perform your drawing using OpenGL commands. // // You can check which `GdkGLContext` is the current one by using // [func@Gdk.GLContext.get_current]; you can also unset any `GdkGLContext` // that is currently set by calling [func@Gdk.GLContext.clear_current]. type GLContext struct { DrawContext } var xGLContextGLibType func() types.GType func GLContextGLibType() types.GType { return xGLContextGLibType() } func GLContextNewFromInternalPtr(ptr uintptr) *GLContext { cls := &GLContext{} cls.Ptr = ptr return cls } var xGLContextGetAllowedApis func(uintptr) GLAPI // Gets the allowed APIs set via gdk_gl_context_set_allowed_apis(). func (x *GLContext) GetAllowedApis() GLAPI { cret := xGLContextGetAllowedApis(x.GoPointer()) return cret } var xGLContextGetApi func(uintptr) GLAPI // Gets the API currently in use. // // If the renderer has not been realized yet, 0 is returned. func (x *GLContext) GetApi() GLAPI { cret := xGLContextGetApi(x.GoPointer()) return cret } var xGLContextGetDebugEnabled func(uintptr) bool // Retrieves whether the context is doing extra validations and runtime checking. // // See [method@Gdk.GLContext.set_debug_enabled]. func (x *GLContext) GetDebugEnabled() bool { cret := xGLContextGetDebugEnabled(x.GoPointer()) return cret } var xGLContextGetDisplay func(uintptr) uintptr // Retrieves the display the @context is created for func (x *GLContext) GetDisplay() *Display { var cls *Display cret := xGLContextGetDisplay(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Display{} cls.Ptr = cret return cls } var xGLContextGetForwardCompatible func(uintptr) bool // Retrieves whether the context is forward-compatible. // // See [method@Gdk.GLContext.set_forward_compatible]. func (x *GLContext) GetForwardCompatible() bool { cret := xGLContextGetForwardCompatible(x.GoPointer()) return cret } var xGLContextGetRequiredVersion func(uintptr, *int, *int) // Retrieves required OpenGL version set as a requirement for the @context // realization. It will not change even if a greater OpenGL version is supported // and used after the @context is realized. See // [method@Gdk.GLContext.get_version] for the real version in use. // // See [method@Gdk.GLContext.set_required_version]. func (x *GLContext) GetRequiredVersion(MajorVar *int, MinorVar *int) { xGLContextGetRequiredVersion(x.GoPointer(), MajorVar, MinorVar) } var xGLContextGetSharedContext func(uintptr) uintptr // Used to retrieves the `GdkGLContext` that this @context share data with. // // As many contexts can share data now and no single shared context exists // anymore, this function has been deprecated and now always returns %NULL. func (x *GLContext) GetSharedContext() *GLContext { var cls *GLContext cret := xGLContextGetSharedContext(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &GLContext{} cls.Ptr = cret return cls } var xGLContextGetSurface func(uintptr) uintptr // Retrieves the surface used by the @context. func (x *GLContext) GetSurface() *Surface { var cls *Surface cret := xGLContextGetSurface(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Surface{} cls.Ptr = cret return cls } var xGLContextGetUseEs func(uintptr) bool // Checks whether the @context is using an OpenGL or OpenGL ES profile. func (x *GLContext) GetUseEs() bool { cret := xGLContextGetUseEs(x.GoPointer()) return cret } var xGLContextGetVersion func(uintptr, *int, *int) // Retrieves the OpenGL version of the @context. // // The @context must be realized prior to calling this function. func (x *GLContext) GetVersion(MajorVar *int, MinorVar *int) { xGLContextGetVersion(x.GoPointer(), MajorVar, MinorVar) } var xGLContextIsLegacy func(uintptr) bool // Whether the `GdkGLContext` is in legacy mode or not. // // The `GdkGLContext` 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. func (x *GLContext) IsLegacy() bool { cret := xGLContextIsLegacy(x.GoPointer()) return cret } var xGLContextIsShared func(uintptr, uintptr) bool // Checks if the two GL contexts can share resources. // // When they can, the texture IDs from @other can be used in @self. This // is particularly useful when passing `GdkGLTexture` objects between // different contexts. // // Contexts created for the same display with the same properties will // always be compatible, even if they are created for different surfaces. // For other contexts it depends on the GL backend. // // Both contexts must be realized for this check to succeed. If either one // is not, this function will return %FALSE. func (x *GLContext) IsShared(OtherVar *GLContext) bool { cret := xGLContextIsShared(x.GoPointer(), OtherVar.GoPointer()) return cret } var xGLContextMakeCurrent func(uintptr) // Makes the @context the current one. func (x *GLContext) MakeCurrent() { xGLContextMakeCurrent(x.GoPointer()) } var xGLContextRealize func(uintptr) bool // Realizes the given `GdkGLContext`. // // It is safe to call this function on a realized `GdkGLContext`. func (x *GLContext) Realize() (bool, error) { var cerr *glib.Error cret := xGLContextRealize(x.GoPointer()) if cerr == nil { return cret, nil } return cret, cerr } var xGLContextSetAllowedApis func(uintptr, GLAPI) // Sets the allowed APIs. When gdk_gl_context_realize() is called, only the // allowed APIs will be tried. If you set this to 0, realizing will always fail. // // If you set it on a realized context, the property will not have any effect. // It is only relevant during gdk_gl_context_realize(). // // By default, all APIs are allowed. func (x *GLContext) SetAllowedApis(ApisVar GLAPI) { xGLContextSetAllowedApis(x.GoPointer(), ApisVar) } var xGLContextSetDebugEnabled func(uintptr, bool) // Sets whether the `GdkGLContext` should perform extra validations and // runtime checking. // // This is useful during development, but has additional overhead. // // The `GdkGLContext` must not be realized or made current prior to // calling this function. func (x *GLContext) SetDebugEnabled(EnabledVar bool) { xGLContextSetDebugEnabled(x.GoPointer(), EnabledVar) } var xGLContextSetForwardCompatible func(uintptr, bool) // Sets whether the `GdkGLContext` should be forward-compatible. // // Forward-compatible 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 `GdkGLContext` must not be realized or made current prior to calling // this function. func (x *GLContext) SetForwardCompatible(CompatibleVar bool) { xGLContextSetForwardCompatible(x.GoPointer(), CompatibleVar) } var xGLContextSetRequiredVersion func(uintptr, int, int) // Sets the major and minor version of OpenGL to request. // // Setting @major and @minor to zero will use the default values. // // Setting @major and @minor lower than the minimum versions required // by GTK will result in the context choosing the minimum version. // // The @context must not be realized or made current prior to calling // this function. func (x *GLContext) SetRequiredVersion(MajorVar int, MinorVar int) { xGLContextSetRequiredVersion(x.GoPointer(), MajorVar, MinorVar) } var xGLContextSetUseEs func(uintptr, int) // Requests that GDK create an OpenGL ES context instead of an OpenGL one. // // Not all platforms support OpenGL ES. // // 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 [method@Gdk.GLContext.get_use_es] // after calling [method@Gdk.GLContext.realize] to decide whether to use // the OpenGL or OpenGL ES API, extensions, or shaders. func (x *GLContext) SetUseEs(UseEsVar int) { xGLContextSetUseEs(x.GoPointer(), UseEsVar) } func (c *GLContext) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *GLContext) SetGoPointer(ptr uintptr) { c.Ptr = ptr } var xGLContextClearCurrent func() // Clears the current `GdkGLContext`. // // Any OpenGL call after this function returns will be ignored // until [method@Gdk.GLContext.make_current] is called. func GLContextClearCurrent() { xGLContextClearCurrent() } var xGLContextGetCurrent func() uintptr // Retrieves the current `GdkGLContext`. func GLContextGetCurrent() *GLContext { var cls *GLContext cret := xGLContextGetCurrent() if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &GLContext{} cls.Ptr = cret return cls } func init() { core.SetPackageName("GDK", "gtk4") core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GDK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xGlErrorQuark, libs, "gdk_gl_error_quark") core.PuregoSafeRegister(&xGLContextGLibType, libs, "gdk_gl_context_get_type") core.PuregoSafeRegister(&xGLContextGetAllowedApis, libs, "gdk_gl_context_get_allowed_apis") core.PuregoSafeRegister(&xGLContextGetApi, libs, "gdk_gl_context_get_api") core.PuregoSafeRegister(&xGLContextGetDebugEnabled, libs, "gdk_gl_context_get_debug_enabled") core.PuregoSafeRegister(&xGLContextGetDisplay, libs, "gdk_gl_context_get_display") core.PuregoSafeRegister(&xGLContextGetForwardCompatible, libs, "gdk_gl_context_get_forward_compatible") core.PuregoSafeRegister(&xGLContextGetRequiredVersion, libs, "gdk_gl_context_get_required_version") core.PuregoSafeRegister(&xGLContextGetSharedContext, libs, "gdk_gl_context_get_shared_context") core.PuregoSafeRegister(&xGLContextGetSurface, libs, "gdk_gl_context_get_surface") core.PuregoSafeRegister(&xGLContextGetUseEs, libs, "gdk_gl_context_get_use_es") core.PuregoSafeRegister(&xGLContextGetVersion, libs, "gdk_gl_context_get_version") core.PuregoSafeRegister(&xGLContextIsLegacy, libs, "gdk_gl_context_is_legacy") core.PuregoSafeRegister(&xGLContextIsShared, libs, "gdk_gl_context_is_shared") core.PuregoSafeRegister(&xGLContextMakeCurrent, libs, "gdk_gl_context_make_current") core.PuregoSafeRegister(&xGLContextRealize, libs, "gdk_gl_context_realize") core.PuregoSafeRegister(&xGLContextSetAllowedApis, libs, "gdk_gl_context_set_allowed_apis") core.PuregoSafeRegister(&xGLContextSetDebugEnabled, libs, "gdk_gl_context_set_debug_enabled") core.PuregoSafeRegister(&xGLContextSetForwardCompatible, libs, "gdk_gl_context_set_forward_compatible") core.PuregoSafeRegister(&xGLContextSetRequiredVersion, libs, "gdk_gl_context_set_required_version") core.PuregoSafeRegister(&xGLContextSetUseEs, libs, "gdk_gl_context_set_use_es") core.PuregoSafeRegister(&xGLContextClearCurrent, libs, "gdk_gl_context_clear_current") core.PuregoSafeRegister(&xGLContextGetCurrent, libs, "gdk_gl_context_get_current") }