gdkvulkancontext.go RawHistoryFolder
1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/glib"
11 "github.com/bnema/puregotk/v4/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15var xVulkanErrorQuark func() glib.Quark
16
17// Registers an error quark for [class@Gdk.VulkanContext] errors.
18func VulkanErrorQuark() glib.Quark {
19
20 cret := xVulkanErrorQuark()
21 return cret
22}
23
24// Represents the platform-specific Vulkan draw context.
25//
26// `GdkVulkanContext`s are created for a surface using
27// [method@Gdk.Surface.create_vulkan_context], and the context will match
28// the characteristics of the surface.
29//
30// Support for `GdkVulkanContext` is platform-specific and context creation
31// can fail, returning %NULL context.
32type VulkanContext struct {
33 DrawContext
34}
35
36var xVulkanContextGLibType func() types.GType
37
38func VulkanContextGLibType() types.GType {
39 return xVulkanContextGLibType()
40}
41
42func VulkanContextNewFromInternalPtr(ptr uintptr) *VulkanContext {
43 cls := &VulkanContext{}
44 cls.Ptr = ptr
45 return cls
46}
47
48func (c *VulkanContext) GoPointer() uintptr {
49 if c == nil {
50 return 0
51 }
52 return c.Ptr
53}
54
55func (c *VulkanContext) SetGoPointer(ptr uintptr) {
56 c.Ptr = ptr
57}
58
59// Emitted when the images managed by this context have changed.
60//
61// Usually this means that the swapchain had to be recreated,
62// for example in response to a change of the surface size.
63func (x *VulkanContext) ConnectImagesUpdated(cb *func(VulkanContext)) uint {
64 cbPtr := uintptr(unsafe.Pointer(cb))
65 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
66 handlerID := gobject.SignalConnect(x.GoPointer(), "images-updated", cbRefPtr)
67 glib.SaveHandlerMapping(handlerID, cbPtr)
68 return handlerID
69 }
70
71 fcb := func(clsPtr uintptr) {
72 fa := VulkanContext{}
73 fa.Ptr = clsPtr
74 cbFn := *cb
75
76 cbFn(fa)
77
78 }
79 cbRefPtr := purego.NewCallback(fcb)
80 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
81 handlerID := gobject.SignalConnect(x.GoPointer(), "images-updated", cbRefPtr)
82 glib.SaveHandlerMapping(handlerID, cbPtr)
83 return handlerID
84}
85
86func init() {
87 core.SetPackageName("GDK", "gtk4")
88 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
89 var libs []uintptr
90 for _, libPath := range core.GetPaths("GDK") {
91 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
92 if err != nil {
93 panic(err)
94 }
95 libs = append(libs, lib)
96 }
97
98 core.PuregoSafeRegister(&xVulkanErrorQuark, libs, "gdk_vulkan_error_quark")
99
100 core.PuregoSafeRegister(&xVulkanContextGLibType, libs, "gdk_vulkan_context_get_type")
101
102}