11218
|
1 #include <gtk/gtk.h>
|
|
2 #include <gtk/gtkgl.h>
|
|
3
|
|
4 #define DEFAULT_FRAME_DELAY 40
|
|
5
|
|
6 typedef void (gl_init_func) (GtkWidget *widget, void *data);
|
|
7 typedef gboolean (*gl_config_func) (GtkWidget *widget, GdkEventConfigure *event,
|
|
8 void *data);
|
|
9 typedef gboolean (*gl_draw_func) (GtkWidget *widget, GdkEventExpose *event,
|
|
10 void *data);
|
|
11
|
|
12 struct draw_info {
|
|
13 gboolean timeout; /* use/not use a timer callback */
|
|
14 int timer_id; /* glib timer callback id */
|
|
15 guint delay_ms; /* timer callback delay in ms */
|
|
16 void *data; /* drawing data */
|
|
17 };
|
|
18
|
|
19 struct window_box {
|
|
20 GtkWidget *window;
|
|
21 GtkWidget *vbox;
|
|
22 GtkWidget *draw_area;
|
|
23 };
|
|
24
|
|
25 /**
|
|
26 * Initialize the gtkglext framework for all our widgets.
|
|
27 * @return 0 on success, non-zero on failure
|
|
28 */
|
|
29 int cc_init_gtk_gl();
|
|
30
|
|
31 /**
|
|
32 * Create a new OpenGL enabled window
|
|
33 * @param init the initialize callback function
|
|
34 * @param draw the drawing callback function
|
|
35 * @param data drawing metadata
|
|
36 * @param ret struct with returned window and vbox
|
|
37 */
|
|
38 void cc_new_gl_window(gl_init_func init, gl_config_func config,
|
|
39 gl_draw_func draw, struct draw_info *data,
|
|
40 struct window_box *ret);
|
|
41
|
|
42 /**
|
|
43 * Create a new OpenGL enabled drawing area widget.
|
|
44 * @param init the initialize callback function
|
|
45 * @param draw the drawing callback function
|
|
46 * @param data drawing metadata
|
|
47 * @return the drawing widget
|
|
48 */
|
|
49 GtkWidget *cc_new_gl_area(gl_init_func init, gl_config_func config,
|
|
50 gl_draw_func draw, struct draw_info *data);
|