Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::UI::Widget::OptGLArea Class Referenceabstract

A widget that can dynamically switch between a Gtk::DrawingArea and a Gtk::GLArea. More...

#include <optglarea.h>

Inheritance diagram for Inkscape::UI::Widget::OptGLArea:
Inkscape::UI::Widget::Canvas

Public Member Functions

 OptGLArea ()
 
 ~OptGLArea () override
 
void set_opengl_enabled (bool)
 Set whether OpenGL is enabled.
 
bool get_opengl_enabled () const
 
void make_current ()
 Call before doing any OpenGL operations to make the context current.
 
void bind_framebuffer () const
 Call before rendering to the widget to bind the widget's framebuffer.
 
void snapshot_vfunc (Glib::RefPtr< Gtk::Snapshot > const &snapshot) override
 

Protected Member Functions

void on_realize () override
 
void on_unrealize () override
 
virtual Glib::RefPtr< Gdk::GLContext > create_context ()=0
 Reimplement to create the desired OpenGL context.
 
virtual void paint_widget (Cairo::RefPtr< Cairo::Context > const &)
 Reimplement to render the widget.
 

Private Member Functions

void init_opengl ()
 
void uninit_opengl ()
 

Private Attributes

bool opengl_enabled = false
 
std::shared_ptr< GLState > gl
 

Detailed Description

A widget that can dynamically switch between a Gtk::DrawingArea and a Gtk::GLArea.

Based on the source code for both widgets.

Definition at line 19 of file optglarea.h.

Constructor & Destructor Documentation

◆ OptGLArea()

Inkscape::UI::Widget::OptGLArea::OptGLArea ( )
default

◆ ~OptGLArea()

Inkscape::UI::Widget::OptGLArea::~OptGLArea ( )
overridedefault

Member Function Documentation

◆ bind_framebuffer()

void Inkscape::UI::Widget::OptGLArea::bind_framebuffer ( ) const

Call before rendering to the widget to bind the widget's framebuffer.

Definition at line 124 of file optglarea.cpp.

References gl.

Referenced by Inkscape::UI::Widget::Canvas::paint_widget().

◆ create_context()

virtual Glib::RefPtr< Gdk::GLContext > Inkscape::UI::Widget::OptGLArea::create_context ( )
protectedpure virtual

Reimplement to create the desired OpenGL context.

Return nullptr on error.

Implemented in Inkscape::UI::Widget::Canvas.

Referenced by init_opengl().

◆ get_opengl_enabled()

bool Inkscape::UI::Widget::OptGLArea::get_opengl_enabled ( ) const
inline

◆ init_opengl()

void Inkscape::UI::Widget::OptGLArea::init_opengl ( )
private

Definition at line 99 of file optglarea.cpp.

References create_context(), gl, and opengl_enabled.

Referenced by on_realize(), and set_opengl_enabled().

◆ make_current()

void Inkscape::UI::Widget::OptGLArea::make_current ( )

Call before doing any OpenGL operations to make the context current.

Automatically done before calling paint_widget().

Definition at line 118 of file optglarea.cpp.

References gl.

◆ on_realize()

void Inkscape::UI::Widget::OptGLArea::on_realize ( )
overrideprotected

Definition at line 79 of file optglarea.cpp.

References init_opengl(), and opengl_enabled.

Referenced by Inkscape::UI::Widget::Canvas::on_realize().

◆ on_unrealize()

void Inkscape::UI::Widget::OptGLArea::on_unrealize ( )
overrideprotected

Definition at line 85 of file optglarea.cpp.

References opengl_enabled, and uninit_opengl().

Referenced by Inkscape::UI::Widget::Canvas::on_unrealize().

◆ paint_widget()

virtual void Inkscape::UI::Widget::OptGLArea::paint_widget ( Cairo::RefPtr< Cairo::Context > const &  )
inlineprotectedvirtual

Reimplement to render the widget.

The Cairo context is only for when OpenGL is disabled.

Reimplemented in Inkscape::UI::Widget::Canvas.

Definition at line 58 of file optglarea.h.

Referenced by snapshot_vfunc().

◆ set_opengl_enabled()

void Inkscape::UI::Widget::OptGLArea::set_opengl_enabled ( bool  enabled)

Set whether OpenGL is enabled.

Initially it is disabled. Upon enabling it, create_context will be called as soon as the widget is realized. If context creation fails, OpenGL will be disabled again.

Definition at line 91 of file optglarea.cpp.

References init_opengl(), opengl_enabled, and uninit_opengl().

Referenced by Inkscape::UI::Widget::Canvas::Canvas().

◆ snapshot_vfunc()

void Inkscape::UI::Widget::OptGLArea::snapshot_vfunc ( Glib::RefPtr< Gtk::Snapshot > const &  snapshot)
override

◆ uninit_opengl()

void Inkscape::UI::Widget::OptGLArea::uninit_opengl ( )
private

Definition at line 111 of file optglarea.cpp.

References gl.

Referenced by on_unrealize(), and set_opengl_enabled().

Member Data Documentation

◆ gl

std::shared_ptr<GLState> Inkscape::UI::Widget::OptGLArea::gl
private

◆ opengl_enabled

bool Inkscape::UI::Widget::OptGLArea::opengl_enabled = false
private

The documentation for this class was generated from the following files: