Added po configurations.
[familia.git] / src / viewport / drawing_area.c
1 #include <gtk/gtk.h>
2 #include <gtk/gtkgl.h>
3 #include <GL/gl.h>
4
5 #include "../debug.h"
6 #include "drawing_area.h"
7
8 /**
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.
12  */
13 gboolean drawing_area_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
14 {
15         /*** OpenGL BEGIN ***/
16         if (!gtk_widget_begin_gl (widget)) {
17                 return FALSE;
18         }
19
20         glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
21
22         glPushMatrix ();
23                 glColor3f (1.0, 1.0, 1.0);
24         glPopMatrix ();
25
26         gtk_widget_end_gl (widget, TRUE);
27         /*** OpenGL END ***/
28
29         return TRUE;
30 }
31
32 /**
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.
37  */
38 gboolean drawing_area_configure_event (GtkWidget *widget,
39                                         GdkEventConfigure *event, gpointer data)
40 {
41         GtkAllocation allocation;
42
43         /* OpenGL widget width */
44         GLfloat w;
45         /* OpenGL widget height */
46         GLfloat h;
47
48         /* Current page width */
49         GLfloat width = 0;
50         /* Current page height */
51         GLfloat height = 0;
52         /* Current page */
53         struct order_page *page = NULL;
54
55         gtk_widget_get_allocation (widget, &allocation);
56         w = allocation.width;
57         h = allocation.height;
58
59         /*** OpenGL BEGIN ***/
60         if (!gtk_widget_begin_gl (widget))
61                 return FALSE;
62
63         glViewport (0, 0, w, h);
64
65         glMatrixMode (GL_PROJECTION);
66         glLoadIdentity ();
67
68         /* Code was here */
69
70         glMatrixMode (GL_MODELVIEW);
71
72         gtk_widget_end_gl (widget, FALSE);
73         /*** OpenGL END ***/
74
75         return TRUE;
76 }
77
78 /**
79  * The "realize" signal handler. All the OpenGL initialization
80  * should be performed here, such as default background colour,
81  * certain states etc.
82  */
83 void drawing_area_realize (GtkWidget *widget, gpointer data)
84 {
85         /*** OpenGL BEGIN ***/
86         if (!gtk_widget_begin_gl (widget)) {
87                 return;
88         }
89
90         glClearColor (0.0, 0.0, 0.0, 0.0);
91         glShadeModel (GL_FLAT);
92
93         gtk_widget_end_gl (widget, FALSE);
94         /*** OpenGL END ***/
95
96         return;
97 }
98
99 /**
100  * The "unrealize" signal handler. Any processing required when
101  * the OpenGL-capable window is unrealized should be done here.
102  */
103 void drawing_area_unrealize (GtkWidget *widget, gpointer data)
104 {
105         /* Code */
106 }