2 * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * SECTION:grits-opengl
20 * @short_description: OpenGL based virtual globe
22 * #GritsOpenGL is the core rendering engine used by grits. Theoretically other
23 * renderers could be writte, but they have not been. GritsOpenGL uses the ROAM
24 * algorithm for updating surface mesh the planet. The only thing GritsOpenGL
25 * can actually render on it's own is a wireframe of a sphere.
27 * GritsOpenGL requires (at least) OpenGL 2.0.
33 #include <gdk/gdkkeysyms.h>
36 #include "grits-opengl.h"
37 #include "grits-util.h"
43 /* Tessellation, "finding intersecting triangles" */
44 /* http://research.microsoft.com/pubs/70307/tr-2006-81.pdf */
45 /* http://www.opengl.org/wiki/Alpha_Blending */
47 /* The unsorted/sroted GLists are blank head nodes,
48 * This way us we can remove objects from the level just by fixing up links
49 * I.e. we don't need to do a lookup to remove an object if we have its GList */
59 static void _set_projection(GritsOpenGL *opengl)
61 double lat, lon, elev, rx, ry, rz;
62 grits_viewer_get_location(GRITS_VIEWER(opengl), &lat, &lon, &elev);
63 grits_viewer_get_rotation(GRITS_VIEWER(opengl), &rx, &ry, &rz);
65 /* Set projection and clipping planes */
66 glMatrixMode(GL_PROJECTION);
69 double width = GTK_WIDGET(opengl)->allocation.width;
70 double height = GTK_WIDGET(opengl)->allocation.height;
71 double ang = atan((height/2)/FOV_DIST)*2;
72 double atmos = 100000;
73 double near = MAX(elev*0.75 - atmos, 50); // View 100km of atmosphere
74 double far = elev + 2*EARTH_R + atmos; // on both sides of the earth
76 glViewport(0, 0, width, height);
77 gluPerspective(rad2deg(ang), width/height, near, far);
79 /* Setup camera and lighting */
80 glMatrixMode(GL_MODELVIEW);
84 glRotatef(rx, 1, 0, 0);
85 glRotatef(rz, 0, 0, 1);
88 float light_position[] = {-13*EARTH_R, 1*EARTH_R, 3*EARTH_R, 1.0f};
89 glLightfv(GL_LIGHT0, GL_POSITION, light_position);
92 glTranslatef(0, 0, -elev2rad(elev));
93 glRotatef(lat, 1, 0, 0);
94 glRotatef(-lon, 0, 1, 0);
96 /* Update roam view */
97 g_mutex_lock(&opengl->sphere_lock);
98 roam_sphere_update_view(opengl->sphere);
99 g_mutex_unlock(&opengl->sphere_lock);
102 static void _set_settings(GritsOpenGL *opengl)
104 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
106 glDisable(GL_ALPHA_TEST);
109 glEnable(GL_LIGHTING);
111 glEnable(GL_LINE_SMOOTH);
113 glDisable(GL_TEXTURE_2D);
114 glDisable(GL_COLOR_MATERIAL);
116 if (opengl->wireframe)
117 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
119 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
123 float light_ambient[] = {0.7f, 0.7f, 0.7f, 1.0f};
124 float light_diffuse[] = {2.0f, 2.0f, 2.0f, 1.0f};
126 float light_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};
127 float light_diffuse[] = {0.8f, 0.8f, 0.8f, 1.0f};
129 glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
130 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
133 float material_ambient[] = {1.0, 1.0, 1.0, 1.0};
134 float material_diffuse[] = {1.0, 1.0, 1.0, 1.0};
135 float material_specular[] = {0.0, 0.0, 0.0, 1.0};
136 float material_emission[] = {0.0, 0.0, 0.0, 1.0};
137 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material_ambient);
138 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_diffuse);
139 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_specular);
140 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, material_emission);
143 glColor4f(1.0, 1.0, 1.0, 1.0);
147 glEnable(GL_CULL_FACE);
150 glDepthFunc(GL_LEQUAL);
151 glEnable(GL_DEPTH_TEST);
155 static GPtrArray *_objects_to_array(GritsOpenGL *opengl, gboolean ortho)
157 GPtrArray *array = g_ptr_array_new();
158 for (GList *i = opengl->objects->head; i; i = i->next) {
159 struct RenderLevel *level = i->data;
160 if ((ortho == TRUE && level->num < GRITS_LEVEL_HUD) ||
161 (ortho == FALSE && level->num >= GRITS_LEVEL_HUD))
163 for (GList *j = level->unsorted.next; j; j = j->next)
164 g_ptr_array_add(array, j->data);
165 for (GList *j = level->sorted.next; j; j = j->next)
166 g_ptr_array_add(array, j->data);
175 static gint run_picking(GritsOpenGL *opengl, GdkEvent *event,
176 GPtrArray *objects, GritsObject **top)
178 /* Setup picking buffers */
179 guint buffer[100][4] = {};
180 glSelectBuffer(G_N_ELEMENTS(buffer), (guint*)buffer);
181 if (!opengl->pickmode)
182 glRenderMode(GL_SELECT);
185 /* Render/pick objects */
186 for (guint i = 0; i < objects->len; i++) {
188 GritsObject *object = objects->pdata[i];
189 object->state.picked = FALSE;
190 grits_object_pick(object, opengl);
194 int hits = glRenderMode(GL_RENDER);
197 for (int i = 0; i < hits; i++) {
198 //g_debug("\tHit: %d", i);
199 //g_debug("\t\tcount: %d", buffer[i][0]);
200 //g_debug("\t\tz1: %f", (float)buffer[i][1]/0x7fffffff);
201 //g_debug("\t\tz2: %f", (float)buffer[i][2]/0x7fffffff);
202 //g_debug("\t\tname: %p", (gpointer)buffer[i][3]);
203 guint index = buffer[i][3];
204 GritsObject *object = objects->pdata[index];
205 object->state.picked = TRUE;
209 /* Notify objects of pointer movements */
210 for (guint i = 0; i < objects->len; i++) {
211 GritsObject *object = objects->pdata[i];
212 grits_object_set_pointer(object, event, object->state.picked);
218 static gboolean run_mouse_move(GritsOpenGL *opengl, GdkEventMotion *event)
220 gdouble height = GTK_WIDGET(opengl)->allocation.height;
221 gdouble gl_x = event->x;
222 gdouble gl_y = height - event->y;
223 gdouble delta = opengl->pickmode ? 200 : 2;
225 if (opengl->pickmode) {
226 gtk_gl_begin(GTK_WIDGET(opengl));
227 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
231 gdouble projection[16];
232 gint viewport[4]; // x=0,y=0,w,h
233 glGetDoublev(GL_PROJECTION_MATRIX, projection);
234 glGetIntegerv(GL_VIEWPORT, viewport);
235 glMatrixMode(GL_MODELVIEW); glPushMatrix();
236 glMatrixMode(GL_PROJECTION); glPushMatrix();
238 g_mutex_lock(&opengl->objects_lock);
240 GritsObject *top = NULL;
241 GPtrArray *ortho = _objects_to_array(opengl, TRUE);
242 GPtrArray *world = _objects_to_array(opengl, FALSE);
244 /* Run perspective picking */
245 glMatrixMode(GL_PROJECTION); glLoadIdentity();
246 gluPickMatrix(gl_x, gl_y, delta, delta, viewport);
247 glMultMatrixd(projection);
248 gint world_hits = run_picking(opengl, (GdkEvent*)event, world, &top);
250 /* Run ortho picking */
251 glMatrixMode(GL_PROJECTION); glLoadIdentity();
252 gluPickMatrix(gl_x, gl_y, delta, delta, viewport);
253 glMatrixMode(GL_MODELVIEW); glLoadIdentity();
254 glOrtho(0, viewport[2], viewport[3], 0, 1000, -1000);
255 gint ortho_hits = run_picking(opengl, (GdkEvent*)event, ortho, &top);
258 static GdkCursor *cursor = NULL;
259 static GdkWindow *window = NULL;
260 if (!window || !cursor) {
261 cursor = gdk_cursor_new(GDK_FLEUR);
262 window = gtk_widget_get_window(GTK_WIDGET(opengl));
264 GdkCursor *topcursor = top && top->cursor ? top->cursor : cursor;
265 gdk_window_set_cursor(window, topcursor);
267 g_debug("GritsOpenGL: run_mouse_move - hits=%d/%d,%d/%d ev=%.0lf,%.0lf",
268 world_hits, world->len, ortho_hits, ortho->len, gl_x, gl_y);
270 g_ptr_array_free(world, TRUE);
271 g_ptr_array_free(ortho, TRUE);
273 g_mutex_unlock(&opengl->objects_lock);
276 //gdouble lat, lon, elev;
277 //grits_viewer_unproject(GRITS_VIEWER(opengl),
278 // gl_x, gl_y, -1, &lat, &lon, &elev);
281 glMatrixMode(GL_PROJECTION); glPopMatrix();
282 glMatrixMode(GL_MODELVIEW); glPopMatrix();
284 if (opengl->pickmode)
285 gtk_gl_end(GTK_WIDGET(opengl));
290 static gboolean on_motion_notify(GritsOpenGL *opengl, GdkEventMotion *event, gpointer _)
292 opengl->mouse_queue = *event;
293 gtk_widget_queue_draw(GTK_WIDGET(opengl));
297 static void _draw_level(gpointer _level, gpointer _opengl)
299 GritsOpenGL *opengl = _opengl;
300 struct RenderLevel *level = _level;
302 g_debug("GritsOpenGL: _draw_level - level=%-4d", level->num);
303 int nsorted = 0, nunsorted = 0;
306 /* Configure individual levels */
307 if (level->num < GRITS_LEVEL_WORLD) {
308 /* Disable depth for background levels */
310 glDisable(GL_ALPHA_TEST);
311 } else if (level->num < GRITS_LEVEL_OVERLAY) {
312 /* Enable depth and alpha for world levels */
313 glEnable(GL_ALPHA_TEST);
314 glAlphaFunc(GL_GREATER, 0.1);
316 /* Disable depth for Overlay/HUD levels */
321 if (level->num >= GRITS_LEVEL_HUD) {
322 glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
323 glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();
324 gint win_width = GTK_WIDGET(opengl)->allocation.width;
325 gint win_height = GTK_WIDGET(opengl)->allocation.height;
326 glOrtho(0, win_width, win_height, 0, 1000, -1000);
329 /* Draw unsorted objects without depth testing,
330 * these are polygons, etc, rather than physical objects */
331 glDisable(GL_DEPTH_TEST);
332 for (cur = level->unsorted.next; cur; cur = cur->next, nunsorted++)
333 grits_object_draw(GRITS_OBJECT(cur->data), opengl);
335 /* Draw sorted objects using depth testing
336 * These are things that are actually part of the world */
337 glEnable(GL_DEPTH_TEST);
338 for (cur = level->sorted.next; cur; cur = cur->next, nsorted++)
339 grits_object_draw(GRITS_OBJECT(cur->data), opengl);
342 if (level->num >= GRITS_LEVEL_HUD) {
343 glMatrixMode(GL_PROJECTION); glPopMatrix();
344 glMatrixMode(GL_MODELVIEW); glPopMatrix();
347 /* Leave depth buffer write enabled */
350 /* TODO: Prune empty levels */
352 g_debug("GritsOpenGL: _draw_level - drew %d,%d objects",
356 static gboolean on_expose(GritsOpenGL *opengl, GdkEventExpose *event, gpointer _)
358 g_debug("GritsOpenGL: on_expose - begin");
360 if (opengl->pickmode)
361 return run_mouse_move(opengl, (GdkEventMotion*)event);
363 if (opengl->mouse_queue.type != GDK_NOTHING) {
364 run_mouse_move(opengl, &opengl->mouse_queue);
365 opengl->mouse_queue.type = GDK_NOTHING;
368 gtk_gl_begin(GTK_WIDGET(opengl));
370 _set_settings(opengl);
371 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
374 roam_sphere_update_errors(opengl->sphere);
375 roam_sphere_split_merge(opengl->sphere);
379 roam_sphere_draw(opengl->sphere);
380 roam_sphere_draw_normals(opengl->sphere);
383 g_mutex_lock(&opengl->objects_lock);
384 g_queue_foreach(opengl->objects, _draw_level, opengl);
385 g_mutex_unlock(&opengl->objects_lock);
388 gtk_gl_end(GTK_WIDGET(opengl));
390 g_debug("GritsOpenGL: on_expose - end\n");
394 static gboolean on_key_press(GritsOpenGL *opengl, GdkEventKey *event, gpointer _)
396 g_debug("GritsOpenGL: on_key_press - key=%x, state=%x, plus=%x",
397 event->keyval, event->state, GDK_plus);
399 guint kv = event->keyval;
402 opengl->wireframe = !opengl->wireframe;
403 gtk_widget_queue_draw(GTK_WIDGET(opengl));
406 opengl->pickmode = !opengl->pickmode;
407 gtk_widget_queue_draw(GTK_WIDGET(opengl));
410 else if (kv == GDK_n) roam_sphere_split_one(opengl->sphere);
411 else if (kv == GDK_p) roam_sphere_merge_one(opengl->sphere);
412 else if (kv == GDK_r) roam_sphere_split_merge(opengl->sphere);
413 else if (kv == GDK_u) roam_sphere_update_errors(opengl->sphere);
414 gtk_widget_queue_draw(GTK_WIDGET(opengl));
419 static gboolean on_chained_event(GritsOpenGL *opengl, GdkEvent *event, gpointer _)
421 for (GList *i = opengl->objects->tail; i; i = i->prev) {
422 struct RenderLevel *level = i->data;
423 for (GList *j = level->unsorted.next; j; j = j->next)
424 if (grits_object_event(j->data, event))
426 for (GList *j = level->sorted.next; j; j = j->next)
427 if (grits_object_event(j->data, event))
433 static void on_realize(GritsOpenGL *opengl, gpointer _)
435 g_debug("GritsOpenGL: on_realize");
436 gtk_gl_begin(GTK_WIDGET(opengl));
438 /* Connect signals and idle functions now that opengl is fully initialized */
439 gtk_widget_add_events(GTK_WIDGET(opengl), GDK_KEY_PRESS_MASK);
440 g_signal_connect(opengl, "configure-event", G_CALLBACK(_set_projection), NULL);
441 g_signal_connect(opengl, "expose-event", G_CALLBACK(on_expose), NULL);
443 g_signal_connect(opengl, "key-press-event", G_CALLBACK(on_key_press), NULL);
445 g_signal_connect(opengl, "location-changed", G_CALLBACK(_set_projection), NULL);
446 g_signal_connect(opengl, "rotation-changed", G_CALLBACK(_set_projection), NULL);
448 g_signal_connect(opengl, "motion-notify-event", G_CALLBACK(on_motion_notify), NULL);
449 g_signal_connect_after(opengl, "key-press-event", G_CALLBACK(on_chained_event), NULL);
450 g_signal_connect_after(opengl, "key-release-event", G_CALLBACK(on_chained_event), NULL);
451 g_signal_connect_after(opengl, "button-press-event", G_CALLBACK(on_chained_event), NULL);
452 g_signal_connect_after(opengl, "button-release-event", G_CALLBACK(on_chained_event), NULL);
453 g_signal_connect_after(opengl, "motion-notify-event", G_CALLBACK(on_chained_event), NULL);
455 /* Re-queue resize incase configure was triggered before realize */
456 gtk_widget_queue_resize(GTK_WIDGET(opengl));
459 /*********************
460 * GritsViewer methods *
461 *********************/
464 * @plugins: the plugins store to use
465 * @prefs: the preferences object to use
467 * Create a new OpenGL renderer.
469 * Returns: the new #GritsOpenGL
471 GritsViewer *grits_opengl_new(GritsPlugins *plugins, GritsPrefs *prefs)
473 g_debug("GritsOpenGL: new");
474 GritsViewer *opengl = g_object_new(GRITS_TYPE_OPENGL, NULL);
475 grits_viewer_setup(opengl, plugins, prefs);
479 static void grits_opengl_center_position(GritsViewer *_opengl, gdouble lat, gdouble lon, gdouble elev)
481 glRotatef(lon, 0, 1, 0);
482 glRotatef(-lat, 1, 0, 0);
483 glTranslatef(0, 0, elev2rad(elev));
486 static void grits_opengl_project(GritsViewer *_opengl,
487 gdouble lat, gdouble lon, gdouble elev,
488 gdouble *px, gdouble *py, gdouble *pz)
490 GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
492 lle2xyz(lat, lon, elev, &x, &y, &z);
494 opengl->sphere->view->model,
495 opengl->sphere->view->proj,
496 opengl->sphere->view->view,
500 static void grits_opengl_unproject(GritsViewer *_opengl,
501 gdouble px, gdouble py, gdouble pz,
502 gdouble *lat, gdouble *lon, gdouble *elev)
504 GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
505 if (!opengl->sphere->view)
510 glReadPixels(px, py, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &tmp);
513 gluUnProject(px, py, pz,
514 opengl->sphere->view->model,
515 opengl->sphere->view->proj,
516 opengl->sphere->view->view,
518 xyz2lle(x, y, z, lat, lon, elev);
519 //g_message("GritsOpenGL: unproject - "
520 // "%4.0lf,%4.0lf,(%5.3lf) -> "
521 // "%8.0lf,%8.0lf,%8.0lf -> "
522 // "%6.2lf,%7.2lf,%4.0lf",
523 // px, py, pz, x, y, z, *lat, *lon, *elev);
526 static void grits_opengl_set_height_func(GritsViewer *_opengl, GritsBounds *bounds,
527 RoamHeightFunc height_func, gpointer user_data, gboolean update)
529 GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
530 /* TODO: get points? */
531 g_mutex_lock(&opengl->sphere_lock);
532 GList *triangles = roam_sphere_get_intersect(opengl->sphere, TRUE,
533 bounds->n, bounds->s, bounds->e, bounds->w);
534 for (GList *cur = triangles; cur; cur = cur->next) {
535 RoamTriangle *tri = cur->data;
536 RoamPoint *points[] = {tri->p.l, tri->p.m, tri->p.r, tri->split};
537 for (int i = 0; i < G_N_ELEMENTS(points); i++) {
538 if (bounds->n >= points[i]->lat && points[i]->lat >= bounds->s &&
539 bounds->e >= points[i]->lon && points[i]->lon >= bounds->w) {
540 points[i]->height_func = height_func;
541 points[i]->height_data = user_data;
542 roam_point_update_height(points[i]);
546 g_list_free(triangles);
547 g_mutex_unlock(&opengl->sphere_lock);
550 static void _grits_opengl_clear_height_func_rec(RoamTriangle *root)
554 RoamPoint *points[] = {root->p.l, root->p.m, root->p.r, root->split};
555 for (int i = 0; i < G_N_ELEMENTS(points); i++) {
556 points[i]->height_func = NULL;
557 points[i]->height_data = NULL;
558 roam_point_update_height(points[i]);
560 _grits_opengl_clear_height_func_rec(root->kids[0]);
561 _grits_opengl_clear_height_func_rec(root->kids[1]);
564 static void grits_opengl_clear_height_func(GritsViewer *_opengl)
566 GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
567 for (int i = 0; i < G_N_ELEMENTS(opengl->sphere->roots); i++)
568 _grits_opengl_clear_height_func_rec(opengl->sphere->roots[i]);
571 static gint _objects_find(gconstpointer a, gconstpointer b)
573 const struct RenderLevel *level = a;
575 return level->num == *key ? 0 : 1;
578 static gint _objects_sort(gconstpointer _a, gconstpointer _b, gpointer _)
580 const struct RenderLevel *a = _a;
581 const struct RenderLevel *b = _b;
582 return a->num < b->num ? -1 :
583 a->num > b->num ? 1 : 0;
586 static void _objects_free(gpointer value, gpointer _)
588 struct RenderLevel *level = value;
589 if (level->sorted.next)
590 g_list_free(level->sorted.next);
591 if (level->unsorted.next)
592 g_list_free(level->unsorted.next);
596 static gpointer grits_opengl_add(GritsViewer *_opengl, GritsObject *object,
597 gint num, gboolean sort)
599 g_assert(GRITS_IS_OPENGL(_opengl));
600 GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
601 g_mutex_lock(&opengl->objects_lock);
602 struct RenderLevel *level = NULL;
603 GList *tmp = g_queue_find_custom(opengl->objects, &num, _objects_find);
607 level = g_new0(struct RenderLevel, 1);
609 g_queue_insert_sorted(opengl->objects, level, _objects_sort, NULL);
611 GList *list = sort ? &level->sorted : &level->unsorted;
612 /* Put the link in the list */
613 GList *link = g_new0(GList, 1);
616 link->next = list->next;
618 list->next->prev = link;
620 g_mutex_unlock(&opengl->objects_lock);
624 static GritsObject *grits_opengl_remove(GritsViewer *_opengl, GritsObject *object)
626 g_assert(GRITS_IS_OPENGL(_opengl));
627 GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
628 GList *link = object->ref;
629 g_mutex_lock(&opengl->objects_lock);
630 /* Just unlink and free it, link->prev is assured */
631 link->prev->next = link->next;
633 link->next->prev = link->prev;
634 g_mutex_unlock(&opengl->objects_lock);
636 object->viewer = NULL;
638 g_object_unref(object);
645 G_DEFINE_TYPE(GritsOpenGL, grits_opengl, GRITS_TYPE_VIEWER);
646 static void grits_opengl_init(GritsOpenGL *opengl)
648 g_debug("GritsOpenGL: init");
649 opengl->objects = g_queue_new();
650 opengl->sphere = roam_sphere_new(opengl);
651 g_mutex_init(&opengl->objects_lock);
652 g_mutex_init(&opengl->sphere_lock);
653 gtk_gl_enable(GTK_WIDGET(opengl));
654 gtk_widget_add_events(GTK_WIDGET(opengl), GDK_KEY_PRESS_MASK);
655 g_signal_connect(opengl, "map", G_CALLBACK(on_realize), NULL);
657 static void grits_opengl_dispose(GObject *_opengl)
659 g_debug("GritsOpenGL: dispose");
660 G_OBJECT_CLASS(grits_opengl_parent_class)->dispose(_opengl);
662 static void grits_opengl_finalize(GObject *_opengl)
664 g_debug("GritsOpenGL: finalize");
665 GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
666 roam_sphere_free(opengl->sphere);
667 g_queue_foreach(opengl->objects, _objects_free, NULL);
668 g_queue_free(opengl->objects);
669 g_mutex_clear(&opengl->objects_lock);
670 g_mutex_clear(&opengl->sphere_lock);
671 G_OBJECT_CLASS(grits_opengl_parent_class)->finalize(_opengl);
673 static void grits_opengl_class_init(GritsOpenGLClass *klass)
675 g_debug("GritsOpenGL: class_init");
676 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
677 gobject_class->finalize = grits_opengl_finalize;
678 gobject_class->dispose = grits_opengl_dispose;
680 GritsViewerClass *viewer_class = GRITS_VIEWER_CLASS(klass);
681 viewer_class->center_position = grits_opengl_center_position;
682 viewer_class->project = grits_opengl_project;
683 viewer_class->unproject = grits_opengl_unproject;
684 viewer_class->clear_height_func = grits_opengl_clear_height_func;
685 viewer_class->set_height_func = grits_opengl_set_height_func;
686 viewer_class->add = grits_opengl_add;
687 viewer_class->remove = grits_opengl_remove;