1/* GTK - The GIMP Toolkit
2 *
3 * gtkglarea.h: A GL drawing area
4 *
5 * Copyright © 2014 Emmanuele Bassi
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __GTK_GL_AREA_H__
22#define __GTK_GL_AREA_H__
23
24#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
25#error "Only <gtk/gtk.h> can be included directly."
26#endif
27
28#include <gtk/gtkwidget.h>
29
30G_BEGIN_DECLS
31
32#define GTK_TYPE_GL_AREA (gtk_gl_area_get_type ())
33#define GTK_GL_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_GL_AREA, GtkGLArea))
34#define GTK_IS_GL_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_GL_AREA))
35#define GTK_GL_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_GL_AREA, GtkGLAreaClass))
36#define GTK_IS_GL_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_GL_AREA))
37#define GTK_GL_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_GL_AREA, GtkGLAreaClass))
38
39typedef struct _GtkGLArea GtkGLArea;
40typedef struct _GtkGLAreaClass GtkGLAreaClass;
41
42/**
43 * GtkGLArea:
44 *
45 * A #GtkWidget used for drawing with OpenGL.
46 *
47 * Since: 3.16
48 */
49struct _GtkGLArea
50{
51 /*< private >*/
52 GtkWidget parent_instance;
53};
54
55/**
56 * GtkGLAreaClass:
57 * @render: class closure for the #GtkGLArea::render signal
58 * @resize: class closeure for the #GtkGLArea::resize signal
59 * @create_context: class closure for the #GtkGLArea::create-context signal
60 *
61 * The `GtkGLAreaClass` structure contains only private data.
62 *
63 * Since: 3.16
64 */
65struct _GtkGLAreaClass
66{
67 /*< private >*/
68 GtkWidgetClass parent_class;
69
70 /*< public >*/
71 gboolean (* render) (GtkGLArea *area,
72 GdkGLContext *context);
73 void (* resize) (GtkGLArea *area,
74 int width,
75 int height);
76 GdkGLContext * (* create_context) (GtkGLArea *area);
77
78 /*< private >*/
79 gpointer _padding[6];
80};
81
82GDK_AVAILABLE_IN_3_16
83GType gtk_gl_area_get_type (void) G_GNUC_CONST;
84
85GDK_AVAILABLE_IN_3_16
86GtkWidget * gtk_gl_area_new (void);
87
88GDK_AVAILABLE_IN_3_22
89void gtk_gl_area_set_use_es (GtkGLArea *area,
90 gboolean use_es);
91GDK_AVAILABLE_IN_3_22
92gboolean gtk_gl_area_get_use_es (GtkGLArea *area);
93GDK_AVAILABLE_IN_3_16
94void gtk_gl_area_set_required_version (GtkGLArea *area,
95 gint major,
96 gint minor);
97GDK_AVAILABLE_IN_3_16
98void gtk_gl_area_get_required_version (GtkGLArea *area,
99 gint *major,
100 gint *minor);
101GDK_AVAILABLE_IN_3_16
102gboolean gtk_gl_area_get_has_alpha (GtkGLArea *area);
103GDK_AVAILABLE_IN_3_16
104void gtk_gl_area_set_has_alpha (GtkGLArea *area,
105 gboolean has_alpha);
106GDK_AVAILABLE_IN_3_16
107gboolean gtk_gl_area_get_has_depth_buffer (GtkGLArea *area);
108GDK_AVAILABLE_IN_3_16
109void gtk_gl_area_set_has_depth_buffer (GtkGLArea *area,
110 gboolean has_depth_buffer);
111GDK_AVAILABLE_IN_3_16
112gboolean gtk_gl_area_get_has_stencil_buffer (GtkGLArea *area);
113GDK_AVAILABLE_IN_3_16
114void gtk_gl_area_set_has_stencil_buffer (GtkGLArea *area,
115 gboolean has_stencil_buffer);
116GDK_AVAILABLE_IN_3_16
117gboolean gtk_gl_area_get_auto_render (GtkGLArea *area);
118GDK_AVAILABLE_IN_3_16
119void gtk_gl_area_set_auto_render (GtkGLArea *area,
120 gboolean auto_render);
121GDK_AVAILABLE_IN_3_16
122void gtk_gl_area_queue_render (GtkGLArea *area);
123
124
125GDK_AVAILABLE_IN_3_16
126GdkGLContext * gtk_gl_area_get_context (GtkGLArea *area);
127
128GDK_AVAILABLE_IN_3_16
129void gtk_gl_area_make_current (GtkGLArea *area);
130GDK_AVAILABLE_IN_3_16
131void gtk_gl_area_attach_buffers (GtkGLArea *area);
132
133GDK_AVAILABLE_IN_3_16
134void gtk_gl_area_set_error (GtkGLArea *area,
135 const GError *error);
136GDK_AVAILABLE_IN_3_16
137GError * gtk_gl_area_get_error (GtkGLArea *area);
138
139G_END_DECLS
140
141#endif /* __GTK_GL_AREA_H__ */
142