Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
optglarea.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef INKSCAPE_UI_WIDGET_OPTGLAREA_H
4#define INKSCAPE_UI_WIDGET_OPTGLAREA_H
5
6#include <epoxy/gl.h>
7#include <glibmm/refptr.h>
8#include <gtkmm/drawingarea.h>
9
10namespace Cairo { class Context; }
11namespace Gdk { class GLContext; }
12
13namespace Inkscape::UI::Widget {
14
19class OptGLArea : public Gtk::Widget
20{
21public:
23 ~OptGLArea() override;
24
30 void set_opengl_enabled(bool);
31 bool get_opengl_enabled() const { return opengl_enabled; }
32
37 void make_current();
38
42 void bind_framebuffer() const;
43
44 void snapshot_vfunc(Glib::RefPtr<Gtk::Snapshot> const &snapshot) override;
45
46protected:
47 void on_realize() override;
48 void on_unrealize() override;
49
53 virtual Glib::RefPtr<Gdk::GLContext> create_context() = 0;
54
58 virtual void paint_widget(Cairo::RefPtr<Cairo::Context> const &) {}
59
60private:
61 bool opengl_enabled = false;
62
63 struct GLState;
64 std::shared_ptr<GLState> gl;
65
66 void init_opengl();
67 void uninit_opengl();
68};
69
70} // namespace Inkscape::UI::Widget
71
72#endif // INKSCAPE_UI_WIDGET_OPTGLAREA_H
73
74/*
75 Local Variables:
76 mode:c++
77 c-file-style:"stroustrup"
78 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
79 indent-tabs-mode:nil
80 fill-column:99
81 End:
82*/
83// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
A widget that can dynamically switch between a Gtk::DrawingArea and a Gtk::GLArea.
Definition optglarea.h:20
std::shared_ptr< GLState > gl
Definition optglarea.h:64
virtual void paint_widget(Cairo::RefPtr< Cairo::Context > const &)
Reimplement to render the widget.
Definition optglarea.h:58
void snapshot_vfunc(Glib::RefPtr< Gtk::Snapshot > const &snapshot) override
void set_opengl_enabled(bool)
Set whether OpenGL is enabled.
Definition optglarea.cpp:91
void bind_framebuffer() const
Call before rendering to the widget to bind the widget's framebuffer.
virtual Glib::RefPtr< Gdk::GLContext > create_context()=0
Reimplement to create the desired OpenGL context.
void make_current()
Call before doing any OpenGL operations to make the context current.
Control handle rendering/caching.
Custom widgets.
Definition desktop.h:126