]> Pileus Git - grits/blob - src/plugins/test.c
Refactor GisViewer and GisOpenGL
[grits] / src / plugins / test.c
1 /*
2  * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
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 #include <gtk/gtkgl.h>
19 #include <GL/gl.h>
20 #include <GL/glu.h>
21
22 #include <gis.h>
23
24 #include "test.h"
25
26 /***********
27  * Methods *
28  ***********/
29 GisPluginTest *gis_plugin_test_new(GisViewer *viewer)
30 {
31         g_debug("GisPluginTest: new");
32         GisPluginTest *self = g_object_new(GIS_TYPE_PLUGIN_TEST, NULL);
33         self->viewer = viewer;
34         return self;
35 }
36
37 static void gis_plugin_test_expose(GisPlugin *_self)
38 {
39         GisPluginTest *self = GIS_PLUGIN_TEST(_self);
40         g_debug("GisPluginTest: expose");
41
42         double width  = GTK_WIDGET(self->viewer)->allocation.width;
43         double height = GTK_WIDGET(self->viewer)->allocation.height;
44
45         // St. Charles
46         // lat =  38.841847
47         // lon = -90.491982
48         gdouble px, py, pz;
49         gis_viewer_project(self->viewer,
50                 38.841847, -90.491982, 0, &px, &py, &pz);
51         py = height-py;
52
53         //cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
54         //cairo_t *cairo = cairo_create(surface);
55         //cairo_set_source_rgba(cairo, 1, 1, 1, 1);
56         //cairo_arc(cairo, px, py, 4, 0, 2*G_PI);
57         //cairo_fill(cairo);
58         //cairo_move_to(cairo, px+4, py-8);
59         //cairo_set_font_size(cairo, 10);
60         //cairo_show_text(cairo, "Marker!");
61
62         //guint tex;
63         //glEnable(GL_TEXTURE_2D);
64         //glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
65         //glPixelStorei(GL_PACK_ALIGNMENT, 1);
66         //glGenTextures(1, &tex);
67         //glBindTexture(GL_TEXTURE_2D, tex);
68         //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
69         //              cairo_image_surface_get_data(surface));
70         //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
71         //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
72
73         //glMatrixMode(GL_PROJECTION);
74         //glLoadIdentity();
75         //glMatrixMode(GL_MODELVIEW);
76         //glLoadIdentity();
77
78         //glDisable(GL_COLOR_MATERIAL);
79         //glDisable(GL_CULL_FACE);
80         //glDisable(GL_DEPTH_TEST);
81         //glDisable(GL_LIGHTING);
82         //glBegin(GL_QUADS);
83         //glTexCoord2d(0, 0); glVertex3f(-1,  1, 1);
84         //glTexCoord2d(1, 0); glVertex3f( 1,  1, 1);
85         //glTexCoord2d(1, 1); glVertex3f( 1, -1, 1);
86         //glTexCoord2d(0, 1); glVertex3f(-1, -1, 1);
87         //glEnd();
88         //glDeleteTextures(1, &tex);
89         //cairo_destroy(cairo);
90         //cairo_surface_destroy(surface);
91 }
92
93
94 /****************
95  * GObject code *
96  ****************/
97 /* Plugin init */
98 static void gis_plugin_test_plugin_init(GisPluginInterface *iface);
99 G_DEFINE_TYPE_WITH_CODE(GisPluginTest, gis_plugin_test, G_TYPE_OBJECT,
100                 G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN,
101                         gis_plugin_test_plugin_init));
102 static void gis_plugin_test_plugin_init(GisPluginInterface *iface)
103 {
104         g_debug("GisPluginTest: plugin_init");
105         /* Add methods to the interface */
106         iface->expose = gis_plugin_test_expose;
107 }
108 /* Class/Object init */
109 static void gis_plugin_test_init(GisPluginTest *self)
110 {
111         g_debug("GisPluginTest: init");
112 }
113 static void gis_plugin_test_class_init(GisPluginTestClass *klass)
114 {
115         g_debug("GisPluginTest: class_init");
116 }