]> Pileus Git - grits/blob - src/plugins/test.c
Switch from GtkGLExt to internal OpenGL handling
[grits] / src / plugins / test.c
1 /*
2  * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
3  *
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.
8  *
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.
13  *
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/>.
16  */
17
18 /**
19  * SECTION:test
20  * @short_description: Testing plugin
21  *
22  * #GritsPluginTest is a testing plugin used during development and as an example
23  * for how to create a plugin.
24  */
25
26 #include <GL/gl.h>
27 #include <GL/glu.h>
28
29 #include <grits.h>
30
31 #include "test.h"
32
33 /***********
34  * Methods *
35  ***********/
36 gboolean _load_marker(gpointer _test)
37 {
38         GritsPluginTest *test = _test;
39         GritsMarker *marker = grits_marker_new("St. Charles");
40         grits_point_set_lle(grits_object_center(marker), 38.841847, -90.491982, 0);
41         GRITS_OBJECT(marker)->lod = EARTH_R;
42         test->marker = grits_viewer_add(test->viewer, GRITS_OBJECT(marker), GRITS_LEVEL_OVERLAY, 0);
43         return FALSE;
44 }
45 /**
46  * grits_plugin_test_new:
47  * @viewer: the #GritsViewer to use for drawing
48  *
49  * Create a new instance of the testing plugin.
50  *
51  * Returns: the new #GritsPluginTest
52  */
53 GritsPluginTest *grits_plugin_test_new(GritsViewer *viewer)
54 {
55         g_debug("GritsPluginTest: new");
56         GritsPluginTest *test = g_object_new(GRITS_TYPE_PLUGIN_TEST, NULL);
57         test->viewer = g_object_ref(viewer);
58         _load_marker(test);
59         return test;
60 }
61
62
63 /****************
64  * GObject code *
65  ****************/
66 /* Plugin init */
67 static void grits_plugin_test_plugin_init(GritsPluginInterface *iface);
68 G_DEFINE_TYPE_WITH_CODE(GritsPluginTest, grits_plugin_test, G_TYPE_OBJECT,
69                 G_IMPLEMENT_INTERFACE(GRITS_TYPE_PLUGIN,
70                         grits_plugin_test_plugin_init));
71 static void grits_plugin_test_plugin_init(GritsPluginInterface *iface)
72 {
73         g_debug("GritsPluginTest: plugin_init");
74         /* Add methods to the interface */
75 }
76 /* Class/Object init */
77 static void grits_plugin_test_init(GritsPluginTest *test)
78 {
79         g_debug("GritsPluginTest: init");
80 }
81 static void grits_plugin_test_dispose(GObject *_test)
82 {
83         g_debug("GritsPluginTest: dispose");
84         GritsPluginTest *test = GRITS_PLUGIN_TEST(_test);
85         if (test->viewer) {
86                 grits_viewer_remove(test->viewer, test->marker);
87                 g_object_unref(test->viewer);
88                 test->viewer = NULL;
89         }
90         G_OBJECT_CLASS(grits_plugin_test_parent_class)->dispose(_test);
91 }
92 static void grits_plugin_test_class_init(GritsPluginTestClass *klass)
93 {
94         g_debug("GritsPluginTest: class_init");
95         GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
96         gobject_class->dispose = grits_plugin_test_dispose;
97 }