pub struct Painter { /* private fields */ }
Expand description

An OpenGL painter using glow.

This is responsible for painting egui and managing egui textures. You can access the underlying glow::Context with Self::gl.

This struct must be destroyed with Painter::destroy before dropping, to ensure OpenGL objects have been properly deleted and are not leaked.

Implementations

Create painter.

Set pp_fb_extent to the framebuffer size to enable sRGB support on OpenGL ES and WebGL.

Set shader_prefix if you want to turn on shader workaround e.g. "#define APPLY_BRIGHTENING_GAMMA\n" (see https://github.com/emilk/egui/issues/794).

Errors

will return Err below cases

  • failed to compile shader
  • failed to create postprocess on webgl with sRGB support
  • failed to create buffer

Access the shared glow context.

The framebuffer we use as an intermediate render target, or None if we are painting to the screen framebuffer directly.

This is the framebuffer that is bound when [egui::Shape::Callback] is called, and is where any callbacks should ultimately render onto.

So if in a [egui::Shape::Callback] you need to use an offscreen FBO, you should then restore to this afterwards with gl.bind_framebuffer(glow::FRAMEBUFFER, painter.intermediate_fbo());

You are expected to have cleared the color buffer before calling this.

Main entry-point for painting a frame.

You should call target.clear_color(..) before and target.finish() after this.

The following OpenGL features will be set:

  • Scissor test will be enabled
  • Cull face will be disabled
  • Blend will be enabled

The scissor area and blend parameters will be changed.

As well as this, the following objects will be unset:

  • Vertex Buffer
  • Element Buffer
  • Texture (and active texture will be set to 0)
  • Program

Please be mindful of these effects when integrating into your program, and also be mindful of the effects your program might have on this code. Look at the source if in doubt.

Get the glow::Texture bound to a [egui::TextureId].

👎 Deprecated:

renamed ‘texture’

This function must be called before Painter is dropped, as Painter has some OpenGL objects that should be deleted.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more