class Gdk::GLTextureBuilder

Overview

Constructs Gdk::Texture objects from GL textures.

The operation is quite simple: Create a texture builder, set all the necessary properties - keep in mind that the properties Gdk::GLTextureBuilder#context, Gdk::GLTextureBuilder#id, Gdk::GLTextureBuilder#width, and Gdk::GLTextureBuilder#height are mandatory - and then call Gdk::GLTextureBuilder#build to create the new texture.

Gdk::GLTextureBuilder can be used for quick one-shot construction of textures as well as kept around and reused to construct multiple textures.

Defined in:

lib/gi-crystal/src/auto/gdk-4.0/gl_texture_builder.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new : self #

Creates a new texture builder.


def self.new(*, color_state : Gdk::ColorState | Nil = nil, context : Gdk::GLContext | Nil = nil, format : Gdk::MemoryFormat | Nil = nil, has_mipmap : Bool | Nil = nil, height : Int32 | Nil = nil, id : UInt32 | Nil = nil, sync : Pointer(Void) | Nil = nil, update_region : Cairo::Region | Nil = nil, update_texture : Gdk::Texture | Nil = nil, width : Int32 | Nil = nil) #

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def build(destroy : GLib::DestroyNotify | Nil, data : Pointer(Void) | Nil) : Gdk::Texture #

Builds a new Gdk::Texture with the values set up in the builder.

The destroy function gets called when the returned texture gets released; either when the texture is finalized or by an explicit call to Gdk::GLTexture#release. It should release all GL resources associated with the texture, such as the Gdk::GLTextureBuilder#id and the Gdk::GLTextureBuilder#sync.

Note that it is a programming error to call this function if any mandatory property has not been set.

It is possible to call this function multiple times to create multiple textures, possibly with changing properties in between.


def color_state : Gdk::ColorState #

Gets the color state previously set via gdk_gl_texture_builder_set_color_state().


def color_state=(color_state : Gdk::ColorState) : Nil #

Sets the color state for the texture.

By default, the sRGB colorstate is used. If you don't know what colorstates are, this is probably the right thing.


def color_state=(value : Gdk::ColorState | Nil) : Gdk::ColorState | Nil #

def context : Gdk::GLContext | Nil #

Gets the context previously set via gdk_gl_texture_builder_set_context() or nil if none was set.


def context=(context : Gdk::GLContext | Nil) : Nil #

Sets the context to be used for the texture. This is the context that owns the texture.

The context must be set before calling Gdk::GLTextureBuilder#build.


def format : Gdk::MemoryFormat #

Gets the format previously set via gdk_gl_texture_builder_set_format().


def format=(format : Gdk::MemoryFormat) : Nil #

Sets the format of the texture. The default is GDK_MEMORY_R8G8B8A8_PREMULTIPLIED.

The format is the preferred format the texture data should be downloaded to. The format must be supported by the GL version of Gdk::GLTextureBuilder#context.

GDK's texture download code assumes that the format corresponds to the storage parameters of the GL texture in an obvious way. For example, a format of GDK_MEMORY_R16G16B16A16_PREMULTIPLIED is expected to be stored as GL_RGBA16 texture, and GDK_MEMORY_G8A8 is expected to be stored as GL_RG8 texture.

Setting the right format is particularly useful when using high bit depth textures to preserve the bit depth, to set the correct value for unpremultiplied textures and to make sure opaque textures are treated as such.

Non-RGBA textures need to have swizzling parameters set up properly to be usable in GSK's shaders.


def has_mipmap : Bool #

Gets whether the texture has a mipmap.


def has_mipmap=(has_mipmap : Bool) : Nil #

Sets whether the texture has a mipmap. This allows the renderer and other users of the generated texture to use a higher quality downscaling.

Typically, the glGenerateMipmap function is used to generate a mimap.


def has_mipmap? : Bool #

def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def height : Int32 #

Gets the height previously set via gdk_gl_texture_builder_set_height() or 0 if the height wasn't set.


def height=(height : Int32) : Nil #

Sets the height of the texture.

The height must be set before calling Gdk::GLTextureBuilder#build.


def id : UInt32 #

Gets the texture id previously set via gdk_gl_texture_builder_set_id() or 0 if the id wasn't set.


def id=(id : UInt32) : Nil #

Sets the texture id of the texture. The texture id must remain unmodified until the texture was finalized. See Gdk::GLTextureBuilder#build for a longer discussion.

The id must be set before calling Gdk::GLTextureBuilder#build.


def sync : Pointer(Void) | Nil #

Gets the GLsync previously set via gdk_gl_texture_builder_set_sync().


def sync=(value : Pointer(Void)) : Pointer(Void) #

def sync=(sync : Pointer(Void) | Nil) : Nil #

Sets the GLSync object to use for the texture.

GTK will wait on this object before using the created Gdk::Texture.

The destroy function that is passed to Gdk::GLTextureBuilder#build is responsible for freeing the sync object when it is no longer needed. The texture builder does not destroy it and it is the callers responsibility to make sure it doesn't leak.


def update_region : Cairo::Region | Nil #

Gets the region previously set via gdk_gl_texture_builder_set_update_region() or nil if none was set.


def update_region=(region : Cairo::Region | Nil) : Nil #

Sets the region to be updated by this texture. Together with [property@Gdk.GLTextureBuilder:update-texture] this describes an update of a previous texture.

When rendering animations of large textures, it is possible that consecutive textures are only updating contents in parts of the texture. It is then possible to describe this update via these two properties, so that GTK can avoid rerendering parts that did not change.

An example would be a screen recording where only the mouse pointer moves.


def update_texture : Gdk::Texture | Nil #

Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() or nil if none was set.


def update_texture=(texture : Gdk::Texture | Nil) : Nil #

Sets the texture to be updated by this texture. See Gdk::GLTextureBuilder#update_region= for an explanation.


def width : Int32 #

Gets the width previously set via gdk_gl_texture_builder_set_width() or 0 if the width wasn't set.


def width=(width : Int32) : Nil #

Sets the width of the texture.

The width must be set before calling Gdk::GLTextureBuilder#build.