Class GLTextureBuilder

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class GLTextureBuilder extends GObject

Constructs 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 build(MemorySegment) to create the new texture.

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

Since:
4.12
  • Constructor Details

    • GLTextureBuilder

      public GLTextureBuilder(MemorySegment address)
      Create a GLTextureBuilder instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • GLTextureBuilder

      public GLTextureBuilder()
      Create a new GLTextureBuilder.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the GLTextureBuilder class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected GLTextureBuilder asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • build

      public Texture build(@Nullable MemorySegment data)

      Builds a new GdkTexture 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 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.

      Parameters:
      data - user data to pass to the destroy function
      Returns:
      a newly built GdkTexture
      Since:
      4.12
    • getColorState

      public ColorState getColorState()
      Gets the color state previously set via gdk_gl_texture_builder_set_color_state().
      Returns:
      the color state
      Since:
      4.16
    • getContext

      public @Nullable GLContext getContext()
      Gets the context previously set via gdk_gl_texture_builder_set_context() or null if none was set.
      Returns:
      The context
      Since:
      4.12
    • getFormat

      public MemoryFormat getFormat()
      Gets the format previously set via gdk_gl_texture_builder_set_format().
      Returns:
      The format
      Since:
      4.12
    • getHasMipmap

      public boolean getHasMipmap()
      Gets whether the texture has a mipmap.
      Returns:
      Whether the texture has a mipmap
      Since:
      4.12
    • getHeight

      public int getHeight()
      Gets the height previously set via gdk_gl_texture_builder_set_height() or 0 if the height wasn't set.
      Returns:
      The height
      Since:
      4.12
    • getId

      public int getId()
      Gets the texture id previously set via gdk_gl_texture_builder_set_id() or 0 if the id wasn't set.
      Returns:
      The id
      Since:
      4.12
    • getSync

      public @Nullable MemorySegment getSync()
      Gets the GLsync previously set via gdk_gl_texture_builder_set_sync().
      Returns:
      the GLSync
      Since:
      4.12
    • getUpdateRegion

      public @Nullable org.freedesktop.cairo.Region getUpdateRegion()
      Gets the region previously set via gdk_gl_texture_builder_set_update_region() or null if none was set.
      Returns:
      The region
      Since:
      4.12
    • getUpdateTexture

      public @Nullable Texture getUpdateTexture()
      Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() or null if none was set.
      Returns:
      The texture
      Since:
      4.12
    • getWidth

      public int getWidth()
      Gets the width previously set via gdk_gl_texture_builder_set_width() or 0 if the width wasn't set.
      Returns:
      The width
      Since:
      4.12
    • setColorState

      public void setColorState(ColorState colorState)

      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.

      Parameters:
      colorState - a GdkColorState
      Since:
      4.16
    • setContext

      public void setContext(@Nullable GLContext context)

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

      The context must be set before calling build(MemorySegment).

      Parameters:
      context - The context the texture belongs to or null to unset
      Since:
      4.12
    • setFormat

      public void setFormat(MemoryFormat format)

      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.

      Parameters:
      format - The texture's format
      Since:
      4.12
    • setHasMipmap

      public void setHasMipmap(boolean hasMipmap)

      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.

      Parameters:
      hasMipmap - Whether the texture has a mipmap
      Since:
      4.12
    • setHeight

      public void setHeight(int height)

      Sets the height of the texture.

      The height must be set before calling build(MemorySegment).

      Parameters:
      height - The texture's height or 0 to unset
      Since:
      4.12
    • setId

      public void setId(int id)

      Sets the texture id of the texture. The texture id must remain unmodified until the texture was finalized. See build(MemorySegment) for a longer discussion.

      The id must be set before calling build(MemorySegment).

      Parameters:
      id - The texture id to be used for creating the texture
      Since:
      4.12
    • setSync

      public void setSync(@Nullable MemorySegment sync)

      Sets the GLSync object to use for the texture.

      GTK will wait on this object before using the created GdkTexture.

      The destroy function that is passed to build(MemorySegment) 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.

      Parameters:
      sync - the GLSync object
      Since:
      4.12
    • setUpdateRegion

      public void setUpdateRegion(@Nullable org.freedesktop.cairo.Region region)

      Sets the region to be updated by this texture. Together with 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.

      Parameters:
      region - the region to update
      Since:
      4.12
    • setUpdateTexture

      public void setUpdateTexture(@Nullable Texture texture)
      Sets the texture to be updated by this texture. See setUpdateRegion(Region) for an explanation.
      Parameters:
      texture - the texture to update
      Since:
      4.12
    • setWidth

      public void setWidth(int width)

      Sets the width of the texture.

      The width must be set before calling build(MemorySegment).

      Parameters:
      width - The texture's width or 0 to unset
      Since:
      4.12
    • builder

      public static GLTextureBuilder.Builder<? extends GLTextureBuilder.Builder> builder()
      A GLTextureBuilder.Builder object constructs a GLTextureBuilder with the specified properties. Use the various set...() methods to set properties, and finish construction with GLTextureBuilder.Builder.build().
      Returns:
      the builder object