Class GLArea.Builder<B extends GLArea.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
Accessible.Builder<B>, BuilderInterface
Enclosing class:
GLArea

public static class GLArea.Builder<B extends GLArea.Builder<B>> extends Widget.Builder<B> implements Accessible.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public GLArea build()
      Finish building the GLArea object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to GLArea.
      Overrides:
      build in class Widget.Builder<B extends GLArea.Builder<B>>
      Returns:
      a new instance of GLArea with the properties that were set in the Builder object.
    • setAllowedApis

      public B setAllowedApis(Set<GLAPI> allowedApis)
      The allowed APIs.
      Parameters:
      allowedApis - the value for the allowed-apis property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.12
    • setAutoRender

      public B setAutoRender(boolean autoRender)

      If set to true the ::render signal will be emitted every time the widget draws.

      This is the default and is useful if drawing the widget is faster.

      If set to false the data from previous rendering is kept around and will be used for drawing the widget the next time, unless the window is resized. In order to force a rendering GLArea.queueRender() must be called. This mode is useful when the scene changes seldom, but takes a long time to redraw.

      Parameters:
      autoRender - the value for the auto-render property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHasDepthBuffer

      public B setHasDepthBuffer(boolean hasDepthBuffer)

      If set to true the widget will allocate and enable a depth buffer for the target framebuffer.

      Setting this property will enable GL's depth testing as a side effect. If you don't need depth testing, you should call glDisable(GL_DEPTH_TEST) in your GtkGLArea::render handler.

      Parameters:
      hasDepthBuffer - the value for the has-depth-buffer property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHasStencilBuffer

      public B setHasStencilBuffer(boolean hasStencilBuffer)
      If set to true the widget will allocate and enable a stencil buffer for the target framebuffer.
      Parameters:
      hasStencilBuffer - the value for the has-stencil-buffer property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setUseEs

      @Deprecated public B setUseEs(boolean useEs)
      Deprecated.
      Use Gtk.GLArea:allowed-apis
      If set to true the widget will try to create a GdkGLContext using OpenGL ES instead of OpenGL.
      Parameters:
      useEs - the value for the use-es property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setAllowedApis

      public B setAllowedApis(GLAPI... allowedApis)
      The allowed APIs.
      Parameters:
      allowedApis - the value for the allowed-apis property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.12
    • onCreateContext

      public B onCreateContext(GLArea.CreateContextCallback handler)

      Emitted when the widget is being realized.

      This allows you to override how the GL context is created. This is useful when you want to reuse an existing GL context, or if you want to try creating different kinds of GL options.

      If context creation fails then the signal handler can use GLArea.setError(GError) to register a more detailed error of how the construction failed.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onRender

      public B onRender(GLArea.RenderCallback handler)

      Emitted every time the contents of the GtkGLArea should be redrawn.

      The context is bound to the area prior to emitting this function, and the buffers are painted to the window once the emission terminates.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onResize

      public B onResize(GLArea.ResizeCallback handler)

      Emitted once when the widget is realized, and then each time the widget is changed while realized.

      This is useful in order to keep GL state up to date with the widget size, like for instance camera properties which may depend on the width/height ratio.

      The GL context for the area is guaranteed to be current when this signal is emitted.

      The default handler sets up the GL viewport.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: