-gboolean on_map(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
-{
- g_debug("AWeatherGui: on_map");
- AWeatherView *view = aweather_gui_get_view(gui);
-
- /* Misc */
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-
- /* Tessellation, "finding intersecting triangles" */
- /* http://research.microsoft.com/pubs/70307/tr-2006-81.pdf */
- /* http://www.opengl.org/wiki/Alpha_Blending */
- glAlphaFunc(GL_GREATER,0.1);
- glEnable(GL_ALPHA_TEST);
-
- /* Depth test */
- glClearDepth(1.0);
- glDepthFunc(GL_LEQUAL);
- glEnable(GL_DEPTH_TEST);
-
- aweather_gui_gl_end(gui);
- return FALSE;
-}
-
-gboolean on_configure(GtkWidget *da, GdkEventConfigure *event, AWeatherGui *gui)
-{
- g_debug("AWeatherGui: on_confiure");
- aweather_gui_gl_begin(gui);
-
- double x, y, z;
- AWeatherView *view = aweather_gui_get_view(gui);
- aweather_view_get_location(view, &x, &y, &z);
-
- /* Window is at 500 m from camera */
- double width = da->allocation.width;
- double height = da->allocation.height;
-
- glViewport(0, 0, width, height);
-
- /* Perspective */
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- double rad = atan((height/2)/500);
- double deg = (rad*180)/M_PI;
-
- gluPerspective(deg*2, width/height, -z-20, -z+20);
- //gluPerspective(deg*2, width/height, 1, 500*1000);
-
- aweather_gui_gl_end(gui);
- return FALSE;
-}
-
-gboolean on_expose(GtkWidget *da, GdkEventExpose *event, AWeatherGui *gui)
-{
- g_debug("AWeatherGui: on_expose - begin");
- aweather_gui_gl_begin(gui);
-
- double x, y, z;
- AWeatherView *view = aweather_gui_get_view(gui);
- aweather_view_get_location(view, &x, &y, &z);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(x, y, z);
-
- //glRotatef(-45, 1, 0, 0);
-
- /* Expose plugins */
- for (GList *cur = gui->plugins; cur; cur = cur->next) {
- AWeatherPlugin *plugin = AWEATHER_PLUGIN(cur->data);
- aweather_plugin_expose(plugin);
- }
-
- aweather_gui_gl_end(gui);
- aweather_gui_gl_flush(gui);
- g_debug("AWeatherGui: on_expose - end\n");
- return FALSE;
-}
-
-void on_about(GtkMenuItem *item, AWeatherGui *gui)
-{
- GError *error = NULL;
- GtkBuilder *builder = gtk_builder_new();
- if (!gtk_builder_add_from_file(builder, DATADIR "/aweather/about.xml", &error))
- g_error("Failed to create gtk builder: %s", error->message);
- gtk_builder_connect_signals(builder, NULL);
- GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
- gtk_window_set_transient_for(GTK_WINDOW(window),
- GTK_WINDOW(aweather_gui_get_widget(gui, "window")));
- gtk_widget_show_all(window);
- g_object_unref(builder);
-}
-
-void on_location_changed(AWeatherView *view,
- gdouble x, gdouble y, gdouble z, AWeatherGui *gui)
-{
- /* Reset clipping area and redraw */
- GtkWidget *da = aweather_gui_get_widget(gui, "drawing");
- on_configure(da, NULL, gui);
- aweather_gui_gl_redraw(gui);
-}
-