6 #include "drawing_area.h"
7 #include "../graphics/individual.h"
10 * The "draw" signal handler. All the OpenGL re-drawing should
11 * be done here. This is repeatedly called as the painting routine
12 * every time the 'draw' event is signalled.
14 gboolean drawing_area_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
16 /*** OpenGL BEGIN ***/
17 if (!gtk_widget_begin_gl (widget)) {
21 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
25 glTranslatef(0, 0, -10);
26 glColor3f (1.0, 1.0, 1.0);
27 graphics_render_individual();
30 gtk_widget_end_gl (widget, TRUE);
37 * The "configure_event" signal handler. Any processing required when
38 * the OpenGL-capable drawing area is re-configured should be done here.
39 * Almost always it will be used to resize the OpenGL viewport when
40 * the window is resized.
42 gboolean drawing_area_configure_event (GtkWidget *widget,
43 GdkEventConfigure *event, gpointer data)
45 GtkAllocation allocation;
47 /* OpenGL widget width */
49 /* OpenGL widget height */
54 gtk_widget_get_allocation (widget, &allocation);
56 h = allocation.height;
59 /*** OpenGL BEGIN ***/
60 if (!gtk_widget_begin_gl (widget))
63 glViewport (0, 0, w, h);
65 glMatrixMode (GL_PROJECTION);
67 gluPerspective (60.0, aspect, 1.0, 60.0);
68 glMatrixMode(GL_MODELVIEW);
70 gtk_widget_end_gl (widget, FALSE);
77 * The "realize" signal handler. All the OpenGL initialization
78 * should be performed here, such as default background colour,
81 void drawing_area_realize (GtkWidget *widget, gpointer data)
83 /*** OpenGL BEGIN ***/
84 if (!gtk_widget_begin_gl (widget)) {
88 glClearColor (0.0, 0.0, 0.0, 0.0);
89 glShadeModel (GL_FLAT);
91 gtk_widget_end_gl (widget, FALSE);
98 * The "unrealize" signal handler. Any processing required when
99 * the OpenGL-capable window is unrealized should be done here.
101 void drawing_area_unrealize (GtkWidget *widget, gpointer data)