6 #include "drawing_area.h"
9 * The "draw" signal handler. All the OpenGL re-drawing should
10 * be done here. This is repeatedly called as the painting routine
11 * every time the 'draw' event is signalled.
13 gboolean drawing_area_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
15 /*** OpenGL BEGIN ***/
16 if (!gtk_widget_begin_gl (widget)) {
20 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
23 glColor3f (1.0, 1.0, 1.0);
26 gtk_widget_end_gl (widget, TRUE);
33 * The "configure_event" signal handler. Any processing required when
34 * the OpenGL-capable drawing area is re-configured should be done here.
35 * Almost always it will be used to resize the OpenGL viewport when
36 * the window is resized.
38 gboolean drawing_area_configure_event (GtkWidget *widget,
39 GdkEventConfigure *event, gpointer data)
41 GtkAllocation allocation;
43 /* OpenGL widget width */
45 /* OpenGL widget height */
48 /* Current page width */
50 /* Current page height */
53 struct order_page *page = NULL;
55 gtk_widget_get_allocation (widget, &allocation);
57 h = allocation.height;
59 /*** OpenGL BEGIN ***/
60 if (!gtk_widget_begin_gl (widget))
63 glViewport (0, 0, w, h);
65 glMatrixMode (GL_PROJECTION);
70 glMatrixMode (GL_MODELVIEW);
72 gtk_widget_end_gl (widget, FALSE);
79 * The "realize" signal handler. All the OpenGL initialization
80 * should be performed here, such as default background colour,
83 void drawing_area_realize (GtkWidget *widget, gpointer data)
85 /*** OpenGL BEGIN ***/
86 if (!gtk_widget_begin_gl (widget)) {
90 glClearColor (0.0, 0.0, 0.0, 0.0);
91 glShadeModel (GL_FLAT);
93 gtk_widget_end_gl (widget, FALSE);
100 * The "unrealize" signal handler. Any processing required when
101 * the OpenGL-capable window is unrealized should be done here.
103 void drawing_area_unrealize (GtkWidget *widget, gpointer data)