- glBegin(GL_QUADS);
- int i;
- for (i = 0; i < 256; i++) {
- glColor4ubv(self->colormap->data[i]);
- glVertex3f(-1.0, (float)((i ) - 256/2)/(256/2), 0.0); // bot left
- glVertex3f(-1.0, (float)((i+1) - 256/2)/(256/2), 0.0); // top left
- glVertex3f(-0.9, (float)((i+1) - 256/2)/(256/2), 0.0); // top right
- glVertex3f(-0.9, (float)((i ) - 256/2)/(256/2), 0.0); // bot right
+
+ GHashTableIter iter;
+ gpointer name, _site;
+ GritsPluginRadar *self = GRITS_PLUGIN_RADAR(_self);
+ g_hash_table_iter_init(&iter, self->sites);
+ while (g_hash_table_iter_next(&iter, &name, &_site)) {
+ /* Pick correct colormaps */
+ RadarSite *site = _site;
+ if (site->hidden || !site->level2)
+ continue;
+ AWeatherColormap *colormap = site->level2->sweep_colors;
+
+ /* Print the color table */
+ glBegin(GL_QUADS);
+ int len = colormap->len;
+ for (int i = 0; i < len; i++) {
+ glColor4ubv(colormap->data[i]);
+ glVertex3f(-1.0, (float)((i ) - len/2)/(len/2), 0.0); // bot left
+ glVertex3f(-1.0, (float)((i+1) - len/2)/(len/2), 0.0); // top left
+ glVertex3f(-0.9, (float)((i+1) - len/2)/(len/2), 0.0); // top right
+ glVertex3f(-0.9, (float)((i ) - len/2)/(len/2), 0.0); // bot right
+ }
+ glEnd();
+ }
+}
+
+static void _load_colormap(gchar *filename, AWeatherColormap *cm)
+{
+ g_debug("GritsPluginRadar: _load_colormap - %s", filename);
+ FILE *file = fopen(filename, "r");
+ if (!file)
+ g_error("GritsPluginRadar: open failed");
+ guint8 color[4];
+ GArray *array = g_array_sized_new(FALSE, TRUE, sizeof(color), 256);
+ if (!fgets(cm->name, sizeof(cm->name), file)) goto out;
+ if (!fscanf(file, "%f\n", &cm->scale)) goto out;
+ if (!fscanf(file, "%f\n", &cm->shift)) goto out;
+ int r, g, b, a;
+ while (fscanf(file, "%d %d %d %d\n", &r, &g, &b, &a) == 4) {
+ color[0] = r;
+ color[1] = g;
+ color[2] = b;
+ color[3] = a;
+ g_array_append_val(array, color);