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 */
52 /* Current page width */
54 /* Current page height */
59 gtk_widget_get_allocation (widget, &allocation);
61 h = allocation.height;
64 /*** OpenGL BEGIN ***/
65 if (!gtk_widget_begin_gl (widget))
68 glViewport (0, 0, w, h);
70 glMatrixMode (GL_PROJECTION);
72 gluPerspective (60.0, aspect, 1.0, 60.0);
73 glMatrixMode(GL_MODELVIEW);
75 gtk_widget_end_gl (widget, FALSE);
82 * The "realize" signal handler. All the OpenGL initialization
83 * should be performed here, such as default background colour,
86 void drawing_area_realize (GtkWidget *widget, gpointer data)
88 /*** OpenGL BEGIN ***/
89 if (!gtk_widget_begin_gl (widget)) {
93 glClearColor (0.0, 0.0, 0.0, 0.0);
94 glShadeModel (GL_FLAT);
96 gtk_widget_end_gl (widget, FALSE);
103 * The "unrealize" signal handler. Any processing required when
104 * the OpenGL-capable window is unrealized should be done here.
106 void drawing_area_unrealize (GtkWidget *widget, gpointer data)