Class GLTextureBuilder
- All Implemented Interfaces:
Proxy
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(java.lang.foreign.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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classGLTextureBuilder.Builder<B extends GLTextureBuilder.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new GLTextureBuilder.GLTextureBuilder(MemorySegment address) Create a GLTextureBuilder proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected GLTextureBuilderasParent()Returns this instance as if it were its parent type.build(@Nullable MemorySegment data) Builds a newGdkTexturewith the values set up in the builder.static GLTextureBuilder.Builder<? extends GLTextureBuilder.Builder> builder()AGLTextureBuilder.Builderobject constructs aGLTextureBuilderwith the specified properties.Gets the color state previously set via gdk_gl_texture_builder_set_color_state().@Nullable GLContextGets the context previously set via gdk_gl_texture_builder_set_context() ornullif none was set.Gets the format previously set via gdk_gl_texture_builder_set_format().booleanGets whether the texture has a mipmap.intGets the height previously set via gdk_gl_texture_builder_set_height() or 0 if the height wasn't set.intgetId()Gets the texture id previously set via gdk_gl_texture_builder_set_id() or 0 if the id wasn't set.@Nullable MemorySegmentgetSync()Gets theGLsyncpreviously set via gdk_gl_texture_builder_set_sync().static @Nullable TypegetType()Get the GType of the GLTextureBuilder class@Nullable org.freedesktop.cairo.RegionGets the region previously set via gdk_gl_texture_builder_set_update_region() ornullif none was set.@Nullable TextureGets the texture previously set via gdk_gl_texture_builder_set_update_texture() ornullif none was set.intgetWidth()Gets the width previously set via gdk_gl_texture_builder_set_width() or 0 if the width wasn't set.voidsetColorState(ColorState colorState) Sets the color state for the texture.voidsetContext(@Nullable GLContext context) Sets the context to be used for the texture.voidsetFormat(MemoryFormat format) Sets the format of the texture.voidsetHasMipmap(boolean hasMipmap) Sets whether the texture has a mipmap.voidsetHeight(int height) Sets the height of the texture.voidsetId(int id) Sets the texture id of the texture.voidsetSync(@Nullable MemorySegment sync) Sets the GLSync object to use for the texture.voidsetUpdateRegion(@Nullable org.freedesktop.cairo.Region region) Sets the region to be updated by this texture.voidsetUpdateTexture(@Nullable Texture texture) Sets the texture to be updated by this texture.voidsetWidth(int width) Sets the width of the texture.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
GLTextureBuilder
Create a GLTextureBuilder proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
GLTextureBuilder
public GLTextureBuilder()Creates a new GLTextureBuilder.
-
-
Method Details
-
getType
Get the GType of the GLTextureBuilder class- Returns:
- the GType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
build
Builds a newGdkTexturewith the values set up in the builder.The
destroyfunction gets called when the returned texture gets released; either when the texture is finalized or by an explicit call toGLTexture.release(). It should release all GL resources associated with the texture, such as theGdk.GLTextureBuilder:idand theGdk.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
Gets the color state previously set via gdk_gl_texture_builder_set_color_state().- Returns:
- the color state
- Since:
- 4.16
-
getContext
Gets the context previously set via gdk_gl_texture_builder_set_context() ornullif none was set.- Returns:
- The context
- Since:
- 4.12
-
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
Gets theGLsyncpreviously 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() ornullif none was set.- Returns:
- The region
- Since:
- 4.12
-
getUpdateTexture
Gets the texture previously set via gdk_gl_texture_builder_set_update_texture() ornullif 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
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- aGdkColorState- Since:
- 4.16
-
setContext
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(java.lang.foreign.MemorySegment).- Parameters:
context- The context the texture belongs to ornullto unset- Since:
- 4.12
-
setFormat
Sets the format of the texture. The default isGDK_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_PREMULTIPLIEDis expected to be stored asGL_RGBA16texture, andGDK_MEMORY_G8A8is expected to be stored asGL_RG8texture.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
glGenerateMipmapfunction 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(java.lang.foreign.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. Seebuild(java.lang.foreign.MemorySegment)for a longer discussion.The id must be set before calling
build(java.lang.foreign.MemorySegment).- Parameters:
id- The texture id to be used for creating the texture- Since:
- 4.12
-
setSync
Sets the GLSync object to use for the texture.GTK will wait on this object before using the created
GdkTexture.The
destroyfunction that is passed tobuild(java.lang.foreign.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 withGdk.GLTextureBuilder:update-texturethis 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
Sets the texture to be updated by this texture. SeesetUpdateRegion(org.freedesktop.cairo.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(java.lang.foreign.MemorySegment).- Parameters:
width- The texture's width or 0 to unset- Since:
- 4.12
-
builder
AGLTextureBuilder.Builderobject constructs aGLTextureBuilderwith the specified properties. Use the variousset...()methods to set properties, and finish construction withGLTextureBuilder.Builder.build().- Returns:
- the builder object
-